When I run the script that is supposed to call adoption_helper.rb, I get the following error message:
C:/Users/mmiddleton/git/CucumberAndCheese/CucumberAndCheese/adoption_helper.rb:4:in `goto_puppy_adoption_site': undefined method `goto' for nil:NilClass (NoMethodError)
from C:/Users/mmiddleton/git/CucumberAndCheese/CucumberAndCheese/adopt_puppies_with_helper.rb:7:in `<main>'
I copied the methods from the previous script, and pasted them in adoption_helper.rb, and copied the lines that call those methods in to a script I called adopt_puppies_with_helper.rb, so I know the spelling is correct. I'm pretty sure that I've capitalized the Module declaration and call correctly, so I can't figure out what's on the go. Below are the two scripts:
adoption_helper.rb
module AdoptionHelper
def goto_puppy_adoption_site
end
def adopt_puppy_number(num)
@browser.button(:value => 'View Details', :index => num - 1).click
@browser.button(:value => 'Adopt Me!').click
end
def continue_adopting_puppies
@browser.button(:value => 'Adopt Another Puppy').click
end
def checkout_with(name, address, email, pay_type)
@browser.button(:value => 'Complete the Adoption').click
@browser.text_field(:id => 'order_name').set(name)
@browser.text_field(:id => 'order_address').set(address)
@browser.text_field(:id => 'order_email').set(email)
@browser.select_list(:id => 'order_pay_type').select(pay_type)
@browser.button(:value => 'Place Order').click
end
def verify_page_contains(text)
fail 'Browser text did not match expected value' unless @browser.text.include? text
end
def close_browser
@browser.close
end
end
adopt_puppies_with_helper.rb
require 'rubygems'
require 'watir-webdriver'
require_relative 'adoption_helper'
include AdoptionHelper
goto_puppy_adoption_site
adopt_puppy_number 1
continue_adopting_puppies
adopt_puppy_number 2
verify_page_contains 'Thank you for adopting a puppy!'
close_browser