cucumber-rails 0.1.1.rc2 → 0.1.1.rc3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ == In Git
2
+
3
+ === New features
4
+ * New #tableish method to extract table-like data from a HTML page. Pure Nokogiri/CSS3/XPath. (Aslak Hellesøy)
5
+
6
+ === Bugfixes
7
+ * Webrat step "Then I should be on" should use request_uri instead of path for missing query string parameters (ZhangJinzhu)
8
+ * Added MIME type parameter to attach file step definition (Felix Flores)
9
+ * Added check when including ActiveSupport::Testing::SetupAndTeardown for older Rails versions (Jeremy Durham)
data/Rakefile CHANGED
@@ -6,10 +6,10 @@ begin
6
6
  gemspec.description = "Cucumber Generators and Runtime for Rails"
7
7
  gemspec.email = "cukes@googlegroups.com"
8
8
  gemspec.homepage = "http://cukes.info"
9
- gemspec.authors = ["Dennis Blöte", "Aslak Hellesøy"]
9
+ gemspec.authors = ["Dennis Blöte", "Aslak Hellesøy", "Rob Holland"]
10
10
  gemspec.homepage = "http://github.com/dbloete/cucumber-rails"
11
11
 
12
- gemspec.add_dependency 'cucumber', '0.4.3'
12
+ gemspec.add_dependency 'cucumber', '>= 0.4.5.rc1'
13
13
  end
14
14
  Jeweler::GemcutterTasks.new
15
15
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1.rc2
1
+ 0.1.1.rc3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cucumber-rails}
8
- s.version = "0.1.1.rc2"
8
+ s.version = "0.1.1.rc3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Dennis Bl\303\266te", "Aslak Helles\303\270y"]
12
- s.date = %q{2009-11-11}
11
+ s.authors = ["Dennis Bl\303\266te", "Aslak Helles\303\270y", "Rob Holland"]
12
+ s.date = %q{2009-12-07}
13
13
  s.description = %q{Cucumber Generators and Runtime for Rails}
14
14
  s.email = %q{cukes@googlegroups.com}
15
15
  s.extra_rdoc_files = [
@@ -17,12 +17,14 @@ Gem::Specification.new do |s|
17
17
  ]
18
18
  s.files = [
19
19
  ".gitignore",
20
+ "History.txt",
20
21
  "README.rdoc",
21
22
  "Rakefile",
22
23
  "VERSION",
23
24
  "cucumber-rails.gemspec",
24
25
  "generators/cucumber/USAGE",
25
26
  "generators/cucumber/cucumber_generator.rb",
27
+ "generators/cucumber/templates/capybara_env.rb",
26
28
  "generators/cucumber/templates/cucumber",
27
29
  "generators/cucumber/templates/cucumber.rake",
28
30
  "generators/cucumber/templates/cucumber_environment.rb",
@@ -30,36 +32,47 @@ Gem::Specification.new do |s|
30
32
  "generators/cucumber/templates/paths.rb",
31
33
  "generators/cucumber/templates/spork_env.rb",
32
34
  "generators/cucumber/templates/version_check.rb",
33
- "generators/cucumber/templates/webrat_steps/webrat_steps_de.rb",
34
- "generators/cucumber/templates/webrat_steps/webrat_steps_en.rb",
35
+ "generators/cucumber/templates/web_steps/capybara_steps.rb",
36
+ "generators/cucumber/templates/web_steps/web_steps_de.rb",
37
+ "generators/cucumber/templates/web_steps/web_steps_no.rb",
38
+ "generators/cucumber/templates/web_steps/web_steps_pt-BR.rb",
39
+ "generators/cucumber/templates/web_steps/webrat_steps.rb",
40
+ "generators/cucumber/templates/webrat_env.rb",
35
41
  "generators/feature/USAGE",
36
42
  "generators/feature/feature_generator.rb",
37
43
  "generators/feature/templates/feature.erb",
38
44
  "generators/feature/templates/steps.erb",
39
- "lib/cucumber-rails.rb",
40
45
  "lib/cucumber/rails/action_controller.rb",
41
46
  "lib/cucumber/rails/active_record.rb",
42
47
  "lib/cucumber/rails/rspec.rb",
43
48
  "lib/cucumber/rails/test_unit.rb",
44
- "lib/cucumber/rails/world.rb"
49
+ "lib/cucumber/rails/world.rb",
50
+ "lib/cucumber/web/tableish.rb",
51
+ "spec/cucumber/web/tableish_spec.rb",
52
+ "spec/spec_helper.rb",
53
+ "tasks/rspec.rake"
45
54
  ]
46
55
  s.homepage = %q{http://github.com/dbloete/cucumber-rails}
47
56
  s.rdoc_options = ["--charset=UTF-8"]
48
57
  s.require_paths = ["lib"]
49
58
  s.rubygems_version = %q{1.3.5}
50
59
  s.summary = %q{Cucumber Generators and Runtime for Rails}
60
+ s.test_files = [
61
+ "spec/cucumber/web/tableish_spec.rb",
62
+ "spec/spec_helper.rb"
63
+ ]
51
64
 
52
65
  if s.respond_to? :specification_version then
53
66
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
67
  s.specification_version = 3
55
68
 
56
69
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
- s.add_runtime_dependency(%q<cucumber>, ["= 0.4.3"])
70
+ s.add_runtime_dependency(%q<cucumber>, [">= 0.4.5.rc1"])
58
71
  else
59
- s.add_dependency(%q<cucumber>, ["= 0.4.3"])
72
+ s.add_dependency(%q<cucumber>, [">= 0.4.5.rc1"])
60
73
  end
61
74
  else
62
- s.add_dependency(%q<cucumber>, ["= 0.4.3"])
75
+ s.add_dependency(%q<cucumber>, [">= 0.4.5.rc1"])
63
76
  end
64
77
  end
65
78
 
@@ -6,6 +6,7 @@ class CucumberGenerator < Rails::Generator::Base
6
6
  DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
7
7
  Config::CONFIG['ruby_install_name'])
8
8
 
9
+ attr_accessor :driver
9
10
  attr_accessor :framework
10
11
  attr_reader :language
11
12
 
@@ -18,8 +19,11 @@ class CucumberGenerator < Rails::Generator::Base
18
19
  record do |m|
19
20
  m.directory 'features/step_definitions'
20
21
 
21
- m.template "webrat_steps/webrat_steps_#{language}.rb", 'features/step_definitions/webrat_steps.rb'
22
- m.template'cucumber_environment.rb', 'config/environments/cucumber.rb',
22
+ m.template "web_steps/#{driver}_steps.rb", 'features/step_definitions/web_steps.rb'
23
+ if language != 'en'
24
+ m.template "web_steps/web_steps_#{language}.rb", "features/step_definitions/web_steps_#{language}.rb"
25
+ end
26
+ m.template 'cucumber_environment.rb', 'config/environments/cucumber.rb',
23
27
  :assigns => { :cucumber_version => ::Cucumber::VERSION }
24
28
 
25
29
  m.gsub_file 'config/database.yml', /test:.*\n/, "test: &TEST\n"
@@ -32,6 +36,7 @@ class CucumberGenerator < Rails::Generator::Base
32
36
  m.template'spork_env.rb', 'features/support/env.rb'
33
37
  else
34
38
  m.template 'env.rb', 'features/support/env.rb'
39
+ m.template "#{driver}_env.rb", "features/support/#{driver}.rb"
35
40
  end
36
41
  m.template 'paths.rb', 'features/support/paths.rb'
37
42
  m.template 'version_check.rb', 'features/support/version_check.rb'
@@ -49,35 +54,49 @@ class CucumberGenerator < Rails::Generator::Base
49
54
  options[:framework] ||= detect_default_framework!
50
55
  end
51
56
 
57
+ def driver
58
+ options[:driver] ||= detect_current_driver! || detect_default_driver!
59
+ end
60
+
52
61
  def spork?
53
62
  options[:spork]
54
63
  end
55
64
 
56
- protected
65
+ private
57
66
 
58
- def detect_default_framework!
67
+ def first_loadable(libraries)
59
68
  require 'rubygems'
60
- rspec! || testunit!
61
- raise "I don't know what test framework you want. Use --rspec or --testunit, or gem install rspec or test-unit." unless @default_framework
62
- @default_framework
69
+ libraries.each do |library|
70
+ begin
71
+ require library[0]
72
+ return library[1]
73
+ rescue LoadError => e
74
+ puts e.inspect
75
+ end
76
+ end
77
+ return nil
63
78
  end
64
79
 
65
- def rspec!
66
- begin
67
- require 'spec'
68
- @default_framework = :rspec
69
- rescue LoadError
70
- false
80
+ def detect_current_driver!
81
+ drivers = [['capybara', :capybara], ['webrat', :webrat ]]
82
+ drivers.each do |driver|
83
+ @current_driver = driver[1] if File.exists?("features/support/#{driver[0]}.rb")
84
+ return @current_driver if @current_driver
71
85
  end
86
+ return nil
72
87
  end
73
88
 
74
- def testunit!
75
- begin
76
- require 'test/unit'
77
- @default_framework = :testunit
78
- rescue LoadError
79
- false
80
- end
89
+ def detect_default_driver!
90
+ drivers = [['capybara', :capybara], ['webrat', :webrat ]]
91
+ @default_driver = first_loadable(drivers)
92
+ raise "I don't know which driver you want. Use --capybara or --webrat, or gem install capybara or webrat." unless @default_driver
93
+ @default_driver
94
+ end
95
+
96
+ def detect_default_framework!
97
+ @default_framework = first_loadable([['spec', :rspec], ['test/unit', :testunit]])
98
+ raise "I don't know what test framework you want. Use --rspec or --testunit, or gem install rspec or test-unit." unless @default_framework
99
+ @default_framework
81
100
  end
82
101
 
83
102
  def banner
@@ -88,6 +107,22 @@ protected
88
107
  require 'cucumber/formatter/ansicolor'
89
108
  extend Cucumber::Formatter::ANSIColor
90
109
 
110
+ if @default_driver
111
+ puts <<-WARNING
112
+
113
+ #{yellow_cukes(15)}
114
+
115
+ #{yellow_cukes(1)} D R I V E R A L E R T #{yellow_cukes(1)}
116
+
117
+ You didn't explicitly generate with --capybara or --webrat, so I looked at
118
+ your gems and saw that you had #{green(@default_driver.to_s)} installed, so I went with that.
119
+ If you want something else, be specific about it. Otherwise, relax.
120
+
121
+ #{yellow_cukes(15)}
122
+
123
+ WARNING
124
+ end
125
+
91
126
  if @default_framework
92
127
  puts <<-WARNING
93
128
 
@@ -108,6 +143,14 @@ WARNING
108
143
  def add_options!(opt)
109
144
  opt.separator ''
110
145
  opt.separator 'Options:'
146
+ opt.on('--webrat', 'Setup cucumber for use with webrat') do |value|
147
+ options[:driver] = :webrat
148
+ end
149
+
150
+ opt.on('--capybara', 'Setup cucumber for use with capybara') do |value|
151
+ options[:driver] = :capybara
152
+ end
153
+
111
154
  opt.on('--rspec', "Setup cucumber for use with RSpec") do |value|
112
155
  options[:framework] = :rspec
113
156
  end
@@ -0,0 +1,24 @@
1
+ require 'capybara/rails'
2
+ require 'capybara/cucumber'
3
+ require 'cucumber/web/tableish'
4
+ World(Cucumber::Tableish)
5
+
6
+ # If you set this to true, each scenario will run in a database transaction.
7
+ # You can still turn off transactions on a per-scenario basis, simply tagging
8
+ # a feature or scenario with the @no-txn tag.
9
+ #
10
+ # If you set this to false, transactions will be off for all scenarios,
11
+ # regardless of whether you use @no-txn or not.
12
+ #
13
+ # Beware that turning transactions off will leave data in your database after
14
+ # each scenario, which can lead to hard-to-debug failures in subsequent
15
+ # scenarios. If you do this, we recommend you create a Before block that will
16
+ # explicitly put your database in a known state.
17
+ #
18
+ Cucumber::Rails::World.use_transactional_fixtures = true
19
+
20
+ # Capybara defaults to XPATH selectors rather than Webrat's default of CSS. In
21
+ # order to ease the transition to Capybara we set the default here. If you'd
22
+ # prefer to use XPATH just remove this line and adjust any selectors in your
23
+ # steps to use the XPATH syntax.
24
+ Capybara.default_selector = :css
@@ -2,7 +2,10 @@
2
2
  # Edit at your own peril - it's recommended to regenerate this file
3
3
  # in the future when you upgrade to a newer version of Cucumber.
4
4
 
5
- config.cache_classes = true # This must be true for Cucumber to operate correctly!
5
+ # IMPORTANT: Setting config.cache_classes to false is known to
6
+ # break Cucumber's use_transactional_fixtures method.
7
+ # For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165
8
+ config.cache_classes = true
6
9
 
7
10
  # Log error messages when you accidentally call methods on nil.
8
11
  config.whiny_nils = true
@@ -20,7 +23,11 @@ config.action_controller.allow_forgery_protection = false
20
23
  config.action_mailer.delivery_method = :test
21
24
 
22
25
  config.gem 'cucumber', :lib => false, :version => '>=<%= cucumber_version %>' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber'))
26
+ <% if driver == :capybara -%>
27
+ config.gem 'capybara', :lib => false, :version => '>=0.1.3' unless File.directory?(File.join(Rails.root, 'vendor/plugins/capybara'))
28
+ <% else -%>
23
29
  config.gem 'webrat', :lib => false, :version => '>=0.5.3' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
30
+ <% end -%>
24
31
  <% if framework == :rspec -%>
25
32
  config.gem 'rspec', :lib => false, :version => '>=1.2.9' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
26
33
  config.gem 'rspec-rails', :lib => false, :version => '>=1.2.9' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
@@ -8,19 +8,6 @@ ENV["RAILS_ENV"] ||= "cucumber"
8
8
  require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
9
9
  require 'cucumber/rails/world'
10
10
 
11
- # If you set this to true, each scenario will run in a database transaction.
12
- # You can still turn off transactions on a per-scenario basis, simply tagging
13
- # a feature or scenario with the @no-txn tag.
14
- #
15
- # If you set this to false, transactions will be off for all scenarios,
16
- # regardless of whether you use @no-txn or not.
17
- #
18
- # Beware that turning transactions off will leave data in your database
19
- # after each scenario, which can lead to hard-to-debug failures in
20
- # subsequent scenarios. If you do this, we recommend you create a Before
21
- # block that will explicitly put your database in a known state.
22
- Cucumber::Rails::World.use_transactional_fixtures = true
23
-
24
11
  # If you set this to false, any error raised from within your app will bubble
25
12
  # up to your step definition and out to cucumber unless you catch it somewhere
26
13
  # on the way. You can make Rails rescue errors and render error pages on a
@@ -35,15 +22,6 @@ ActionController::Base.allow_rescue = false
35
22
  require 'cucumber'
36
23
  # Comment out the next line if you don't want Cucumber Unicode support
37
24
  require 'cucumber/formatter/unicode'
38
- require 'cucumber/webrat/element_locator' # Lets you do table.diff!(element_at('#my_table_or_dl_or_ul_or_ol').to_table)
39
25
  <% if framework == :rspec -%>
40
26
  require 'cucumber/rails/rspec'
41
27
  <% end -%>
42
-
43
- require 'webrat'
44
- require 'webrat/core/matchers'
45
- Webrat.configure do |config|
46
- config.mode = :rails
47
- config.open_error_files = false # Set to true if you want error pages to pop up in the browser
48
- end
49
-
@@ -0,0 +1,247 @@
1
+ # IMPORTANT: This file was generated.
2
+ # Edit at your own peril - it's recommended to regenerate this file
3
+ # in the future when you upgrade to a newer version of Cucumber.
4
+ # Consider adding your own code to a new file instead of editing this one.
5
+
6
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
7
+
8
+ module WithinHelpers
9
+ def with_scope(locator)
10
+ within(locator || 'html') { yield }
11
+ end
12
+ end
13
+ World(WithinHelpers)
14
+
15
+ Given /^(?:|I )am on (.+)$/ do |page_name|
16
+ visit path_to(page_name)
17
+ end
18
+
19
+ When /^(?:|I )go to (.+)$/ do |page_name|
20
+ visit path_to(page_name)
21
+ end
22
+
23
+ When /^(?:|I )press "([^\"]*)"(?: within "([^\"]*)")?$/ do |button, selector|
24
+ with_scope(selector) do
25
+ click_button(button)
26
+ end
27
+ end
28
+
29
+ When /^(?:|I )follow "([^\"]*)"(?: within "([^\"]*)")?$/ do |link, selector|
30
+ with_scope(selector) do
31
+ click_link(link)
32
+ end
33
+ end
34
+
35
+ When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, value, selector|
36
+ with_scope(selector) do
37
+ fill_in(field, :with => value)
38
+ end
39
+ end
40
+
41
+ When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
42
+ with_scope(selector) do
43
+ fill_in(field, :with => value)
44
+ end
45
+ end
46
+
47
+ # Use this to fill in an entire form with data from a table. Example:
48
+ #
49
+ # When I fill in the following:
50
+ # | Account Number | 5002 |
51
+ # | Expiry date | 2009-11-01 |
52
+ # | Note | Nice guy |
53
+ # | Wants Email? | |
54
+ #
55
+ # TODO: Add support for checkbox, select og option
56
+ # based on naming conventions.
57
+ #
58
+ When /^(?:|I )fill in the following(?: within "([^\"]*)"|)?:$/ do |fields, selector|
59
+ with_scope(selector) do
60
+ fields.rows_hash.each do |name, value|
61
+ When %{I fill in "#{name}" with "#{value}"}
62
+ end
63
+ end
64
+ end
65
+
66
+ When /^(?:|I )select "([^\"]*)" from "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
67
+ with_scope(selector) do
68
+ select(value, :from => field)
69
+ end
70
+ end
71
+
72
+ # Use this step in conjunction with Rail's datetime_select helper. For example:
73
+ # When I select "December 25, 2008 10:00" as the date and time
74
+ When /^(?:|I )select "([^\"]*)" as the date and time(?: within "([^\"]*)")?$/ do |time, selector|
75
+ with_scope(selector) do
76
+ select_datetime(time)
77
+ end
78
+ end
79
+
80
+ # Use this step when using multiple datetime_select helpers on a page or
81
+ # you want to specify which datetime to select. Given the following view:
82
+ # <%%= f.label :preferred %><br />
83
+ # <%%= f.datetime_select :preferred %>
84
+ # <%%= f.label :alternative %><br />
85
+ # <%%= f.datetime_select :alternative %>
86
+ # The following steps would fill out the form:
87
+ # When I select "November 23, 2004 11:20" as the "Preferred" date and time
88
+ # And I select "November 25, 2004 10:30" as the "Alternative" date and time
89
+ When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time(?: within "([^\"]*)")?$/ do |datetime, datetime_label, selector|
90
+ with_scope(selector) do
91
+ select_datetime(datetime, :from => datetime_label)
92
+ end
93
+ end
94
+
95
+ # Use this step in conjunction with Rail's time_select helper. For example:
96
+ # When I select "2:20PM" as the time
97
+ # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
98
+ # will convert the 2:20PM to 14:20 and then select it.
99
+ When /^(?:|I )select "([^\"]*)" as the time(?: within "([^\"]*)")?$/ do |time, selector|
100
+ with_scope(selector) do
101
+ select_time(time)
102
+ end
103
+ end
104
+
105
+ # Use this step when using multiple time_select helpers on a page or you want to
106
+ # specify the name of the time on the form. For example:
107
+ # When I select "7:30AM" as the "Gym" time
108
+ When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time(?: within "([^\"]*)")?$/ do |time, time_label, selector|
109
+ with_scope(selector) do
110
+ select_time(time, :from => time_label)
111
+ end
112
+ end
113
+
114
+ # Use this step in conjunction with Rail's date_select helper. For example:
115
+ # When I select "February 20, 1981" as the date
116
+ When /^(?:|I )select "([^\"]*)" as the date(?: within "([^\"]*)")?$/ do |date, selector|
117
+ with_scope(selector) do
118
+ select_date(date)
119
+ end
120
+ end
121
+
122
+ # Use this step when using multiple date_select helpers on one page or
123
+ # you want to specify the name of the date on the form. For example:
124
+ # When I select "April 26, 1982" as the "Date of Birth" date
125
+ When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date(?: within "([^\"]*)")?$/ do |date, date_label, selector|
126
+ with_scope(selector) do
127
+ select_date(date, :from => date_label)
128
+ end
129
+ end
130
+
131
+ When /^(?:|I )check "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
132
+ with_scope(selector) do
133
+ check(field)
134
+ end
135
+ end
136
+
137
+ When /^(?:|I )uncheck "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
138
+ with_scope(selector) do
139
+ uncheck(field)
140
+ end
141
+ end
142
+
143
+ When /^(?:|I )choose "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
144
+ with_scope(selector) do
145
+ choose(field)
146
+ end
147
+ end
148
+
149
+ When /^(?:|I )attach the file at "([^\"]*)" to "([^\"]*)"(?: within "([^\"]*)")?$/ do |path, field, selector|
150
+ with_scope(selector) do
151
+ attach_file(field, path)
152
+ end
153
+ end
154
+
155
+ Then /^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
156
+ with_scope(selector) do
157
+ if defined?(Spec::Rails::Matchers)
158
+ has_content?(text).should be_true
159
+ else
160
+ assert has_content?(text)
161
+ end
162
+ end
163
+ end
164
+
165
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
166
+ regexp = Regexp.new(regexp)
167
+ with_scope(selector) do
168
+ if defined?(Spec::Rails::Matchers)
169
+ has_xpath?('//*', :text => regexp).should be_true
170
+ else
171
+ assert has_xpath('//*', :text => regexp)
172
+ end
173
+ end
174
+ end
175
+
176
+ Then /^(?:|I )should not see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
177
+ with_scope(selector) do
178
+ if defined?(Spec::Rails::Matchers)
179
+ has_content?(text).should be_false
180
+ else
181
+ assert_not has_content?(text)
182
+ end
183
+ end
184
+ end
185
+
186
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
187
+ regexp = Regexp.new(regexp)
188
+ with_scope(selector) do
189
+ if defined?(Spec::Rails::Matchers)
190
+ has_xpath?('//*', :text => regexp).should be_false
191
+ else
192
+ assert_not has_xpath?('//*', :text => regexp)
193
+ end
194
+ end
195
+ end
196
+
197
+ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/ do |field, selector, value|
198
+ with_scope(selector) do
199
+ if defined?(Spec::Rails::Matchers)
200
+ field_labeled(field).value.should =~ /#{value}/
201
+ else
202
+ assert_match(/#{value}/, field_labeled(field).value)
203
+ end
204
+ end
205
+ end
206
+
207
+ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should not contain "([^\"]*)"$/ do |field, selector, value|
208
+ with_scope(selector) do
209
+ if defined?(Spec::Rails::Matchers)
210
+ find_field(field).value.should_not =~ /#{value}/
211
+ else
212
+ assert_no_match(/#{value}/, find_field(field).value)
213
+ end
214
+ end
215
+ end
216
+
217
+ Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should be checked$/ do |label, selector|
218
+ with_scope(selector) do
219
+ if defined?(Spec::Rails::Matchers)
220
+ field_labeled(label)['checked'].should == 'checked'
221
+ else
222
+ assert field_labeled(label)['checked'] == 'checked'
223
+ end
224
+ end
225
+ end
226
+
227
+ Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should not be checked$/ do |label, selector|
228
+ with_scope(selector) do
229
+ if defined?(Spec::Rails::Matchers)
230
+ field_labeled(label)['checked'].should_not == 'checked'
231
+ else
232
+ assert field_labeled(label)['checked'] != 'checked'
233
+ end
234
+ end
235
+ end
236
+
237
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
238
+ if defined?(Spec::Rails::Matchers)
239
+ URI.parse(current_url).path.should == path_to(page_name)
240
+ else
241
+ assert_equal path_to(page_name), URI.parse(current_url).path
242
+ end
243
+ end
244
+
245
+ Then /^show me the page$/ do
246
+ save_and_open_page
247
+ end