shakespeare 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/README.md +88 -84
  2. data/Rakefile +42 -42
  3. data/app/controllers/admin/pages_controller.rb +46 -46
  4. data/app/controllers/pages_controller.rb +4 -4
  5. data/app/models/page.rb +9 -9
  6. data/app/views/admin/pages/_form.html.erb +37 -37
  7. data/app/views/admin/pages/edit.html.erb +2 -2
  8. data/app/views/admin/pages/index.html.erb +23 -23
  9. data/app/views/admin/pages/new.html.erb +2 -2
  10. data/app/views/layouts/admin.html.erb +8 -8
  11. data/app/views/pages/show.html.erb +2 -2
  12. data/config/cucumber.yml +7 -7
  13. data/config/routes.rb +7 -7
  14. data/features/admin_pages.feature +37 -37
  15. data/features/public_pages.feature +11 -11
  16. data/features/step_definitions/page_steps.rb +6 -6
  17. data/features/step_definitions/web_steps.rb +258 -258
  18. data/features/support/env.rb +55 -55
  19. data/features/support/paths.rb +32 -32
  20. data/features/support/shakespeare_env.rb +2 -2
  21. data/generators/shakespeare/USAGE +4 -4
  22. data/generators/shakespeare/shakespeare_generator.rb +7 -7
  23. data/generators/shakespeare/templates/20091230095600_create_pages.rb +25 -25
  24. data/lib/shakespeare.rb +6 -6
  25. data/lib/shakespeare/helpers.rb +15 -15
  26. data/lib/shakespeare/settings.rb +29 -29
  27. data/lib/shakespeare/shakespeare.rb +7 -7
  28. data/lib/shakespeare/view_helpers.rb +28 -28
  29. data/rerun.txt +1 -1
  30. data/shakespeare.gemspec +89 -0
  31. data/spec/blueprints.rb +8 -8
  32. data/spec/controllers/admin/pages_controller_spec.rb +34 -34
  33. data/spec/database.yml +20 -20
  34. data/spec/helpers_spec.rb +19 -19
  35. data/spec/models/page_spec.rb +27 -27
  36. data/spec/schema.rb +15 -15
  37. data/spec/shakespeare_generator_spec.rb +35 -35
  38. data/spec/shakespeare_spec.rb +2 -2
  39. data/spec/spec_helper.rb +40 -40
  40. data/spec/view_helpers_spec.rb +102 -102
  41. metadata +2 -1
@@ -1,3 +1,3 @@
1
- <h2>Edit Page</h2>
2
-
1
+ <h2>Edit Page</h2>
2
+
3
3
  <%= render 'form' %>
@@ -1,24 +1,24 @@
1
- <h2>Pages</h2>
2
-
3
- <ul>
4
- <li><%= link_to "Add a New Page", new_admin_page_path %></li>
5
- </ul>
6
-
7
- <%- if @pages.empty? -%>
8
- <p>No pages have been added yet.</p>
9
- <%- else -%>
10
- <table>
11
- <tr>
12
- <th>Title</th>
13
- <th>&nbsp;</th>
14
- </tr>
15
-
16
- <%- @pages.each do |page| -%>
17
- <tr>
18
- <td><%= page.title %> (<%= link_to "Edit", edit_admin_page_path(page) %>)</td>
19
- <td><%= link_to "Delete", admin_page_path(page), :method => :delete %></td>
20
- </tr>
21
- <%- end -%>
22
-
23
- </table>
1
+ <h2>Pages</h2>
2
+
3
+ <ul>
4
+ <li><%= link_to "Add a New Page", new_admin_page_path %></li>
5
+ </ul>
6
+
7
+ <%- if @pages.empty? -%>
8
+ <p>No pages have been added yet.</p>
9
+ <%- else -%>
10
+ <table>
11
+ <tr>
12
+ <th>Title</th>
13
+ <th>&nbsp;</th>
14
+ </tr>
15
+
16
+ <%- @pages.each do |page| -%>
17
+ <tr>
18
+ <td><%= page.title %> (<%= link_to "Edit", edit_admin_page_path(page) %>)</td>
19
+ <td><%= link_to "Delete", admin_page_path(page), :method => :delete %></td>
20
+ </tr>
21
+ <%- end -%>
22
+
23
+ </table>
24
24
  <%- end -%>
@@ -1,3 +1,3 @@
1
- <h2>Add a New Page</h2>
2
-
1
+ <h2>Add a New Page</h2>
2
+
3
3
  <%= render 'form' %>
@@ -1,9 +1,9 @@
1
- <html>
2
- <head>
3
- <title>Admin</title>
4
- </head>
5
- <body>
6
- <h1>Admin</h1>
7
- <%= yield %>
8
- </body>
1
+ <html>
2
+ <head>
3
+ <title>Admin</title>
4
+ </head>
5
+ <body>
6
+ <h1>Admin</h1>
7
+ <%= yield %>
8
+ </body>
9
9
  </html>
@@ -1,3 +1,3 @@
1
- <h2><%= @page.title %></h2>
2
-
1
+ <h2><%= @page.title %></h2>
2
+
3
3
  <%= @page.content %>
data/config/cucumber.yml CHANGED
@@ -1,7 +1,7 @@
1
- <%
2
- rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
- rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
- std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
5
- %>
6
- default: <%= std_opts %>
7
- wip: --tags @wip:3 --wip features
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %>
7
+ wip: --tags @wip:3 --wip features
data/config/routes.rb CHANGED
@@ -1,8 +1,8 @@
1
- ActionController::Routing::Routes.draw do |map|
2
-
3
- map.resources :pages
4
-
5
- map.namespace :admin do |admin|
6
- admin.resources :pages
7
- end
1
+ ActionController::Routing::Routes.draw do |map|
2
+
3
+ map.resources :pages
4
+
5
+ map.namespace :admin do |admin|
6
+ admin.resources :pages
7
+ end
8
8
  end
@@ -1,38 +1,38 @@
1
- Feature: Managing Pages
2
- In order to update the site
3
- As an admin
4
- I want to add, edit and delete pages
5
-
6
- Scenario: I'm on the admin layout
7
- When I am on the pages admin page
8
- Then I should see "Admin"
9
-
10
- Scenario: New Page
11
- Given I am on the pages admin page
12
- When I follow "Add a New Page"
13
- And I fill in "Title" with "Harry and the Hendersons"
14
- And I fill in "Keywords" with "80s, movie"
15
- And I check "No-index"
16
- And I check "No-follow"
17
- And I check "Set Canonical Tag?"
18
- And I fill in "Canonical URL" with "http://hendersons.com"
19
- And I press "Save"
20
- Then I should see "Harry and the Hendersons"
21
-
22
- Scenario: Edit Page
23
- Given a page titled "Harry and the Hendersons"
24
- And I am on the pages admin page
25
- When I follow "Edit"
26
- And I fill in "Title" with "Three Men and a Baby"
27
- And I press "Save"
28
- Then I should see "Three Men and a Baby"
29
- And I should not see "Harry and the Hendersons"
30
-
31
- Scenario: Delete Page
32
- Given a page titled "The Departed"
33
- When I am on the pages admin page
34
- Then I should see "The Departed"
35
-
36
- When I follow "Delete"
37
- Then I should not see "The Departed"
1
+ Feature: Managing Pages
2
+ In order to update the site
3
+ As an admin
4
+ I want to add, edit and delete pages
5
+
6
+ Scenario: I'm on the admin layout
7
+ When I am on the pages admin page
8
+ Then I should see "Admin"
9
+
10
+ Scenario: New Page
11
+ Given I am on the pages admin page
12
+ When I follow "Add a New Page"
13
+ And I fill in "Title" with "Harry and the Hendersons"
14
+ And I fill in "Keywords" with "80s, movie"
15
+ And I check "No-index"
16
+ And I check "No-follow"
17
+ And I check "Set Canonical Tag?"
18
+ And I fill in "Canonical URL" with "http://hendersons.com"
19
+ And I press "Save"
20
+ Then I should see "Harry and the Hendersons"
21
+
22
+ Scenario: Edit Page
23
+ Given a page titled "Harry and the Hendersons"
24
+ And I am on the pages admin page
25
+ When I follow "Edit"
26
+ And I fill in "Title" with "Three Men and a Baby"
27
+ And I press "Save"
28
+ Then I should see "Three Men and a Baby"
29
+ And I should not see "Harry and the Hendersons"
30
+
31
+ Scenario: Delete Page
32
+ Given a page titled "The Departed"
33
+ When I am on the pages admin page
34
+ Then I should see "The Departed"
35
+
36
+ When I follow "Delete"
37
+ Then I should not see "The Departed"
38
38
 
@@ -1,12 +1,12 @@
1
- Feature: Public Pages
2
- In order to find out more information
3
- As a user
4
- I want to be able to see what's on a page
5
-
6
- Scenario: A public page
7
- Given a page titled "Mr. MacAllister's Christmas"
8
- And page "Mr. MacAllister's Christmas" has content "I was Home Alone"
9
-
10
- When I am on the page for "Mr. MacAllister's Christmas"
11
-
1
+ Feature: Public Pages
2
+ In order to find out more information
3
+ As a user
4
+ I want to be able to see what's on a page
5
+
6
+ Scenario: A public page
7
+ Given a page titled "Mr. MacAllister's Christmas"
8
+ And page "Mr. MacAllister's Christmas" has content "I was Home Alone"
9
+
10
+ When I am on the page for "Mr. MacAllister's Christmas"
11
+
12
12
  Then I should see "I was Home Alone"
@@ -1,7 +1,7 @@
1
- Given /^a page titled "([^\"]*)"$/ do |title|
2
- Page.make(:title => title)
3
- end
4
-
5
- Given /^page "([^\"]*)" has content "([^\"]*)"$/ do |title, content|
6
- Page.find_by_title(title).update_attribute(:content, content)
1
+ Given /^a page titled "([^\"]*)"$/ do |title|
2
+ Page.make(:title => title)
3
+ end
4
+
5
+ Given /^page "([^\"]*)" has content "([^\"]*)"$/ do |title, content|
6
+ Page.find_by_title(title).update_attribute(:content, content)
7
7
  end
@@ -1,259 +1,259 @@
1
- # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
- # It is recommended to regenerate this file in the future when you upgrade to a
3
- # newer version of cucumber-rails. Consider adding your own code to a new file
4
- # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
- # files.
6
-
7
-
8
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
9
-
10
- # Commonly used webrat steps
11
- # http://github.com/brynary/webrat
12
-
13
- Given /^(?:|I )am on (.+)$/ do |page_name|
14
- visit path_to(page_name)
15
- end
16
-
17
- When /^(?:|I )go to (.+)$/ do |page_name|
18
- visit path_to(page_name)
19
- end
20
-
21
- When /^(?:|I )press "([^\"]*)"$/ do |button|
22
- click_button(button)
23
- end
24
-
25
- When /^(?:|I )follow "([^\"]*)"$/ do |link|
26
- click_link(link)
27
- end
28
-
29
- When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
30
- click_link_within(parent, link)
31
- end
32
-
33
- When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
34
- fill_in(field, :with => value)
35
- end
36
-
37
- When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
38
- fill_in(field, :with => value)
39
- end
40
-
41
- # Use this to fill in an entire form with data from a table. Example:
42
- #
43
- # When I fill in the following:
44
- # | Account Number | 5002 |
45
- # | Expiry date | 2009-11-01 |
46
- # | Note | Nice guy |
47
- # | Wants Email? | |
48
- #
49
- # TODO: Add support for checkbox, select og option
50
- # based on naming conventions.
51
- #
52
- When /^(?:|I )fill in the following:$/ do |fields|
53
- fields.rows_hash.each do |name, value|
54
- When %{I fill in "#{name}" with "#{value}"}
55
- end
56
- end
57
-
58
- When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
59
- select(value, :from => field)
60
- end
61
-
62
- # Use this step in conjunction with Rail's datetime_select helper. For example:
63
- # When I select "December 25, 2008 10:00" as the date and time
64
- When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
65
- select_datetime(time)
66
- end
67
-
68
- # Use this step when using multiple datetime_select helpers on a page or
69
- # you want to specify which datetime to select. Given the following view:
70
- # <%= f.label :preferred %><br />
71
- # <%= f.datetime_select :preferred %>
72
- # <%= f.label :alternative %><br />
73
- # <%= f.datetime_select :alternative %>
74
- # The following steps would fill out the form:
75
- # When I select "November 23, 2004 11:20" as the "Preferred" date and time
76
- # And I select "November 25, 2004 10:30" as the "Alternative" date and time
77
- When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
78
- select_datetime(datetime, :from => datetime_label)
79
- end
80
-
81
- # Use this step in conjunction with Rail's time_select helper. For example:
82
- # When I select "2:20PM" as the time
83
- # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
84
- # will convert the 2:20PM to 14:20 and then select it.
85
- When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
86
- select_time(time)
87
- end
88
-
89
- # Use this step when using multiple time_select helpers on a page or you want to
90
- # specify the name of the time on the form. For example:
91
- # When I select "7:30AM" as the "Gym" time
92
- When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
93
- select_time(time, :from => time_label)
94
- end
95
-
96
- # Use this step in conjunction with Rail's date_select helper. For example:
97
- # When I select "February 20, 1981" as the date
98
- When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
99
- select_date(date)
100
- end
101
-
102
- # Use this step when using multiple date_select helpers on one page or
103
- # you want to specify the name of the date on the form. For example:
104
- # When I select "April 26, 1982" as the "Date of Birth" date
105
- When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
106
- select_date(date, :from => date_label)
107
- end
108
-
109
- When /^(?:|I )check "([^\"]*)"$/ do |field|
110
- check(field)
111
- end
112
-
113
- When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
114
- uncheck(field)
115
- end
116
-
117
- When /^(?:|I )choose "([^\"]*)"$/ do |field|
118
- choose(field)
119
- end
120
-
121
- # Adds support for validates_attachment_content_type. Without the mime-type getting
122
- # passed to attach_file() you will get a "Photo file is not one of the allowed file types."
123
- # error message
124
- When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
125
- type = path.split(".")[1]
126
-
127
- case type
128
- when "jpg"
129
- type = "image/jpg"
130
- when "jpeg"
131
- type = "image/jpeg"
132
- when "png"
133
- type = "image/png"
134
- when "gif"
135
- type = "image/gif"
136
- end
137
-
138
- attach_file(field, path, type)
139
- end
140
-
141
- Then /^(?:|I )should see "([^\"]*)"$/ do |text|
142
- if defined?(Spec::Rails::Matchers)
143
- response.should contain(text)
144
- else
145
- assert_contain text
146
- end
147
- end
148
-
149
- Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
150
- within(selector) do |content|
151
- if defined?(Spec::Rails::Matchers)
152
- content.should contain(text)
153
- else
154
- assert content.include?(text)
155
- end
156
- end
157
- end
158
-
159
- Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
160
- regexp = Regexp.new(regexp)
161
- if defined?(Spec::Rails::Matchers)
162
- response.should contain(regexp)
163
- else
164
- assert_contain regexp
165
- end
166
- end
167
-
168
- Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
169
- within(selector) do |content|
170
- regexp = Regexp.new(regexp)
171
- if defined?(Spec::Rails::Matchers)
172
- content.should contain(regexp)
173
- else
174
- assert content =~ regexp
175
- end
176
- end
177
- end
178
-
179
- Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
180
- if defined?(Spec::Rails::Matchers)
181
- response.should_not contain(text)
182
- else
183
- assert_not_contain text
184
- end
185
- end
186
-
187
- Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
188
- within(selector) do |content|
189
- if defined?(Spec::Rails::Matchers)
190
- content.should_not contain(text)
191
- else
192
- assert !content.include?(text)
193
- end
194
- end
195
- end
196
-
197
- Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
198
- regexp = Regexp.new(regexp)
199
- if defined?(Spec::Rails::Matchers)
200
- response.should_not contain(regexp)
201
- else
202
- assert_not_contain regexp
203
- end
204
- end
205
-
206
- Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
207
- within(selector) do |content|
208
- regexp = Regexp.new(regexp)
209
- if defined?(Spec::Rails::Matchers)
210
- content.should_not contain(regexp)
211
- else
212
- assert content !~ regexp
213
- end
214
- end
215
- end
216
-
217
- Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
218
- if defined?(Spec::Rails::Matchers)
219
- field_labeled(field).value.should =~ /#{value}/
220
- else
221
- assert_match(/#{value}/, field_labeled(field).value)
222
- end
223
- end
224
-
225
- Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
226
- if defined?(Spec::Rails::Matchers)
227
- field_labeled(field).value.should_not =~ /#{value}/
228
- else
229
- assert_no_match(/#{value}/, field_labeled(field).value)
230
- end
231
- end
232
-
233
- Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
234
- if defined?(Spec::Rails::Matchers)
235
- field_labeled(label).should be_checked
236
- else
237
- assert field_labeled(label).checked?
238
- end
239
- end
240
-
241
- Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
242
- if defined?(Spec::Rails::Matchers)
243
- field_labeled(label).should_not be_checked
244
- else
245
- assert !field_labeled(label).checked?
246
- end
247
- end
248
-
249
- Then /^(?:|I )should be on (.+)$/ do |page_name|
250
- if defined?(Spec::Rails::Matchers)
251
- URI.parse(current_url).path.should == path_to(page_name)
252
- else
253
- assert_equal path_to(page_name), URI.parse(current_url).path
254
- end
255
- end
256
-
257
- Then /^show me the page$/ do
258
- save_and_open_page
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
9
+
10
+ # Commonly used webrat steps
11
+ # http://github.com/brynary/webrat
12
+
13
+ Given /^(?:|I )am on (.+)$/ do |page_name|
14
+ visit path_to(page_name)
15
+ end
16
+
17
+ When /^(?:|I )go to (.+)$/ do |page_name|
18
+ visit path_to(page_name)
19
+ end
20
+
21
+ When /^(?:|I )press "([^\"]*)"$/ do |button|
22
+ click_button(button)
23
+ end
24
+
25
+ When /^(?:|I )follow "([^\"]*)"$/ do |link|
26
+ click_link(link)
27
+ end
28
+
29
+ When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
30
+ click_link_within(parent, link)
31
+ end
32
+
33
+ When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
34
+ fill_in(field, :with => value)
35
+ end
36
+
37
+ When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
38
+ fill_in(field, :with => value)
39
+ end
40
+
41
+ # Use this to fill in an entire form with data from a table. Example:
42
+ #
43
+ # When I fill in the following:
44
+ # | Account Number | 5002 |
45
+ # | Expiry date | 2009-11-01 |
46
+ # | Note | Nice guy |
47
+ # | Wants Email? | |
48
+ #
49
+ # TODO: Add support for checkbox, select og option
50
+ # based on naming conventions.
51
+ #
52
+ When /^(?:|I )fill in the following:$/ do |fields|
53
+ fields.rows_hash.each do |name, value|
54
+ When %{I fill in "#{name}" with "#{value}"}
55
+ end
56
+ end
57
+
58
+ When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
59
+ select(value, :from => field)
60
+ end
61
+
62
+ # Use this step in conjunction with Rail's datetime_select helper. For example:
63
+ # When I select "December 25, 2008 10:00" as the date and time
64
+ When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
65
+ select_datetime(time)
66
+ end
67
+
68
+ # Use this step when using multiple datetime_select helpers on a page or
69
+ # you want to specify which datetime to select. Given the following view:
70
+ # <%= f.label :preferred %><br />
71
+ # <%= f.datetime_select :preferred %>
72
+ # <%= f.label :alternative %><br />
73
+ # <%= f.datetime_select :alternative %>
74
+ # The following steps would fill out the form:
75
+ # When I select "November 23, 2004 11:20" as the "Preferred" date and time
76
+ # And I select "November 25, 2004 10:30" as the "Alternative" date and time
77
+ When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
78
+ select_datetime(datetime, :from => datetime_label)
79
+ end
80
+
81
+ # Use this step in conjunction with Rail's time_select helper. For example:
82
+ # When I select "2:20PM" as the time
83
+ # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
84
+ # will convert the 2:20PM to 14:20 and then select it.
85
+ When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
86
+ select_time(time)
87
+ end
88
+
89
+ # Use this step when using multiple time_select helpers on a page or you want to
90
+ # specify the name of the time on the form. For example:
91
+ # When I select "7:30AM" as the "Gym" time
92
+ When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
93
+ select_time(time, :from => time_label)
94
+ end
95
+
96
+ # Use this step in conjunction with Rail's date_select helper. For example:
97
+ # When I select "February 20, 1981" as the date
98
+ When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
99
+ select_date(date)
100
+ end
101
+
102
+ # Use this step when using multiple date_select helpers on one page or
103
+ # you want to specify the name of the date on the form. For example:
104
+ # When I select "April 26, 1982" as the "Date of Birth" date
105
+ When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
106
+ select_date(date, :from => date_label)
107
+ end
108
+
109
+ When /^(?:|I )check "([^\"]*)"$/ do |field|
110
+ check(field)
111
+ end
112
+
113
+ When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
114
+ uncheck(field)
115
+ end
116
+
117
+ When /^(?:|I )choose "([^\"]*)"$/ do |field|
118
+ choose(field)
119
+ end
120
+
121
+ # Adds support for validates_attachment_content_type. Without the mime-type getting
122
+ # passed to attach_file() you will get a "Photo file is not one of the allowed file types."
123
+ # error message
124
+ When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
125
+ type = path.split(".")[1]
126
+
127
+ case type
128
+ when "jpg"
129
+ type = "image/jpg"
130
+ when "jpeg"
131
+ type = "image/jpeg"
132
+ when "png"
133
+ type = "image/png"
134
+ when "gif"
135
+ type = "image/gif"
136
+ end
137
+
138
+ attach_file(field, path, type)
139
+ end
140
+
141
+ Then /^(?:|I )should see "([^\"]*)"$/ do |text|
142
+ if defined?(Spec::Rails::Matchers)
143
+ response.should contain(text)
144
+ else
145
+ assert_contain text
146
+ end
147
+ end
148
+
149
+ Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
150
+ within(selector) do |content|
151
+ if defined?(Spec::Rails::Matchers)
152
+ content.should contain(text)
153
+ else
154
+ assert content.include?(text)
155
+ end
156
+ end
157
+ end
158
+
159
+ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
160
+ regexp = Regexp.new(regexp)
161
+ if defined?(Spec::Rails::Matchers)
162
+ response.should contain(regexp)
163
+ else
164
+ assert_contain regexp
165
+ end
166
+ end
167
+
168
+ Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
169
+ within(selector) do |content|
170
+ regexp = Regexp.new(regexp)
171
+ if defined?(Spec::Rails::Matchers)
172
+ content.should contain(regexp)
173
+ else
174
+ assert content =~ regexp
175
+ end
176
+ end
177
+ end
178
+
179
+ Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
180
+ if defined?(Spec::Rails::Matchers)
181
+ response.should_not contain(text)
182
+ else
183
+ assert_not_contain text
184
+ end
185
+ end
186
+
187
+ Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
188
+ within(selector) do |content|
189
+ if defined?(Spec::Rails::Matchers)
190
+ content.should_not contain(text)
191
+ else
192
+ assert !content.include?(text)
193
+ end
194
+ end
195
+ end
196
+
197
+ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
198
+ regexp = Regexp.new(regexp)
199
+ if defined?(Spec::Rails::Matchers)
200
+ response.should_not contain(regexp)
201
+ else
202
+ assert_not_contain regexp
203
+ end
204
+ end
205
+
206
+ Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
207
+ within(selector) do |content|
208
+ regexp = Regexp.new(regexp)
209
+ if defined?(Spec::Rails::Matchers)
210
+ content.should_not contain(regexp)
211
+ else
212
+ assert content !~ regexp
213
+ end
214
+ end
215
+ end
216
+
217
+ Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
218
+ if defined?(Spec::Rails::Matchers)
219
+ field_labeled(field).value.should =~ /#{value}/
220
+ else
221
+ assert_match(/#{value}/, field_labeled(field).value)
222
+ end
223
+ end
224
+
225
+ Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
226
+ if defined?(Spec::Rails::Matchers)
227
+ field_labeled(field).value.should_not =~ /#{value}/
228
+ else
229
+ assert_no_match(/#{value}/, field_labeled(field).value)
230
+ end
231
+ end
232
+
233
+ Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
234
+ if defined?(Spec::Rails::Matchers)
235
+ field_labeled(label).should be_checked
236
+ else
237
+ assert field_labeled(label).checked?
238
+ end
239
+ end
240
+
241
+ Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
242
+ if defined?(Spec::Rails::Matchers)
243
+ field_labeled(label).should_not be_checked
244
+ else
245
+ assert !field_labeled(label).checked?
246
+ end
247
+ end
248
+
249
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
250
+ if defined?(Spec::Rails::Matchers)
251
+ URI.parse(current_url).path.should == path_to(page_name)
252
+ else
253
+ assert_equal path_to(page_name), URI.parse(current_url).path
254
+ end
255
+ end
256
+
257
+ Then /^show me the page$/ do
258
+ save_and_open_page
259
259
  end