mattscilipoti-cucumber-rails 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. data/.gitignore +3 -0
  2. data/History.txt +84 -0
  3. data/README.rdoc +38 -0
  4. data/Rakefile +19 -0
  5. data/VERSION +1 -0
  6. data/cucumber-rails.gemspec +84 -0
  7. data/generators/cucumber/USAGE +14 -0
  8. data/generators/cucumber/cucumber_generator.rb +196 -0
  9. data/generators/cucumber/templates/config/cucumber.yml.erb +7 -0
  10. data/generators/cucumber/templates/environments/cucumber.rb.erb +37 -0
  11. data/generators/cucumber/templates/script/cucumber +10 -0
  12. data/generators/cucumber/templates/step_definitions/capybara_steps.rb.erb +187 -0
  13. data/generators/cucumber/templates/step_definitions/web_steps_cs.rb.erb +136 -0
  14. data/generators/cucumber/templates/step_definitions/web_steps_de.rb.erb +136 -0
  15. data/generators/cucumber/templates/step_definitions/web_steps_es.rb.erb +136 -0
  16. data/generators/cucumber/templates/step_definitions/web_steps_no.rb.erb +114 -0
  17. data/generators/cucumber/templates/step_definitions/web_steps_pt-BR.rb.erb +140 -0
  18. data/generators/cucumber/templates/step_definitions/webrat_steps.rb.erb +258 -0
  19. data/generators/cucumber/templates/support/_rails_each_run.rb +29 -0
  20. data/generators/cucumber/templates/support/_rails_prefork.rb.erb +10 -0
  21. data/generators/cucumber/templates/support/capybara.rb +9 -0
  22. data/generators/cucumber/templates/support/edit_warning.txt +5 -0
  23. data/generators/cucumber/templates/support/paths.rb +27 -0
  24. data/generators/cucumber/templates/support/rails.rb.erb +4 -0
  25. data/generators/cucumber/templates/support/rails_spork.rb.erb +13 -0
  26. data/generators/cucumber/templates/support/webrat.rb +8 -0
  27. data/generators/cucumber/templates/tasks/cucumber.rake.erb +42 -0
  28. data/generators/feature/USAGE +12 -0
  29. data/generators/feature/feature_generator.rb +41 -0
  30. data/generators/feature/templates/feature.erb +59 -0
  31. data/generators/feature/templates/steps.erb +14 -0
  32. data/lib/cucumber/rails/action_controller.rb +65 -0
  33. data/lib/cucumber/rails/active_record.rb +36 -0
  34. data/lib/cucumber/rails/capybara_javascript_emulation.rb +61 -0
  35. data/lib/cucumber/rails/rspec.rb +10 -0
  36. data/lib/cucumber/rails/test_unit.rb +9 -0
  37. data/lib/cucumber/rails/world.rb +47 -0
  38. data/lib/cucumber/web/tableish.rb +75 -0
  39. data/spec/cucumber/web/tableish_spec.rb +160 -0
  40. data/spec/spec_helper.rb +6 -0
  41. data/tasks/rspec.rake +13 -0
  42. metadata +107 -0
@@ -0,0 +1,136 @@
1
+ # encoding: utf-8
2
+ <%= embed_file('support/edit_warning.txt') %>
3
+
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+
6
+ Dado /^que estoy en (.+)$/ do |page_name|
7
+ Given %{I am on #{page_name}}
8
+ end
9
+
10
+ Cuando /^voy a (.+)$/ do |page_name|
11
+ When %{I go to #{page_name}}
12
+ end
13
+
14
+ Cuando /^apreto "([^\"]*)"$/ do |button|
15
+ When %{I press "#{button}"}
16
+ end
17
+
18
+ Cuando /^clickeo "([^\"]*)"$/ do |link|
19
+ When %{I follow "#{link}"}
20
+ end
21
+
22
+ Cuando /^clickeo "([^\"]*)" dentro de "([^\"]*)"$/ do |link, parent|
23
+ When %{I follow "#{link}" within "#{parent}"}
24
+ end
25
+
26
+ Cuando /^completo "([^\"]*)" con "([^\"]*)"$/ do |field, value|
27
+ When %{I fill in "#{field}" with "#{value}"}
28
+ end
29
+
30
+ Cuando /^completo "([^\"]*)" para "([^\"]*)"$/ do |value, field|
31
+ When %{I fill in "#{value}" for "#{field}"}
32
+ end
33
+
34
+ Cuando /^completo lo siguiente:$/ do |fields|
35
+ When %{I fill in the following:}, fields
36
+ end
37
+
38
+ Cuando /^selecciono "([^\"]*)" de "([^\"]*)"$/ do |value, field|
39
+ When %{I select "#{value}" from "#{field}"}
40
+ end
41
+
42
+ Cuando /^selecciono "([^\"]*)" como la fecha y la hora$/ do |time|
43
+ When %{I select "#{time}" as the date and time}
44
+ end
45
+
46
+ Cuando /^selecciono "([^\"]*)" como la fecha y la hora "([^\"]*)"$/ do |datetime, datetime_label|
47
+ When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
48
+ end
49
+
50
+ Cuando /^selecciono "([^\"]*)" como la hora$/ do |time|
51
+ When %{I select "#{time}" as the time}
52
+ end
53
+
54
+ Cuando /^selecciono "([^\"]*)" como la hora "([^\"]*)"$/ do |time, time_label|
55
+ When %{I select "#{time}" as the "#{time_label}" time}
56
+ end
57
+
58
+ Cuando /^selecciono "([^\"]*)" como la fecha$/ do |date|
59
+ When %{I select "#{date}" as the date}
60
+ end
61
+
62
+ Cuando /^selecciono "([^\"]*)" como la fecha "([^\"]*)"$/ do |date, date_label|
63
+ When %{I select "#{date}" as the "#{date_label}" date}
64
+ end
65
+
66
+ Cuando /^marco "([^\"]*)"$/ do |field|
67
+ When %{I check "#{field}"}
68
+ end
69
+
70
+ Cuando /^desmarco "([^\"]*)"$/ do |field|
71
+ When %{I uncheck "#{field}"}
72
+ end
73
+
74
+ Cuando /^elijo "([^\"]*)"$/ do |field|
75
+ When %{I choose "#{field}"}
76
+ end
77
+
78
+ Cuando /^adjunto el archivo "([^\"]*)" a "([^\"]*)"$/ do |path, field|
79
+ When %{I attach the file "#{path}" to "#{field}"}
80
+ end
81
+
82
+ Entonces /^debería ver "([^\"]*)"$/ do |text|
83
+ Then %{I should see "#{text}"}
84
+ end
85
+
86
+ Entonces /^debería ver "([^\"]*)" dentro de "([^\"]*)"$/ do |text, selector|
87
+ Then %{I should see "#{text}" within "#{selector}"}
88
+ end
89
+
90
+ Entonces /^debería ver \/([^\/]*)\/$/ do |regexp|
91
+ Then %{I should see /#{regexp}/}
92
+ end
93
+
94
+ Entonces /^debería ver \/([^\/]*)\/ dentro de "([^\"]*)"$/ do |regexp, selector|
95
+ Then %{I should see /#{regexp}/ within "#{selector}"}
96
+ end
97
+
98
+ Entonces /^no debería ver "([^\"]*)"$/ do |text|
99
+ Then %{I should not see "#{text}"}
100
+ end
101
+
102
+ Entonces /^no debería ver "([^\"]*)" dentro de "([^\"]*)"$/ do |text, selector|
103
+ Then %{I should not see "#{text}" within "#{selector}"}
104
+ end
105
+
106
+ Entonces /^no debería ver \/([^\/]*)\/$/ do |regexp|
107
+ Then %{I should not see /#{regexp}/}
108
+ end
109
+
110
+ Entonces /^no debería ver \/([^\/]*)\/ dentro de "([^\"]*)"$/ do |regexp, selector|
111
+ Then %{I should not see /#{regexp}/ within "#{selector}"}
112
+ end
113
+
114
+ Entonces /^el campo "([^\"]*)" debería contener "([^\"]*)"$/ do |field, value|
115
+ Then %{the "#{field}" field should contain "#{value}"}
116
+ end
117
+
118
+ Entonces /^el campo "([^\"]*)" no debería contener "([^\"]*)"$/ do |field, value|
119
+ Then %{the "#{field}" field should not contain "#{value}"}
120
+ end
121
+
122
+ Entonces /^la checkbox "([^\"]*)" debería estar marcada$/ do |label|
123
+ Then %{the "#{label}" checkbox should be checked}
124
+ end
125
+
126
+ Entonces /^la checkbox "([^\"]*)" no debería estar marcada$/ do |label|
127
+ Then %{the "#{label}" checkbox should not be checked}
128
+ end
129
+
130
+ Entonces /^debería estar en (.+)$/ do |page_name|
131
+ Then %{I should be on #{page_name}}
132
+ end
133
+
134
+ Entonces /^mostrame la página$/ do
135
+ Then %{show me the page}
136
+ end
@@ -0,0 +1,114 @@
1
+ # encoding: utf-8
2
+ <%= embed_file('support/edit_warning.txt') %>
3
+
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+
6
+ Gitt /^(?:at )jeg står på (.*)$/ do |page_name|
7
+ Given %{I am on #{page_name}}
8
+ end
9
+
10
+ Når /^jeg går til (.*)$/ do |page_name|
11
+ When %{I go to #{page_name}}
12
+ end
13
+
14
+ Når /^jeg trykker "([^\"]*)"$/ do |button|
15
+ When %{I press "#{button}"}
16
+ end
17
+
18
+ Når /^jeg klikker "([^\"]*)"$/ do |link|
19
+ When %{I follow "#{link}"}
20
+ end
21
+
22
+ Når /^jeg klikker "([^\"]*)" under "([^\"]*)"$/ do |link, parent|
23
+ When %{I follow "#{link}" within "#{parent}"}
24
+ end
25
+
26
+ Når /^jeg fyller inn "([^\"]*)" med "([^\"]*)"$/ do |field, value|
27
+ When %{I fill in "#{field}" with "#{value}"}
28
+ end
29
+
30
+ Når /^jeg fyller inn "([^\"]*)" for "([^\"]*)"$/ do |value, field|
31
+ When %{I fill in "#{value}" for "#{field}"}
32
+ end
33
+
34
+ Når /^jeg fyller inn følgende:$/ do |fields|
35
+ When %{I fill in the following:}, fields
36
+ end
37
+
38
+ Når /^jeg velger "([^\"]*)" fra "([^\"]*)"$/ do |value, field|
39
+ When %{I select "#{value}" from "#{field}"}
40
+ end
41
+
42
+ # Missing: date stuff
43
+
44
+ Når /^jeg krysser av "([^\"]*)"$/ do |field|
45
+ When %{I check "#{field}"}
46
+ end
47
+
48
+ Når /^jeg fjerner avkrysning for "([^\"]*)"$/ do |field|
49
+ When %{I uncheck "#{field}"}
50
+ end
51
+
52
+ Når /^jeg velger "([^\"]*)"$/ do |field|
53
+ When %{I choose "#{field}"}
54
+ end
55
+
56
+ Når /^jeg legger ved filen "([^\"]*)" til "([^\"]*)"$/ do |path, field|
57
+ When %{I attach the file "#{path}" to "#{field}"}
58
+ end
59
+
60
+ Så /^(?:skal jeg|jeg skal) se "([^\"]*)"$/ do |text|
61
+ Then %{I should see "#{text}"}
62
+ end
63
+
64
+ Så /^(?:skal jeg|jeg skal) se "([^\"]*)" under "([^\"]*)"$/ do |text, selector|
65
+ Then %{I should see "#{text}" within "#{selector}"}
66
+ end
67
+
68
+ Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/$/ do |regexp|
69
+ Then %{I should see /#{regexp}/}
70
+ end
71
+
72
+ Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/ under "([^\"]*)"$/ do |regexp, selector|
73
+ Then %{I should see /#{regexp}/ within "#{selector}"}
74
+ end
75
+
76
+ Så /^(?:skal jeg|jeg skal) ikke se "([^\"]*)"$/ do |text|
77
+ Then %{I should not see "#{text}"}
78
+ end
79
+
80
+ Så /^(?:skal jeg|jeg skal) ikke se "([^\"]*)" under "([^\"]*)"$/ do |text, selector|
81
+ Then %{I should not see "#{text}" within "#{selector}"}
82
+ end
83
+
84
+ Så /^(?:skal jeg|jeg skal) ikke se \/([^\/]*)\/$/ do |regexp|
85
+ Then %{I should not see /#{regexp}/}
86
+ end
87
+
88
+ Så /^(?:skal jeg|jeg skal) ikke se \/([^\/]*)\/ under "([^\"]*)"$/ do |regexp, selector|
89
+ Then %{I should not see /#{regexp}/ within "#{selector}"}
90
+ end
91
+
92
+ Så /^(?:skal )"([^\"]*)" feltet (?:skal )inneholde "([^\"]*)"$/ do |field, value|
93
+ Then %{the "#{field}" field should contain "#{value}"}
94
+ end
95
+
96
+ Så /^(?:skal ) "([^\"]*)" feltet (?:skal )ikke inneholde "([^\"]*)"$/ do |field, value|
97
+ Then %{the "#{field}" field should not contain "#{value}"}
98
+ end
99
+
100
+ Så /^(?:skal ) "([^\"]*)" avkrysningsboksen (?:skal )være krysset av$/ do |label|
101
+ Then %{the "#{label}" checkbox should be checked}
102
+ end
103
+
104
+ Så /^(?:skal ) "([^\"]*)" avkrysningsboksen (?:skal )ikke være krysset av$/ do |label|
105
+ Then %{the "#{label}" checkbox should not be checked}
106
+ end
107
+
108
+ Så /^(?:skal jeg|jeg skal) komme til (.+)$/ do |page_name|
109
+ Then %{I should be on #{page_name}}
110
+ end
111
+
112
+ Så /^vil jeg se siden$/ do |page_name|
113
+ Then %{show me the page}
114
+ end
@@ -0,0 +1,140 @@
1
+ # encoding: utf-8
2
+ <%= embed_file('support/edit_warning.txt') %>
3
+
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+
6
+ Dado /^que eu esteja na (.+)$/ do |page_name|
7
+ Given %{I am on #{page_name}}
8
+ end
9
+
10
+ Quando /^eu vou para (.+)$/ do |page_name|
11
+ When %{I go to #{page_name}}
12
+ end
13
+
14
+ Quando /^eu aperto "([^\"]*)"$/ do |button|
15
+ When %{I press "#{button}"}
16
+ end
17
+
18
+ Quando /^eu clico "([^\"]*)"$/ do |link|
19
+ When %{I follow "#{link}"}
20
+ end
21
+
22
+ Quando /^eu clico "([^\"]*)" dentro de "([^\"]*)"$/ do |link, parent|
23
+ When %{I follow "#{link}" within "#{parent}"}
24
+ end
25
+
26
+ Quando /^eu preencho "([^\"]*)" com "([^\"]*)"$/ do |field, value|
27
+ When %{I fill in "#{field}" with "#{value}"}
28
+ end
29
+
30
+ Quando /^eu preencho "([^\"]*)" para "([^\"]*)"$/ do |value, field|
31
+ When %{I fill in "#{value}" for "#{field}"}
32
+ end
33
+
34
+ Quando /^eu preencho o seguinte:$/ do |fields|
35
+ When %{I fill in the following:}, fields
36
+ end
37
+
38
+ Quando /^eu seleciono "([^\"]*)" de "([^\"]*)"$/ do |value, field|
39
+ When %{I select "#{value}" from "#{field}"}
40
+ end
41
+
42
+ Quando /^eu seleciono "([^\"]*)" como a data e a hora$/ do |time|
43
+ When %{I select "#{time}" as the date and time}
44
+ end
45
+
46
+ Quando /^eu seleciono "([^\"]*)" como a data e a hora "([^\"]*)"$/ do |datetime, datetime_label|
47
+ When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
48
+ end
49
+
50
+ Quando /^eu seleciono "([^\"]*)" como a hora$/ do |time|
51
+ When %{I select "#{time}" as the time}
52
+ end
53
+
54
+ Quando /^eu seleciono "([^\"]*)" como a hora "([^\"]*)"$/ do |time, time_label|
55
+ When %{I select "#{time}" as the "#{time_label}" time}
56
+ end
57
+
58
+ Quando /^eu seleciono "([^\"]*)" como a data$/ do |date|
59
+ When %{I select "#{date}" as the date}
60
+ end
61
+
62
+ Quando /^eu seleciono "([^\"]*)" como a data "([^\"]*)"$/ do |date, date_label|
63
+ When %{I select "#{date}" as the "#{date_label}" date}
64
+ end
65
+
66
+ Quando /^eu seleciono "([^\"]*)" como "([^\"]*)"$/ do |date, date_label|
67
+ When %{I select "#{date}" as the "#{date_label}" date}
68
+ end
69
+
70
+ Quando /^eu marco "([^\"]*)"$/ do |field|
71
+ When %{I check "#{field}"}
72
+ end
73
+
74
+ Quando /^eu desmarco "([^\"]*)"$/ do |field|
75
+ When %{I uncheck "#{field}"}
76
+ end
77
+
78
+ Quando /^eu escolho "([^\"]*)"$/ do |field|
79
+ When %{I choose "#{field}"}
80
+ end
81
+
82
+ Quando /^eu anexo o arquivo em "([^\"]*)" a "([^\"]*)"$/ do |path, field|
83
+ When %{I attach the file "#{path}" to "#{field}"}
84
+ end
85
+
86
+ Então /^eu devo ver "([^\"]*)"$/ do |text|
87
+ Then %{I should see "#{text}"}
88
+ end
89
+
90
+ Então /^eu devo ver "([^\"]*)" dentro de "([^\"]*)"$/ do |text, selector|
91
+ Then %{I should see "#{text}" within "#{selector}"}
92
+ end
93
+
94
+ Então /^eu devo ver \/([^\/]*)\/$/ do |regexp|
95
+ Then %{I should see /#{regexp}/}
96
+ end
97
+
98
+ Então /^eu devo ver \/([^\/]*)\/ dentro de "([^\"]*)"$/ do |regexp, selector|
99
+ Then %{I should see /#{regexp}/ within "#{selector}"}
100
+ end
101
+
102
+ Então /^eu não devo ver "([^\"]*)"$/ do |text|
103
+ Then %{I should not see "#{text}"}
104
+ end
105
+
106
+ Então /^eu não devo ver "([^\"]*)" dentro de "([^\"]*)"$/ do |text, selector|
107
+ Then %{I should not see "#{text}" within "#{selector}"}
108
+ end
109
+
110
+ Então /^eu não devo ver \/([^\/]*)\/$/ do |regexp|
111
+ Then %{I should not see /#{regexp}/}
112
+ end
113
+
114
+ Então /^eu não devo ver \/([^\/]*)\/ dentro de "([^\"]*)"$/ do |regexp, selector|
115
+ Then %{I should not see /#{regexp}/ within "#{selector}"}
116
+ end
117
+
118
+ Então /^o campo "([^\"]*)" deve conter "([^\"]*)"$/ do |field, value|
119
+ Then %{the "#{field}" field should contain "#{value}"}
120
+ end
121
+
122
+ Então /^o campo "([^\"]*)" não deve conter "([^\"]*)"$/ do |field, value|
123
+ Then %{the "#{field}" field should not contain "#{value}"}
124
+ end
125
+
126
+ Então /^o checkbox "([^\"]*)" deve estar marcado$/ do |label|
127
+ Then %{the "#{label}" checkbox should be checked}
128
+ end
129
+
130
+ Então /^o checkbox "([^\"]*)" não deve estar marcado$/ do |label|
131
+ Then %{the "#{label}" checkbox should not be checked}
132
+ end
133
+
134
+ Então /^eu devo estar na (.+)$/ do |page_name|
135
+ Then %{I should be on #{page_name}}
136
+ end
137
+
138
+ Então /^mostre-me a página$/ do
139
+ Then %{show me the page}
140
+ end
@@ -0,0 +1,258 @@
1
+ <%= embed_file('support/edit_warning.txt') %>
2
+
3
+ require 'uri'
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+
6
+ # Commonly used webrat steps
7
+ # http://github.com/brynary/webrat
8
+
9
+ Given /^(?:|I )am on (.+)$/ do |page_name|
10
+ visit path_to(page_name)
11
+ end
12
+
13
+ When /^(?:|I )go to (.+)$/ do |page_name|
14
+ visit path_to(page_name)
15
+ end
16
+
17
+ When /^(?:|I )press "([^\"]*)"$/ do |button|
18
+ click_button(button)
19
+ end
20
+
21
+ When /^(?:|I )follow "([^\"]*)"$/ do |link|
22
+ click_link(link)
23
+ end
24
+
25
+ When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
26
+ click_link_within(parent, link)
27
+ end
28
+
29
+ When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
30
+ fill_in(field, :with => value)
31
+ end
32
+
33
+ When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
34
+ fill_in(field, :with => value)
35
+ end
36
+
37
+ # Use this to fill in an entire form with data from a table. Example:
38
+ #
39
+ # When I fill in the following:
40
+ # | Account Number | 5002 |
41
+ # | Expiry date | 2009-11-01 |
42
+ # | Note | Nice guy |
43
+ # | Wants Email? | |
44
+ #
45
+ # TODO: Add support for checkbox, select og option
46
+ # based on naming conventions.
47
+ #
48
+ When /^(?:|I )fill in the following:$/ do |fields|
49
+ fields.rows_hash.each do |name, value|
50
+ When %{I fill in "#{name}" with "#{value}"}
51
+ end
52
+ end
53
+
54
+ When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
55
+ select(value, :from => field)
56
+ end
57
+
58
+ # Use this step in conjunction with Rail's datetime_select helper. For example:
59
+ # When I select "December 25, 2008 10:00" as the date and time
60
+ When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
61
+ select_datetime(time)
62
+ end
63
+
64
+ # Use this step when using multiple datetime_select helpers on a page or
65
+ # you want to specify which datetime to select. Given the following view:
66
+ # <%%= f.label :preferred %><br />
67
+ # <%%= f.datetime_select :preferred %>
68
+ # <%%= f.label :alternative %><br />
69
+ # <%%= f.datetime_select :alternative %>
70
+ # The following steps would fill out the form:
71
+ # When I select "November 23, 2004 11:20" as the "Preferred" date and time
72
+ # And I select "November 25, 2004 10:30" as the "Alternative" date and time
73
+ When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
74
+ select_datetime(datetime, :from => datetime_label)
75
+ end
76
+
77
+ # Use this step in conjunction with Rail's time_select helper. For example:
78
+ # When I select "2:20PM" as the time
79
+ # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
80
+ # will convert the 2:20PM to 14:20 and then select it.
81
+ When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
82
+ select_time(time)
83
+ end
84
+
85
+ # Use this step when using multiple time_select helpers on a page or you want to
86
+ # specify the name of the time on the form. For example:
87
+ # When I select "7:30AM" as the "Gym" time
88
+ When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
89
+ select_time(time, :from => time_label)
90
+ end
91
+
92
+ # Use this step in conjunction with Rail's date_select helper. For example:
93
+ # When I select "February 20, 1981" as the date
94
+ When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
95
+ select_date(date)
96
+ end
97
+
98
+ # Use this step when using multiple date_select helpers on one page or
99
+ # you want to specify the name of the date on the form. For example:
100
+ # When I select "April 26, 1982" as the "Date of Birth" date
101
+ When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
102
+ select_date(date, :from => date_label)
103
+ end
104
+
105
+ When /^(?:|I )check "([^\"]*)"$/ do |field|
106
+ check(field)
107
+ end
108
+
109
+ When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
110
+ uncheck(field)
111
+ end
112
+
113
+ When /^(?:|I )choose "([^\"]*)"$/ do |field|
114
+ choose(field)
115
+ end
116
+
117
+ # Adds support for validates_attachment_content_type. Without the mime-type getting
118
+ # passed to attach_file() you will get a "Photo file is not one of the allowed file types."
119
+ # error message
120
+ When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
121
+ type = path.split(".")[1]
122
+
123
+ case type
124
+ when "jpg"
125
+ type = "image/jpg"
126
+ when "jpeg"
127
+ type = "image/jpeg"
128
+ when "png"
129
+ type = "image/png"
130
+ when "gif"
131
+ type = "image/gif"
132
+ end
133
+
134
+ attach_file(field, path, type)
135
+ end
136
+
137
+ Then /^(?:|I )should see "([^\"]*)"$/ do |text|
138
+ if defined?(Spec::Rails::Matchers)
139
+ response.should contain(text)
140
+ else
141
+ assert_contain text
142
+ end
143
+ end
144
+
145
+ Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
146
+ within(selector) do |content|
147
+ if defined?(Spec::Rails::Matchers)
148
+ content.should contain(text)
149
+ else
150
+ hc = Webrat::Matchers::HasContent.new(text)
151
+ assert hc.matches?(content), hc.failure_message
152
+ end
153
+ end
154
+ end
155
+
156
+ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
157
+ regexp = Regexp.new(regexp)
158
+ if defined?(Spec::Rails::Matchers)
159
+ response.should contain(regexp)
160
+ else
161
+ assert_match(regexp, response_body)
162
+ end
163
+ end
164
+
165
+ Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
166
+ within(selector) do |content|
167
+ regexp = Regexp.new(regexp)
168
+ if defined?(Spec::Rails::Matchers)
169
+ content.should contain(regexp)
170
+ else
171
+ assert_match(regexp, content)
172
+ end
173
+ end
174
+ end
175
+
176
+ Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
177
+ if defined?(Spec::Rails::Matchers)
178
+ response.should_not contain(text)
179
+ else
180
+ assert_not_contain(text)
181
+ end
182
+ end
183
+
184
+ Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
185
+ within(selector) do |content|
186
+ if defined?(Spec::Rails::Matchers)
187
+ content.should_not contain(text)
188
+ else
189
+ hc = Webrat::Matchers::HasContent.new(text)
190
+ assert !hc.matches?(content), hc.negative_failure_message
191
+ end
192
+ end
193
+ end
194
+
195
+ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
196
+ regexp = Regexp.new(regexp)
197
+ if defined?(Spec::Rails::Matchers)
198
+ response.should_not contain(regexp)
199
+ else
200
+ assert_not_contain(regexp)
201
+ end
202
+ end
203
+
204
+ Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
205
+ within(selector) do |content|
206
+ regexp = Regexp.new(regexp)
207
+ if defined?(Spec::Rails::Matchers)
208
+ content.should_not contain(regexp)
209
+ else
210
+ assert_no_match(regexp, content)
211
+ end
212
+ end
213
+ end
214
+
215
+ Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
216
+ if defined?(Spec::Rails::Matchers)
217
+ field_labeled(field).value.should =~ /#{value}/
218
+ else
219
+ assert_match(/#{value}/, field_labeled(field).value)
220
+ end
221
+ end
222
+
223
+ Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
224
+ if defined?(Spec::Rails::Matchers)
225
+ field_labeled(field).value.should_not =~ /#{value}/
226
+ else
227
+ assert_no_match(/#{value}/, field_labeled(field).value)
228
+ end
229
+ end
230
+
231
+ Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
232
+ if defined?(Spec::Rails::Matchers)
233
+ field_labeled(label).should be_checked
234
+ else
235
+ assert field_labeled(label).checked?
236
+ end
237
+ end
238
+
239
+ Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
240
+ if defined?(Spec::Rails::Matchers)
241
+ field_labeled(label).should_not be_checked
242
+ else
243
+ assert !field_labeled(label).checked?
244
+ end
245
+ end
246
+
247
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
248
+ current_path = URI.parse(current_url).select(:path, :query).compact.join('?')
249
+ if defined?(Spec::Rails::Matchers)
250
+ current_path.should == path_to(page_name)
251
+ else
252
+ assert_equal path_to(page_name), current_path
253
+ end
254
+ end
255
+
256
+ Then /^show me the page$/ do
257
+ save_and_open_page
258
+ end