Permalink
Browse files

started cucumber tests for orders

  • Loading branch information...
1 parent 0484a5c commit 6b5cd76f86a187e071d3dfd6e5bda3b016c0aca8 @khustochka committed Mar 10, 2010
@@ -35,17 +35,17 @@ Feature: Restricted access to administration parts for external users
Scenario: Unauthorized user should not see New Ordo page
- When I go to New Ordo page
+ When I go to the new ordo page
Then I should see 404 status page
Scenario: Unauthorized user should not see New Familia page
- When I go to New Familia page
+ When I go to the new familia page
Then I should see 404 status page
Scenario: Unauthorized user should not see New Species page
- When I go to New Species page
+ When I go to the new species page
Then I should see 404 status page
Scenario: Unauthorized user should not create new ordo
@@ -0,0 +1,28 @@
+Feature: Manage ordines
+ In order to [goal]
+ [stakeholder]
+ wants [behaviour]
+
+ Scenario: Register new ordo
+ Given logged as administrator
+ When I go to the new ordo page
+ When I fill in the following:
+ | Name la | Sphenisciformes2 |
+ | Name ru | Пингвинообразные |
+ | Name uk | Пінгвіноподібні |
+ And I press "Create"
+ Then I should see "Sphenisciformes"
+
+# Scenario: Delete ordo
+# Given the following ordines:
+# |name_la|
+# |name_la 1|
+# |name_la 2|
+# |name_la 3|
+# |name_la 4|
+# When I delete the 3rd ordo
+# Then I should see the following ordines:
+# |Name la|
+# |name_la 1|
+# |name_la 2|
+# |name_la 4|
@@ -0,0 +1,14 @@
+Given /^the following ordines:$/ do |ordines|
+ Ordo.create!(ordines.hashes)
+end
+
+When /^I delete the (\d+)(?:st|nd|rd|th) ordo$/ do |pos|
+ visit ordines_url
+ within("table tr:nth-child(#{pos.to_i+1})") do
+ click_link "Destroy"
+ end
+end
+
+Then /^I should see the following ordines:$/ do |expected_ordines_table|
+ expected_ordines_table.diff!(tableish('table tr', 'td,th'))
+end
@@ -15,6 +15,11 @@
basic_auth(user_name, password)
end
+Given /^logged as administrator$/ do
+ Given 'logged as "admin" with password "secret2pwd"'
+ When 'I go to Admin dashboard'
+end
+
Given /^(?:|I )am on (.+)$/ do |page_name|
visit path_to(page_name)
end
@@ -24,7 +29,10 @@
end
When /^(?:|I )press "([^\"]*)"$/ do |button|
- click_button(button)
+ begin
+ click_button(button)
+ rescue ActiveRecord::RecordInvalid
+ end
end
When /^(?:|I )follow "([^\"]*)"$/ do |link|
@@ -130,16 +138,16 @@
type = path.split(".")[1]
case type
- when "jpg"
- type = "image/jpg"
- when "jpeg"
- type = "image/jpeg"
- when "png"
- type = "image/png"
- when "gif"
- type = "image/gif"
+ when "jpg"
+ type = "image/jpg"
+ when "jpeg"
+ type = "image/jpeg"
+ when "png"
+ type = "image/png"
+ when "gif"
+ type = "image/gif"
end
-
+
attach_file(field, path, type)
end
@@ -267,8 +275,8 @@
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
actual_params = CGI.parse(URI.parse(current_url).query)
- expected_params = Hash[expected_pairs.rows_hash.map{|k,v| [k,[v]]}]
-
+ expected_params = Hash[expected_pairs.rows_hash.map{|k, v| [k, [v]]}]
+
if defined?(Spec::Rails::Matchers)
actual_params.should == expected_params
else
@@ -17,8 +17,8 @@ def path_to(page_name)
when /(Ordines|Familiae) Index/
"/admin/#{$1.downcase}"
- when /New (Ordo|Familia|Species) page/
- "/admin/#{$1.downcase}/new"
+ when /the new (ordo|familia|species) page/
+ "/admin/#{$1.pluralize}/new"
when /'([^']*)'/
$1

0 comments on commit 6b5cd76

Please sign in to comment.