More Rails 3 in Action Fun: Chapter 4
The problems with outdated code unfortunately doesn’t end with Cucumber. FactoryGirl also has new syntax. Here is my solution:
p. 84: I kept Listing 4.1 as is.
I had to add handlers for things formerly handled by web_steps.rb. Here are the second two I had to create:
`
When /^I follow “(.*?)”$/ do |arg1|
click_link(arg1)
end</p>
Then /^I should be on the project page for "(.*?)"$/ do |arg1|
current_path.should == project_path(Project.find_by_name!(arg1))
end
`
On to Factory Girl:
On page 85 add ‘factory\_girl\_rails’ instead of ‘factory_girl’
Then your first step definition should be:
`
Given /^there is a project called "(.*?)"$/ do |arg1|
project = FactoryGirl.create(:project, :name => arg1)
end
`
The code for factories/project_factory.rb is (p. 86)
`
FactoryGirl.define do
factory :project do
name 'Ticketee'
end
end
`
features/support/factories.rb is now unnecessary and will cause your definitions to be loaded twice.
That’s only section 4.1, but should get you going.