You just have to love this “syntax” 😀
Story
#features/discussion.feature
Scenario: I add to an discussion
Given I am logged in
And a "Discussion" exists for "Festival" "1"
And I am on "Festival" "1"
When I fill in "Text" with "Halloo"
And I press "Send"
Then I should be on "Festival" "1"
And I should see "Halloo"
Steps
#features/step_definitions/common_steps.rb # On page/record Given /^I am on "([^"]*)"$/ do |path| visit path end Then /^I should be on "([^"]*)"$/ do |path| current_path.should == path end Given /^I am on "([^"]*)" "([^"]*)"$/ do |model,number| visit polymorphic_path(record_from_strings(model,number)) end Then /^I should be on "([^"]*)" "([^"]*)"$/ do |model,number| current_path.should == polymorphic_path(record_from_strings(model,number)) end # Existing Given /^a "([^"]*)" exists for "([^"]*)" "([^"]*)"$/ do |associated,model,number| record = record_from_strings(model,number) record.send(associated.underscore+'=',valid(associated)) record.save! end # Login Then /^I should be logged in$/ do should be_logged_in end Given /^I am logged in$/ do visit 'login' fill_in 'email', :with=>'quentin@example.com' fill_in 'password', :with=>'test' click_button 'Login' end # Support def current_path response.request.request_uri end def record_from_strings(model,number) model.constantize.find(:first,:offset=>number.to_i-1) end
env.rb
#features/support/env.rb #load all fixtures include AuthenticatedTestHelper #restful_authentification include ValidAttributes #http://github.com/grosser/valid_attributes

