9. Feature:
Now User has given all his basic info and decided which products he will buy, then he
forward into the last process - pay the money. /registration/business_pay will summarize the
price(including tax and discount) he will pay and let user fill in his credit card info, when he
presses "Confirm", it will charge his credit card.
Scenario: Now user input credit card info and press "Confirm", the page will submit his info
to AriaSystem, AriaSystem will validate his credit card info, charge his credit card and return
some data to our database. Then our database will save his personal info and partner info. If
all these work well, user will be redirected to /registration/business_finish.
Given I reach /registration/business_pay
When I fill in basic info into /registration/business_pay
And I press "Confirm"
Then I should see "Please wait..."
And I waiting for being redirected to "/registration/business_finish"
And all MozyPro data in Database is correct
21. Step Definitions
Given /^I am in "([^"]*)"$/ do |url|
visit mozy_url(url, :https => true)
end
Then /^I would be redirected to "([^"]*)"$/ do |url|
page.current_url.should
be_include?mozy_url(url, :https => true)
end
22. Have a try ?
Let’s write a simple Cucumber test case
24. Gemfile
group :test do
gem 'cucumber'
gem 'cucumber-rails', require: false
gem 'capybara', git: 'https://github.com/jnicklas/capybara.git'
gem 'rspec' #use rspec expectation
gem 'Selenium' #use firefox to test
gem 'database_cleaner' #clean database after each test case
end
$ bundle install
26. features/support/env.rb
require 'cucumber/rails’
Capybara.default_selector = :css
Capybara.default_driver = :selenium #add this line
ActionController::Base.allow_rescue = false
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you
wish to use it."
End
Cucumber::Rails::Database.javascript_strategy = :truncation
27. features/sign_up.feature
Feature: Sign up
Scenario: I will register a user with email "zhour@vmware.com" and
password "vmware”
Given I fill in email "zhour@vmware.com" and password "vmware" in sign
up page
When I press "Sign up"
Then I should see "Page#index"