Browse files

features created in cucumber scaffold

  • Loading branch information...
1 parent 66744b4 commit f0da74dc7677f49b898246fc807f63c254a75237 @johnivanoff committed Oct 29, 2010
Showing with 72 additions and 0 deletions.
  1. +55 −0 features/manage_accounts.feature
  2. +14 −0 features/step_definitions/account_steps.rb
  3. +3 −0 features/support/paths.rb
View
55 features/manage_accounts.feature
@@ -0,0 +1,55 @@
+Feature: Manage accounts
+ In order to [goal]
+ [stakeholder]
+ wants [behaviour]
+
+ Scenario: Register new account
+ Given I am on the new account page
+ When I fill in "Name" with "name 1"
+ And I fill in "Address" with "address 1"
+ And I fill in "City" with "city 1"
+ And I fill in "State" with "state 1"
+ And I fill in "Zip code" with "zip_code 1"
+ And I press "Create"
+ Then I should see "name 1"
+ And I should see "address 1"
+ And I should see "city 1"
+ And I should see "state 1"
+ And I should see "zip_code 1"
+
+ # Rails generates Delete links that use Javascript to pop up a confirmation
+ # dialog and then do a HTTP POST request (emulated DELETE request).
+ #
+ # Capybara must use Culerity/Celerity or Selenium2 (webdriver) when pages rely
+ # on Javascript events. Only Culerity/Celerity supports clicking on confirmation
+ # dialogs.
+ #
+ # Since Culerity/Celerity and Selenium2 has some overhead, Cucumber-Rails will
+ # detect the presence of Javascript behind Delete links and issue a DELETE request
+ # instead of a GET request.
+ #
+ # You can turn this emulation off by tagging your scenario with @no-js-emulation.
+ # Turning on browser testing with @selenium, @culerity, @celerity or @javascript
+ # will also turn off the emulation. (See the Capybara documentation for
+ # details about those tags). If any of the browser tags are present, Cucumber-Rails
+ # will also turn off transactions and clean the database with DatabaseCleaner
+ # after the scenario has finished. This is to prevent data from leaking into
+ # the next scenario.
+ #
+ # Another way to avoid Cucumber-Rails' javascript emulation without using any
+ # of the tags above is to modify your views to use <button> instead. You can
+ # see how in http://github.com/jnicklas/capybara/issues#issue/12
+ #
+ Scenario: Delete account
+ Given the following accounts:
+ |name|address|city|state|zip_code|
+ |name 1|address 1|city 1|state 1|zip_code 1|
+ |name 2|address 2|city 2|state 2|zip_code 2|
+ |name 3|address 3|city 3|state 3|zip_code 3|
+ |name 4|address 4|city 4|state 4|zip_code 4|
+ When I delete the 3rd account
+ Then I should see the following accounts:
+ |Name|Address|City|State|Zip code|
+ |name 1|address 1|city 1|state 1|zip_code 1|
+ |name 2|address 2|city 2|state 2|zip_code 2|
+ |name 4|address 4|city 4|state 4|zip_code 4|
View
14 features/step_definitions/account_steps.rb
@@ -0,0 +1,14 @@
+Given /^the following accounts:$/ do |accounts|
+ Account.create!(accounts.hashes)
+end
+
+When /^I delete the (\d+)(?:st|nd|rd|th) account$/ do |pos|
+ visit accounts_path
+ within("table tr:nth-child(#{pos.to_i+1})") do
+ click_link "Destroy"
+ end
+end
+
+Then /^I should see the following accounts:$/ do |expected_accounts_table|
+ expected_accounts_table.diff!(tableish('table tr', 'td,th'))
+end
View
3 features/support/paths.rb
@@ -10,6 +10,9 @@ def path_to(page_name)
when /the home\s?page/
'/'
+ when /the new account page/
+ new_account_path
+
when /the new contact page/
new_contact_path

0 comments on commit f0da74d

Please sign in to comment.