August 11, 2011. This presentation (lightning talk at the LA Ruby Meetup) demonstrates how to test your Rails app in-browser, full stack including javascript, without using cucumber. The testing stack uses RSpec, augmented by our gem RSpec-Steps, and capybara/selenium.
21. RSPEC PHILOSOPHY:
All tests / examples are
completely isolated and
independent!
22. RSPEC PHILOSOPHY:
All tests / examples are
completely isolated and
independent!
This is a problem for
integration testing / stories.
23. OPTION 1: Long examples
it “very long user story” do
# Log In
visit login_path
fill_in :login, “quentin”
click “Log In”
page.should have_text(“Welcome, Quentin!”)
# Update Profile
click “Update Profile”
page.should have_css(“form#edit_account”)
# More shit
... another 100 lines & 20 requests ...
end
24. OPTION 2: Repeat Yourself
it “should log in” do
visit login_path
fill_in :login, “quentin”
click “Log In”
page.should have_text(“Welcome, Quentin!”)
end
it “should log in and load profile form” do
visit login_path
... etc ...
click “Update Profile”
page.should have_css(“form#edit_account”)
end
it “should log in AND load form AND update profile” do
end
28. INTRODUCING: RSpec-Steps
steps “neat user story” do
it “should log in” do
visit login_path
fill_in :login, “quentin”
click “Log In”
page.should have_text(“Welcome, Quentin!”)
end
it “should load profile form do”
click “Update Profile”
page.should have_css(“form#edit_account”)
end
it “etc ... more steps” do
end
end