Feature file:
Feature: Adopting two puppies
As a puppy lover
I want to adopt puppies
So they can chew my furniture
Scenario: Adopting two puppies
Given I am on the puppy adoption site
When I click the first View Details button
And I click the Adopt Me button first
And I click the Adopt Another Puppy button
And I click the second View Details button
And I click the Adopt Me button second
And I click the Complete the Adoption button
And I enter "Cheezy" in the name field
And I enter "123 Main Street" in the address field
And I select "Credit card" from the pay with dropdown
And I click the Place Order button
Then I should see "Thank you for adopting a puppy!"
Step definition:
Given(/^I am on the puppy adoption site$/) do
end
When(/^I click the first View Details button$/) do
@browser.button(:value => "View Details").click
end
And(/^I click the Adopt Me button first$/) do
@browser.button(:value => "Adopt Me!").click
end
And(/^I click the Adopt Another Puppy button$/) do
@browser.button(:value => "Complete the Adoption").click
end
And(/^I click the second View Details button$/) do
@browser.button(:value => "Complete the Adoption").click
end
And(/^I click the Adopt Me button second$/) do
@browser.button(:value => "Adopt Me!").click
end
And(/^I click the Complete the Adoption button$/) do And(/^I enter "(.*?)" in the name field$/) do |arg1|
@browser.button(:value => "Complete the Adoption").click
end
When(/^I enter "([^\"]*)" in the name field$/) do |name|
@browser.text_field(:id => "order_name").set(name)
end
And(/^I enter "([^\"]*)" in the address field$/) do |adress|
@browser.text_field(:id => "order_address").set(address)
end
And(/^I enter "([^\"]*)" in the email field$/) do |email|
@browser.text_field(:id => "order_email").set(email)
end
And(/^I select "(.*?)" from the pay with dropdown$/) do |pay_type|
@browser.select_list(:id => "order_pay_type").select(pay_type)
end
And(/^I click the Place Order button$/) do
@browser.button(:value => "Place Order").click
end
Then /^I should see "([^\"]*)" $/ do |expected|
@browser.text.should include expected
end
Following is the error:
C:\Ruby193\bin\ruby.exe -EUTF-8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:\Ruby193\bin/cucumber C:/RubymineProjects/test_puppies/features/adopting_two_puppies.feature --format Teamcity::Cucumber::Formatter --expand --color -r features
Testing started at 2:26 AM ...
C:/RubymineProjects/test_puppies/features/step_definitions/adopting_two_puppies.rb:66: syntax error, unexpected $end, expecting keyword_end (SyntaxError)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/lib/cucumber/rb_support/rb_language.rb:122:in `load'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/lib/cucumber/rb_support/rb_language.rb:122:in `load_code_file'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/lib/cucumber/runtime/support_code.rb:180:in `load_file'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/lib/cucumber/runtime/support_code.rb:82:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/lib/cucumber/runtime.rb:183:in `load_step_definitions'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/lib/cucumber/runtime.rb:42:in `run!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/lib/cucumber/cli/main.rb:47:in `execute!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.6/bin/cucumber:13:in `<top (required)>'
C:/Ruby193/bin/cucumber:23:in `load'
C:/Ruby193/bin/cucumber:23:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
Process finished with exit code 1
Please let me know what am I doing wrong. How should I bold statements in the feature file and accordingly.
I didn't get the thing suggested in the book on Page number 50 in the following paragraph.
"Go ahead and generate the step definition and implement the methods. As you see, we were able to
reuse much of the previous step definitions in this new Scenario. The two steps that we did have to
create were the ones that clicked the first and second view details buttons. We already had a step in
the first Scenario that clicked the first view details button. When we see this sort of duplication it is
a good idea to remove it. Please change the first scenario to use the step When I click the first View
Details button and then remove the step definition for the generic method so it no longer exists in
your step definition file."