14. Webrat Core API
• visit, click_link
• get + assert_response :success
• click_button
• submit form + assert_response :success
• submit form default values if any
15. Webrat + RSpec
describe "tweeting" do
it "should show my tweets" do
visit "/home"
fill_in "status", :with => "lorem ipsum"
click_button "update"
response.body.should =~ /lorem ipsum/
end
end
19. Feature: Update my status
In order to keep friends posted
As a friendly person
I post my status to twitter
Scenario: Update my status
Given I go to “/home”
When I fill in “status” with “lorem ipsum”
And I click “send”
Then I should see “lorem ipsum”
20. Feature: Update my status
In order to keep friends posted
As a friendly person
I post my status to twitter
Scenario: Update my status
Given I go to “/home”
When I fill in “status” with “lorem ipsum”
And I click “send”
Then I should see “lorem ipsum”
21. Feature: Update my status
In order to keep friends posted
As a friendly person
I post my status to twitter
Scenario: Update my status
Given I go to “/home”
When I fill in “status” with “lorem ipsum”
And I click “send”
Then I should see “lorem ipsum”
22. Scenario: Update my status
Given I go to “/home”
When I fill in “status” with “lorem ipsum”
And I click “send”
Then I should see “lorem ipsum”
Given –
When –
Then –
23. Given /^I go to "(.*)"$/ do |url|
visit url
end
When /^I fill in "(.*)" with "(.*)"$/ do |field,value|
fill_in field, :with => value
end
When /^I click "(.*)"$/ do |link|
click_link(link)
end
Then /^I should see "(.*)"$/ do |text|
response.body.should =~ /#{text}/m
end
27. Scenario: Update my status
Given I go to “/home”
When I fill in “status” with “lorem ipsum”
And I click “send”
Then I should see “lorem ipsum”
28. describe "tweeting" do
it "should show my tweets" do
visit "/home"
fill_in "status", :with => "lorem ipsum"
click_button "update"
response.body.should =~ /lorem ipsum/
end
end