email_spec 0.6.6 → 1.0.1

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 (151) hide show
  1. data/History.txt +21 -26
  2. data/README.rdoc +5 -3
  3. data/Rakefile +16 -27
  4. data/examples/rails3_root/Gemfile +17 -0
  5. data/examples/rails3_root/Gemfile.lock +138 -0
  6. data/examples/rails3_root/README +5 -0
  7. data/examples/rails3_root/Rakefile +11 -0
  8. data/examples/rails3_root/app/controllers/application_controller.rb +3 -0
  9. data/examples/rails3_root/app/controllers/welcome_controller.rb +16 -0
  10. data/examples/rails3_root/app/helpers/application_helper.rb +2 -0
  11. data/examples/rails3_root/app/mailers/user_mailer.rb +39 -0
  12. data/examples/{rails_root → rails3_root}/app/models/user.rb +0 -0
  13. data/examples/{rails_root/app/views/user_mailer/attachments.erb → rails3_root/app/views/user_mailer/attachments.html.erb} +0 -0
  14. data/examples/{rails_root/app/views/user_mailer/newsletter.erb → rails3_root/app/views/user_mailer/newsletter.html.erb} +0 -0
  15. data/examples/{rails_root/app/views/user_mailer/signup.erb → rails3_root/app/views/user_mailer/signup.html.erb} +1 -0
  16. data/examples/rails3_root/app/views/user_mailer/signup.text.erb +4 -0
  17. data/examples/{rails_root → rails3_root}/app/views/welcome/attachments.html.erb +0 -0
  18. data/examples/{rails_root → rails3_root}/app/views/welcome/confirm.html.erb +0 -0
  19. data/examples/{rails_root → rails3_root}/app/views/welcome/index.html.erb +1 -1
  20. data/examples/{rails_root → rails3_root}/app/views/welcome/newsletter.html.erb +0 -0
  21. data/examples/{rails_root → rails3_root}/app/views/welcome/signup.html.erb +0 -0
  22. data/examples/{rails_root → rails3_root}/attachments/document.pdf +0 -0
  23. data/examples/{rails_root → rails3_root}/attachments/image.png +0 -0
  24. data/examples/rails3_root/config.ru +4 -0
  25. data/examples/rails3_root/config/application.rb +43 -0
  26. data/examples/rails3_root/config/boot.rb +14 -0
  27. data/examples/rails3_root/config/cucumber.yml +8 -0
  28. data/examples/{rails_root → rails3_root}/config/database.yml +0 -0
  29. data/examples/rails3_root/config/environment.rb +6 -0
  30. data/examples/rails3_root/config/environments/development.rb +20 -0
  31. data/examples/rails3_root/config/environments/production.rb +42 -0
  32. data/examples/rails3_root/config/environments/test.rb +30 -0
  33. data/examples/rails3_root/config/initializers/backtrace_silencers.rb +7 -0
  34. data/examples/rails3_root/config/initializers/cookie_verification_secret.rb +7 -0
  35. data/examples/rails3_root/config/initializers/delayed_job.rb +1 -0
  36. data/examples/{rails_root → rails3_root}/config/initializers/inflections.rb +0 -0
  37. data/examples/{rails_root → rails3_root}/config/initializers/mime_types.rb +0 -0
  38. data/examples/rails3_root/config/initializers/notifier_job.rb +1 -0
  39. data/examples/rails3_root/config/initializers/rspec_generator.rb +6 -0
  40. data/examples/rails3_root/config/initializers/session_store.rb +10 -0
  41. data/examples/rails3_root/config/locales/en.yml +5 -0
  42. data/examples/rails3_root/config/routes.rb +7 -0
  43. data/examples/{rails_root → rails3_root}/db/migrate/20090125013728_create_users.rb +0 -0
  44. data/examples/{rails_root → rails3_root}/db/migrate/20090908054656_create_delayed_jobs.rb +0 -0
  45. data/examples/{rails_root → rails3_root}/db/schema.rb +7 -6
  46. data/examples/rails3_root/db/seeds.rb +7 -0
  47. data/examples/rails3_root/doc/README_FOR_APP +2 -0
  48. data/examples/{rails_root → rails3_root}/features/attachments.feature +0 -0
  49. data/examples/{rails_root → rails3_root}/features/delayed_job.feature +0 -0
  50. data/examples/{rails_root → rails3_root}/features/errors.feature +0 -0
  51. data/examples/{sinatra → rails3_root}/features/example.feature +9 -0
  52. data/examples/{rails_root → rails3_root}/features/step_definitions/user_steps.rb +2 -2
  53. data/examples/rails3_root/features/step_definitions/web_steps.rb +219 -0
  54. data/examples/{rails_root → rails3_root}/features/support/env.rb +10 -10
  55. data/examples/rails3_root/features/support/env_ext.rb +2 -0
  56. data/examples/{rails_root → rails3_root}/features/support/paths.rb +2 -2
  57. data/examples/rails3_root/lib/notifier_job.rb +5 -0
  58. data/examples/{rails_root → rails3_root}/lib/tasks/cucumber.rake +6 -0
  59. data/examples/rails3_root/lib/tasks/rspec.rake +69 -0
  60. data/examples/rails3_root/public/404.html +26 -0
  61. data/examples/rails3_root/public/422.html +26 -0
  62. data/examples/rails3_root/public/500.html +26 -0
  63. data/examples/{rails_root → rails3_root}/public/favicon.ico +0 -0
  64. data/examples/{rails_root → rails3_root}/public/images/rails.png +0 -0
  65. data/examples/{rails_root → rails3_root}/public/javascripts/application.js +0 -0
  66. data/examples/{rails_root → rails3_root}/public/javascripts/controls.js +5 -3
  67. data/examples/{rails_root → rails3_root}/public/javascripts/dragdrop.js +7 -6
  68. data/examples/{rails_root → rails3_root}/public/javascripts/effects.js +8 -13
  69. data/examples/{rails_root → rails3_root}/public/javascripts/prototype.js +1573 -1019
  70. data/examples/rails3_root/public/javascripts/rails.js +109 -0
  71. data/examples/{rails_root → rails3_root}/public/robots.txt +0 -0
  72. data/examples/{rails_root → rails3_root}/script/cucumber +0 -0
  73. data/examples/rails3_root/script/rails +9 -0
  74. data/examples/rails3_root/spec/controllers/welcome_controller_spec.rb +20 -0
  75. data/examples/{rails_root → rails3_root}/spec/models/user_mailer_spec.rb +7 -18
  76. data/examples/rails3_root/spec/spec_helper.rb +19 -0
  77. data/examples/sinatra_root/config.ru +4 -0
  78. data/examples/{sinatra → sinatra_root}/features/errors.feature +0 -0
  79. data/examples/{rails_root → sinatra_root}/features/example.feature +0 -0
  80. data/examples/{sinatra → sinatra_root}/features/step_definitions/user_steps.rb +2 -2
  81. data/examples/sinatra_root/features/step_definitions/web_steps.rb +219 -0
  82. data/examples/sinatra_root/features/support/env.rb +21 -0
  83. data/examples/{sinatra → sinatra_root}/features/support/paths.rb +9 -4
  84. data/examples/sinatra_root/lib/example_sinatra_app.rb +35 -0
  85. data/lib/email_spec.rb +2 -2
  86. data/lib/email_spec/deliveries.rb +7 -11
  87. data/lib/email_spec/email_viewer.rb +1 -1
  88. data/lib/email_spec/helpers.rb +7 -7
  89. data/lib/email_spec/mail_ext.rb +11 -0
  90. data/lib/email_spec/matchers.rb +31 -26
  91. data/lib/generators/email_spec/steps/USAGE +5 -0
  92. data/lib/generators/email_spec/steps/steps_generator.rb +14 -0
  93. data/{examples/rails3_root/features/step_definitions → lib/generators/email_spec/steps/templates}/email_steps.rb +0 -0
  94. data/spec/email_spec/helpers_spec.rb +4 -6
  95. data/spec/email_spec/mail_ext_spec.rb +34 -0
  96. data/spec/email_spec/matchers_spec.rb +227 -37
  97. data/spec/spec_helper.rb +14 -2
  98. metadata +174 -207
  99. data/examples/rails_root/Rakefile +0 -13
  100. data/examples/rails_root/app/controllers/application_controller.rb +0 -15
  101. data/examples/rails_root/app/controllers/welcome_controller.rb +0 -16
  102. data/examples/rails_root/app/helpers/application_helper.rb +0 -3
  103. data/examples/rails_root/app/helpers/welcome_helper.rb +0 -2
  104. data/examples/rails_root/app/models/user_mailer.rb +0 -39
  105. data/examples/rails_root/config/boot.rb +0 -110
  106. data/examples/rails_root/config/cucumber.yml +0 -7
  107. data/examples/rails_root/config/environment.rb +0 -28
  108. data/examples/rails_root/config/environments/cucumber.rb +0 -29
  109. data/examples/rails_root/config/environments/development.rb +0 -17
  110. data/examples/rails_root/config/environments/production.rb +0 -28
  111. data/examples/rails_root/config/environments/test.rb +0 -28
  112. data/examples/rails_root/config/initializers/new_rails_defaults.rb +0 -17
  113. data/examples/rails_root/config/routes.rb +0 -45
  114. data/examples/rails_root/doc/README_FOR_APP +0 -5
  115. data/examples/rails_root/features/step_definitions/web_steps.rb +0 -273
  116. data/examples/rails_root/features/support/env_ext.rb +0 -6
  117. data/examples/rails_root/public/404.html +0 -30
  118. data/examples/rails_root/public/422.html +0 -30
  119. data/examples/rails_root/public/500.html +0 -33
  120. data/examples/rails_root/public/dispatch.rb +0 -10
  121. data/examples/rails_root/script/about +0 -4
  122. data/examples/rails_root/script/autospec +0 -5
  123. data/examples/rails_root/script/console +0 -3
  124. data/examples/rails_root/script/dbconsole +0 -3
  125. data/examples/rails_root/script/delayed_job +0 -5
  126. data/examples/rails_root/script/destroy +0 -3
  127. data/examples/rails_root/script/generate +0 -3
  128. data/examples/rails_root/script/performance/benchmarker +0 -3
  129. data/examples/rails_root/script/performance/profiler +0 -3
  130. data/examples/rails_root/script/performance/request +0 -3
  131. data/examples/rails_root/script/plugin +0 -3
  132. data/examples/rails_root/script/process/inspector +0 -3
  133. data/examples/rails_root/script/process/reaper +0 -3
  134. data/examples/rails_root/script/process/spawner +0 -3
  135. data/examples/rails_root/script/runner +0 -3
  136. data/examples/rails_root/script/server +0 -3
  137. data/examples/rails_root/script/spec +0 -5
  138. data/examples/rails_root/script/spec_server +0 -125
  139. data/examples/rails_root/spec/controllers/welcome_controller_spec.rb +0 -15
  140. data/examples/rails_root/spec/model_factory.rb +0 -6
  141. data/examples/rails_root/spec/models/user_spec.rb +0 -5
  142. data/examples/rails_root/spec/rcov.opts +0 -2
  143. data/examples/rails_root/spec/spec.opts +0 -4
  144. data/examples/rails_root/spec/spec_helper.rb +0 -51
  145. data/examples/sinatra/app.rb +0 -33
  146. data/examples/sinatra/features/step_definitions/email_steps.rb +0 -182
  147. data/examples/sinatra/features/step_definitions/web_steps.rb +0 -273
  148. data/examples/sinatra/features/support/env.rb +0 -39
  149. data/examples/sinatra_root/features/step_definitions/email_steps.rb +0 -194
  150. data/lib/email_spec/#helpers.rb# +0 -168
  151. data/spec/spec.opts +0 -4
@@ -1,182 +0,0 @@
1
- # Commonly used email steps
2
- #
3
- # To add your own steps make a custom_email_steps.rb
4
- # The provided methods are:
5
- #
6
- # last_email_address
7
- # reset_mailer
8
- # open_last_email
9
- # visit_in_email
10
- # unread_emails_for
11
- # mailbox_for
12
- # current_email
13
- # open_email
14
- # read_emails_for
15
- # find_email
16
- #
17
- # General form for email scenarios are:
18
- # - clear the email queue (done automatically by email_spec)
19
- # - execute steps that sends an email
20
- # - check the user received an/no/[0-9] emails
21
- # - open the email
22
- # - inspect the email contents
23
- # - interact with the email (e.g. click links)
24
- #
25
- # The Cucumber steps below are setup in this order.
26
-
27
- module EmailHelpers
28
- def current_email_address
29
- # Replace with your a way to find your current email. e.g @current_user.email
30
- # last_email_address will return the last email address used by email spec to find an email.
31
- # Note that last_email_address will be reset after each Scenario.
32
- last_email_address || "example@example.com"
33
- end
34
- end
35
-
36
- World(EmailHelpers)
37
-
38
- #
39
- # Reset the e-mail queue within a scenario.
40
- # This is done automatically before each scenario.
41
- #
42
-
43
- Given /^(?:a clear email queue|no emails have been sent)$/ do
44
- reset_mailer
45
- end
46
-
47
- #
48
- # Check how many emails have been sent/received
49
- #
50
-
51
- Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
52
- unread_emails_for(address).size.should == parse_email_count(amount)
53
- end
54
-
55
- Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
56
- mailbox_for(address).size.should == parse_email_count(amount)
57
- end
58
-
59
- Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
60
- unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
61
- end
62
-
63
- Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
64
- open_email(address, :with_text => expected_body)
65
- end
66
-
67
- #
68
- # Accessing emails
69
- #
70
-
71
- # Opens the most recently received email
72
- When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
73
- open_email(address)
74
- end
75
-
76
- When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
77
- open_email(address, :with_subject => subject)
78
- end
79
-
80
- When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
81
- open_email(address, :with_text => text)
82
- end
83
-
84
- #
85
- # Inspect the Email Contents
86
- #
87
-
88
- Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
89
- current_email.should have_subject(text)
90
- end
91
-
92
- Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
93
- current_email.should have_subject(Regexp.new(text))
94
- end
95
-
96
- Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
97
- current_email.body.should include(text)
98
- end
99
-
100
- Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
101
- current_email.body.should =~ Regexp.new(text)
102
- end
103
-
104
- Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
105
- current_email.should be_delivered_from(text)
106
- end
107
-
108
- Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
109
- current_email.should have_header(name, text)
110
- end
111
-
112
- Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
113
- current_email.should have_header(name, Regexp.new(text))
114
- end
115
-
116
- #
117
- # Inspect the Email Attachments
118
- #
119
-
120
- Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
121
- current_email_attachments.size.should == parse_email_count(amount)
122
- end
123
-
124
- Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
125
- current_email_attachments.select { |a| a.original_filename == filename }.size.should == parse_email_count(amount)
126
- end
127
-
128
- Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
129
- current_email_attachments[(index.to_i - 1)].original_filename.should == filename
130
- end
131
-
132
- Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
133
- current_email_attachments.select { |a| a.content_type == content_type }.size.should == parse_email_count(amount)
134
- end
135
-
136
- Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
137
- current_email_attachments[(index.to_i - 1)].content_type.should == content_type
138
- end
139
-
140
- Then /^all attachments should not be blank$/ do
141
- current_email_attachments.each do |attachment|
142
- attachment.size.should_not == 0
143
- end
144
- end
145
-
146
- Then /^show me a list of email attachments$/ do
147
- EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
148
- end
149
-
150
- #
151
- # Interact with Email Contents
152
- #
153
-
154
- When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
155
- visit_in_email(link)
156
- end
157
-
158
- When /^(?:I|they) click the first link in the email$/ do
159
- click_first_link_in_email
160
- end
161
-
162
- #
163
- # Debugging
164
- # These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
165
- # Patches accepted. ;)
166
- #
167
-
168
- Then /^save and open current email$/ do
169
- EmailSpec::EmailViewer::save_and_open_email(current_email)
170
- end
171
-
172
- Then /^save and open all text emails$/ do
173
- EmailSpec::EmailViewer::save_and_open_all_text_emails
174
- end
175
-
176
- Then /^save and open all html emails$/ do
177
- EmailSpec::EmailViewer::save_and_open_all_html_emails
178
- end
179
-
180
- Then /^save and open all raw emails$/ do
181
- EmailSpec::EmailViewer::save_and_open_all_raw_emails
182
- end
@@ -1,273 +0,0 @@
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 'uri'
9
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
10
-
11
- # Commonly used webrat steps
12
- # http://github.com/brynary/webrat
13
-
14
- Given /^(?:|I )am on (.+)$/ do |page_name|
15
- visit path_to(page_name)
16
- end
17
-
18
- When /^(?:|I )go to (.+)$/ do |page_name|
19
- visit path_to(page_name)
20
- end
21
-
22
- When /^(?:|I )press "([^\"]*)"$/ do |button|
23
- click_button(button)
24
- end
25
-
26
- When /^(?:|I )follow "([^\"]*)"$/ do |link|
27
- click_link(link)
28
- end
29
-
30
- When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
31
- click_link_within(parent, link)
32
- end
33
-
34
- When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
35
- fill_in(field, :with => value)
36
- end
37
-
38
- When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
39
- fill_in(field, :with => value)
40
- end
41
-
42
- # Use this to fill in an entire form with data from a table. Example:
43
- #
44
- # When I fill in the following:
45
- # | Account Number | 5002 |
46
- # | Expiry date | 2009-11-01 |
47
- # | Note | Nice guy |
48
- # | Wants Email? | |
49
- #
50
- # TODO: Add support for checkbox, select og option
51
- # based on naming conventions.
52
- #
53
- When /^(?:|I )fill in the following:$/ do |fields|
54
- fields.rows_hash.each do |name, value|
55
- When %{I fill in "#{name}" with "#{value}"}
56
- end
57
- end
58
-
59
- When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
60
- select(value, :from => field)
61
- end
62
-
63
- # Use this step in conjunction with Rail's datetime_select helper. For example:
64
- # When I select "December 25, 2008 10:00" as the date and time
65
- When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
66
- select_datetime(time)
67
- end
68
-
69
- # Use this step when using multiple datetime_select helpers on a page or
70
- # you want to specify which datetime to select. Given the following view:
71
- # <%= f.label :preferred %><br />
72
- # <%= f.datetime_select :preferred %>
73
- # <%= f.label :alternative %><br />
74
- # <%= f.datetime_select :alternative %>
75
- # The following steps would fill out the form:
76
- # When I select "November 23, 2004 11:20" as the "Preferred" date and time
77
- # And I select "November 25, 2004 10:30" as the "Alternative" date and time
78
- When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
79
- select_datetime(datetime, :from => datetime_label)
80
- end
81
-
82
- # Use this step in conjunction with Rail's time_select helper. For example:
83
- # When I select "2:20PM" as the time
84
- # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
85
- # will convert the 2:20PM to 14:20 and then select it.
86
- When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
87
- select_time(time)
88
- end
89
-
90
- # Use this step when using multiple time_select helpers on a page or you want to
91
- # specify the name of the time on the form. For example:
92
- # When I select "7:30AM" as the "Gym" time
93
- When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
94
- select_time(time, :from => time_label)
95
- end
96
-
97
- # Use this step in conjunction with Rail's date_select helper. For example:
98
- # When I select "February 20, 1981" as the date
99
- When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
100
- select_date(date)
101
- end
102
-
103
- # Use this step when using multiple date_select helpers on one page or
104
- # you want to specify the name of the date on the form. For example:
105
- # When I select "April 26, 1982" as the "Date of Birth" date
106
- When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
107
- select_date(date, :from => date_label)
108
- end
109
-
110
- When /^(?:|I )check "([^\"]*)"$/ do |field|
111
- check(field)
112
- end
113
-
114
- When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
115
- uncheck(field)
116
- end
117
-
118
- When /^(?:|I )choose "([^\"]*)"$/ do |field|
119
- choose(field)
120
- end
121
-
122
- # Adds support for validates_attachment_content_type. Without the mime-type getting
123
- # passed to attach_file() you will get a "Photo file is not one of the allowed file types."
124
- # error message
125
- When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
126
- type = path.split(".")[1]
127
-
128
- case type
129
- when "jpg"
130
- type = "image/jpg"
131
- when "jpeg"
132
- type = "image/jpeg"
133
- when "png"
134
- type = "image/png"
135
- when "gif"
136
- type = "image/gif"
137
- end
138
-
139
- attach_file(field, path, type)
140
- end
141
-
142
- Then /^(?:|I )should see "([^\"]*)"$/ do |text|
143
- if defined?(Spec::Rails::Matchers)
144
- response.should contain(text)
145
- else
146
- assert_contain text
147
- end
148
- end
149
-
150
- Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
151
- within(selector) do |content|
152
- if defined?(Spec::Rails::Matchers)
153
- content.should contain(text)
154
- else
155
- hc = Webrat::Matchers::HasContent.new(text)
156
- assert hc.matches?(content), hc.failure_message
157
- end
158
- end
159
- end
160
-
161
- Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
162
- regexp = Regexp.new(regexp)
163
- if defined?(Spec::Rails::Matchers)
164
- response.should contain(regexp)
165
- else
166
- assert_match(regexp, response_body)
167
- end
168
- end
169
-
170
- Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
171
- within(selector) do |content|
172
- regexp = Regexp.new(regexp)
173
- if defined?(Spec::Rails::Matchers)
174
- content.should contain(regexp)
175
- else
176
- assert_match(regexp, content)
177
- end
178
- end
179
- end
180
-
181
- Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
182
- if defined?(Spec::Rails::Matchers)
183
- response.should_not contain(text)
184
- else
185
- assert_not_contain(text)
186
- end
187
- end
188
-
189
- Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
190
- within(selector) do |content|
191
- if defined?(Spec::Rails::Matchers)
192
- content.should_not contain(text)
193
- else
194
- hc = Webrat::Matchers::HasContent.new(text)
195
- assert !hc.matches?(content), hc.negative_failure_message
196
- end
197
- end
198
- end
199
-
200
- Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
201
- regexp = Regexp.new(regexp)
202
- if defined?(Spec::Rails::Matchers)
203
- response.should_not contain(regexp)
204
- else
205
- assert_not_contain(regexp)
206
- end
207
- end
208
-
209
- Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
210
- within(selector) do |content|
211
- regexp = Regexp.new(regexp)
212
- if defined?(Spec::Rails::Matchers)
213
- content.should_not contain(regexp)
214
- else
215
- assert_no_match(regexp, content)
216
- end
217
- end
218
- end
219
-
220
- Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
221
- if defined?(Spec::Rails::Matchers)
222
- field_labeled(field).value.should =~ /#{value}/
223
- else
224
- assert_match(/#{value}/, field_labeled(field).value)
225
- end
226
- end
227
-
228
- Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
229
- if defined?(Spec::Rails::Matchers)
230
- field_labeled(field).value.should_not =~ /#{value}/
231
- else
232
- assert_no_match(/#{value}/, field_labeled(field).value)
233
- end
234
- end
235
-
236
- Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
237
- if defined?(Spec::Rails::Matchers)
238
- field_labeled(label).should be_checked
239
- else
240
- assert field_labeled(label).checked?
241
- end
242
- end
243
-
244
- Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
245
- if defined?(Spec::Rails::Matchers)
246
- field_labeled(label).should_not be_checked
247
- else
248
- assert !field_labeled(label).checked?
249
- end
250
- end
251
-
252
- Then /^(?:|I )should be on (.+)$/ do |page_name|
253
- if defined?(Spec::Rails::Matchers)
254
- URI.parse(current_url).path.should == path_to(page_name)
255
- else
256
- assert_equal path_to(page_name), URI.parse(current_url).path
257
- end
258
- end
259
-
260
- Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
261
- actual_params = CGI.parse(URI.parse(current_url).query)
262
- expected_params = Hash[expected_pairs.rows_hash.map{|k,v| [k,[v]]}]
263
-
264
- if defined?(Spec::Rails::Matchers)
265
- actual_params.should == expected_params
266
- else
267
- assert_equal expected_params, actual_params
268
- end
269
- end
270
-
271
- Then /^show me the page$/ do
272
- save_and_open_page
273
- end