Permalink
Browse files

updates from glrb

  • Loading branch information...
1 parent 366b314 commit 08c94acea7403ac03eba20463cfb5a50942674e0 @cheezy committed Jun 18, 2011
Showing with 89 additions and 2 deletions.
  1. +1 −1 app/models/order.rb
  2. +31 −1 features/glrb.feature
  3. +28 −0 features/pages/personal_info_page.rb
  4. +29 −0 features/step_definitions/glrb_steps.rb
View
@@ -1,6 +1,6 @@
class Order < ActiveRecord::Base
has_many :adoptions, :dependent => :destroy
- PAYMENT_TYPES = [ 'Check', 'Credit card', 'Purchase order' ]
+ PAYMENT_TYPES = [ 'Check', 'Credit card', 'Cash' ]
validates :name, :address, :email, :pay_type, :presence => true
validates :pay_type, :inclusion => PAYMENT_TYPES
View
@@ -1,2 +1,32 @@
+Feature: Entering your personal info to complete an adoption
-Feature: Entering your personal information to complete the adoption
+ Background:
+ Given I am on the puppy adoption site
+
+ Scenario: Filling in all fields
+ When I complete the adoption
+ And I enter the following personal info
+ | name | address | email | pay_type |
+ | Sam Smith | 1213 Main Street | sam@example.com | Credit card |
+ Then I should see "Thank you for adopting a puppy"
+
+ Scenario: Name is required
+ When I complete the adoption
+ And I complete the adoption leaving the "Name" field blank
+ Then I should see an error message with "Name can't be blank"
+
+ Scenario: Address is required
+ When I complete the adoption
+ And I complete the adoption leaving the "Address" field blank
+ Then I should see an error message with "Address can't be blank"
+
+ Scenario: Email is required
+ When I complete the adoption
+ And I complete the adoption leaving the "Email" field blank
+ Then I should see an error message with "Email can't be blank"
+
+ Scenario: Options for Pay with
+ When I complete the adoption
+ Then the Pay with dropdown should contain "Check"
+ And the Pay with dropdown should contain "Credit card"
+ And the Pay with dropdown should contain "Cash"
@@ -0,0 +1,28 @@
+class PersonalInfoPage
+ include PageObject
+
+ DEFAULT_DATA = {
+ 'name' => 'cheezy',
+ 'address' => '123 main street',
+ 'email' => 'cheezy@leandog.com',
+ 'pay_type' => 'Credit card',
+ 'accept' => true
+ }
+
+ text_field(:name, :id => 'order_name')
+ text_area(:address, :id => 'order_address')
+ text_field(:email, :id => 'order_email')
+ select_list(:pay_type, :id => 'order_pay_type')
+ checkbox(:accept, :id => 'order_accept')
+ button(:place_adoption, :text => 'Place Adoption')
+
+ def complete_adoption(personal_info)
+ personal_info = DEFAULT_DATA.merge(personal_info)
+ self.name = personal_info['name']
+ self.address = personal_info['address']
+ self.email = personal_info['email']
+ self.pay_type = personal_info['pay_type']
+ self.check_accept if personal_info['accept']
+ place_adoption
+ end
+end
@@ -0,0 +1,29 @@
+When /^I enter the following personal info$/ do |table|
+ on_page PersonalInfoPage do |page|
+ page.complete_adoption table.hashes.first
+ end
+end
+
+Then /^I should see "([^\"]*)"$/ do |expected_text|
+ on_page HomePage do |page|
+ page.text.should include expected_text
+ end
+end
+
+When /^I complete the adoption leaving the "([^\"]*)" field blank$/ do |field|
+ on_page PersonalInfoPage do |page|
+ page.complete_adoption field.downcase => ''
+ end
+end
+
+Then /^I should see an error message with "([^\"]*)"$/ do |message|
+ on_page PersonalInfoPage do |page|
+ page.text.should include message
+ end
+end
+
+Then /^the Pay with dropdown should contain "([^\"]*)"$/ do |value|
+ on_page PersonalInfoPage do |page|
+ page.pay_type_select_list.text.should include value
+ end
+end

0 comments on commit 08c94ac

Please sign in to comment.