cucumber_rails3_gen 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/LICENSE +20 -0
  2. data/README +19 -0
  3. data/README.rdoc +19 -0
  4. data/USAGE +19 -0
  5. data/VERSION +1 -0
  6. data/bin/cucumber_skeleton +19 -0
  7. data/lib/generators/cucumber/skeleton/USAGE +19 -0
  8. data/lib/generators/cucumber/skeleton/skeleton_generator.rb +178 -0
  9. data/lib/generators/cucumber/skeleton/templates/config/cucumber.yml.erb +7 -0
  10. data/lib/generators/cucumber/skeleton/templates/environments/cucumber.rb.erb +37 -0
  11. data/lib/generators/cucumber/skeleton/templates/script/cucumber +10 -0
  12. data/lib/generators/cucumber/skeleton/templates/step_definitions/capybara_steps.rb.erb +187 -0
  13. data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_cs.rb.erb +136 -0
  14. data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_da.rb.erb +114 -0
  15. data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_de.rb.erb +136 -0
  16. data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_es.rb.erb +136 -0
  17. data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_ja.rb.erb +136 -0
  18. data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_no.rb.erb +114 -0
  19. data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_pt-BR.rb.erb +140 -0
  20. data/lib/generators/cucumber/skeleton/templates/step_definitions/webrat_steps.rb.erb +258 -0
  21. data/lib/generators/cucumber/skeleton/templates/support/_rails_each_run.rb +29 -0
  22. data/lib/generators/cucumber/skeleton/templates/support/_rails_prefork.rb.erb +10 -0
  23. data/lib/generators/cucumber/skeleton/templates/support/capybara.rb +9 -0
  24. data/lib/generators/cucumber/skeleton/templates/support/edit_warning.txt +5 -0
  25. data/lib/generators/cucumber/skeleton/templates/support/paths.rb +27 -0
  26. data/lib/generators/cucumber/skeleton/templates/support/rails.rb.erb +5 -0
  27. data/lib/generators/cucumber/skeleton/templates/support/rails_spork.rb.erb +13 -0
  28. data/lib/generators/cucumber/skeleton/templates/support/webrat.rb +8 -0
  29. data/lib/generators/cucumber/skeleton/templates/tasks/cucumber.rake.erb +42 -0
  30. data/spec/cucumber_gen_spec.rb +7 -0
  31. data/spec/spec_helper.rb +9 -0
  32. metadata +95 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Kristian Mandrup
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,19 @@
1
+ Description:
2
+ Sets up Cucumber in your Rails 3 project. After running this generator you will
3
+ get a new rake task called features.
4
+
5
+ This also generates the necessary files in the features directory.
6
+
7
+ Also see the feature generator, which you can use to generate skeletons
8
+ for new features.
9
+
10
+ Examples: Generator
11
+ ./script/generate cucumber:skeleton
12
+
13
+ You can also provide a language argument for localized webrat steps:
14
+ ./script/generate cucumber de
15
+
16
+ Examples: Executable
17
+ $ cucumber_skeleton
18
+
19
+ $ cucumber_skeleton de
@@ -0,0 +1,19 @@
1
+ = Description:
2
+ Sets up Cucumber in your Rails 3 project. After running this generator you will
3
+ get a new rake task called features.
4
+
5
+ This also generates the necessary files in the features directory.
6
+
7
+ Also see the feature generator, which you can use to generate skeletons
8
+ for new features.
9
+
10
+ == Examples: Generator
11
+ ./script/generate cucumber:skeleton
12
+
13
+ You can also provide a language argument for localized webrat steps:
14
+ ./script/generate cucumber de
15
+
16
+ == Examples: Executable
17
+ $ cucumber_skeleton
18
+
19
+ $ cucumber_skeleton de
data/USAGE ADDED
@@ -0,0 +1,19 @@
1
+ Description:
2
+ Sets up Cucumber in your Rails 3 project. After running this generator you will
3
+ get a new rake task called features.
4
+
5
+ This also generates the necessary files in the features directory.
6
+
7
+ Also see the feature generator, which you can use to generate skeletons
8
+ for new features.
9
+
10
+ Examples: Generator
11
+ ./script/generate cucumber:skeleton
12
+
13
+ You can also provide a language argument for localized webrat steps:
14
+ ./script/generate cucumber de
15
+
16
+ Examples: Executable
17
+ $ cucumber_skeleton
18
+
19
+ $ cucumber_skeleton de
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,19 @@
1
+ #!/user/local/bin/ruby
2
+
3
+ begin
4
+ require 'rails/ruby_version_check'
5
+ rescue LoadError
6
+ # If people are not using gems, the load path must still
7
+ # be correct.
8
+ # TODO: Remove the begin / rescue block somehow
9
+ $:.unshift File.expand_path('../../lib', __FILE__)
10
+ $:.unshift File.expand_path('../../../activesupport/lib', __FILE__)
11
+ $:.unshift File.expand_path('../../../actionpack/lib', __FILE__)
12
+ end
13
+
14
+ Signal.trap("INT") { puts; exit }
15
+
16
+ require 'rails/generators'
17
+ require 'generators/cucumber/skeleton/skeleton_generator'
18
+
19
+ Cucumber::SkeletonGenerator.start
@@ -0,0 +1,19 @@
1
+ Description:
2
+ Sets up Cucumber in your Rails 3 project. After running this generator you will
3
+ get a new rake task called features.
4
+
5
+ This also generates the necessary files in the features directory.
6
+
7
+ Also see the feature generator, which you can use to generate skeletons
8
+ for new features.
9
+
10
+ Examples: Generator
11
+ ./script/generate cucumber:skeleton
12
+
13
+ You can also provide a language argument for localized webrat steps:
14
+ ./script/generate cucumber de
15
+
16
+ Examples: Executable
17
+ $ cucumber_skeleton
18
+
19
+ $ cucumber_skeleton de
@@ -0,0 +1,178 @@
1
+ # This generator bootstraps a Rails project for use with Cucumber
2
+ module Cucumber
3
+ class SkeletonGenerator < Rails::Generators::Base
4
+
5
+ argument :language, :type => :string, :required => false, :default => 'en'
6
+
7
+ class_option :shebang, :type => :boolean, :aliases => "--shebang", :group => :cucumber,
8
+ :desc => "Adds shebang marker to script files"
9
+
10
+ class_option :webrat, :type => :boolean, :aliases => "--webrat", :group => :cucumber,
11
+ :desc => "Use webrat"
12
+
13
+ class_option :capybara, :type => :boolean, :aliases => "--capybara", :group => :cucumber,
14
+ :desc => "Use capybara"
15
+
16
+ class_option :rspec, :type => :boolean, :aliases => "--rspec", :group => :cucumber,
17
+ :desc => "Use rspec"
18
+
19
+ class_option :testunit, :type => :boolean, :aliases => "--testunit", :group => :cucumber,
20
+ :desc => "Use testunit"
21
+
22
+ class_option :spork, :type => :boolean, :aliases => "--spork", :group => :cucumber,
23
+ :desc => "Use spork"
24
+
25
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
26
+ Config::CONFIG['ruby_install_name'])
27
+
28
+
29
+ def self.source_root
30
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
31
+ end
32
+
33
+
34
+ def initialize(*args, &block)
35
+ super
36
+ # @language = args.empty? ? 'en' : args.first
37
+ end
38
+
39
+ def my_options
40
+ @my_options ||= {}
41
+ end
42
+
43
+ def spork?
44
+ options[:spork]
45
+ end
46
+
47
+ def framework
48
+ my_options[:framework] ||= detect_current_framework || detect_default_framework
49
+ end
50
+
51
+ def driver
52
+ my_options[:driver] ||= detect_current_driver || detect_default_driver
53
+ end
54
+
55
+ # def embed_template(source, indent='')
56
+ # template = File.join(File.dirname(__FILE__), 'templates', source)
57
+ # ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
58
+ # end
59
+
60
+ def version
61
+ filename = File.dirname(__FILE__) + '/../../../../VERSION'
62
+ path = File.expand_path(filename)
63
+ IO.read(filename).chomp
64
+ end
65
+
66
+ def create_files
67
+ if File.exist?('features/step_definitions/webrat_steps.rb')
68
+ STDERR.puts "Please remove features/step_definitions/webrat_steps.rb\n" +
69
+ "See upgrading instructions for 0.2.0 in History.txt"
70
+ exit(1)
71
+ end
72
+ if File.exist?('features/support/version_check.rb')
73
+ STDERR.puts "Please remove features/support/version_check.rb\n" +
74
+ "See upgrading instructions for 0.2.0 in History.txt"
75
+ exit(1)
76
+ end
77
+
78
+ template 'config/cucumber.yml.erb', 'config/cucumber.yml'
79
+ template 'environments/cucumber.rb.erb', 'config/environments/cucumber.rb'
80
+
81
+ copy_file 'script/cucumber', 'script/cucumber'
82
+ chmod 'script/cucumber', 0755, :verbose => false, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
83
+
84
+ empty_directory 'features/step_definitions'
85
+ template "step_definitions/#{driver}_steps.rb.erb", 'features/step_definitions/web_steps.rb'
86
+ if language != 'en'
87
+ template "step_definitions/web_steps_#{language}.rb.erb", "features/step_definitions/web_steps_#{language}.rb"
88
+ end
89
+
90
+ empty_directory 'features/support'
91
+ if spork?
92
+ template 'support/rails_spork.rb.erb', 'features/support/env.rb'
93
+ else
94
+ template 'support/rails.rb.erb', 'features/support/env.rb'
95
+ end
96
+ copy_file 'support/paths.rb', 'features/support/paths.rb'
97
+
98
+ empty_directory 'lib/tasks'
99
+ template 'tasks/cucumber.rake.erb', 'lib/tasks/cucumber.rake'
100
+
101
+ gsub_file 'config/database.yml', /test:.*\n/, "test: &TEST\n"
102
+ unless File.read('config/database.yml').include? 'cucumber:'
103
+ gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *TEST"
104
+ end
105
+
106
+ end
107
+
108
+ def banner
109
+ "Usage: #{$0} cucumber (language)"
110
+ end
111
+
112
+ private
113
+ def empty_directory_with_gitkeep(destination, config = {})
114
+ empty_directory(destination, config)
115
+ create_file("#{destination}/.gitkeep") unless options[:skip_git]
116
+ end
117
+
118
+ def first_loadable(libraries)
119
+ require 'rubygems'
120
+ libraries.each do |library|
121
+ begin
122
+ require library[0]
123
+ return library[1]
124
+ rescue LoadError => ignore
125
+ end
126
+ end
127
+ return nil
128
+ end
129
+
130
+ def detect_current_driver
131
+ detect_in_env([['capybara', :capybara], ['webrat', :webrat ]])
132
+ end
133
+
134
+ def detect_default_driver
135
+ @default_driver = first_loadable([['capybara', :capybara], ['webrat', :webrat ]])
136
+ raise "I don't know which driver you want. Use --capybara or --webrat, or gem install capybara or webrat." unless @default_driver
137
+ @default_driver
138
+ end
139
+
140
+ def detect_current_framework
141
+ detect_in_env([['spec', :rspec], ['test/unit', :testunit]])
142
+ end
143
+
144
+ def detect_default_framework
145
+ @default_framework = first_loadable([['spec', :rspec], ['test/unit', :testunit]])
146
+ raise "I don't know what test framework you want. Use --rspec or --testunit, or gem install rspec or test-unit." unless @default_framework
147
+ @default_framework
148
+ end
149
+
150
+ def detect_in_env(choices)
151
+ env = File.file?("features/support/env.rb") ? IO.read("features/support/env.rb") : ''
152
+ choices.each do |choice|
153
+ detected = choice[1] if env =~ /#{choice[0]}/n
154
+ return detected if detected
155
+ end
156
+ return nil
157
+ end
158
+ end
159
+ end
160
+
161
+ module Cucumber
162
+ module Helper
163
+ class << self
164
+ attr_accessor :framework
165
+ end
166
+
167
+ def self.embed_file(source, indent='')
168
+ IO.read(File.join(File.dirname(__FILE__), 'templates', source)).gsub(/^/, indent)
169
+ end
170
+
171
+ def self.embed_template(source, indent='')
172
+ template = File.join(File.dirname(__FILE__), 'templates', source)
173
+ ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
174
+ end
175
+ end
176
+ end
177
+
178
+
@@ -0,0 +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: <%= spork? ? '--drb ' : '' %><%%= std_opts %>
7
+ wip: <%= spork? ? '--drb ' : '' %>--tags @wip:3 --wip features
@@ -0,0 +1,37 @@
1
+ # Edit at your own peril - it's recommended to regenerate this file
2
+ # in the future when you upgrade to a newer version of Cucumber.
3
+
4
+ # IMPORTANT: Setting config.cache_classes to false is known to
5
+ # break Cucumber's use_transactional_fixtures method.
6
+ # For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Disable request forgery protection in test environment
17
+ config.action_controller.allow_forgery_protection = false
18
+
19
+ # Tell Action Mailer not to deliver emails to the real world.
20
+ # The :test delivery method accumulates sent emails in the
21
+ # ActionMailer::Base.deliveries array.
22
+ config.action_mailer.delivery_method = :test
23
+
24
+ config.gem 'cucumber-rails', :lib => false, :version => '>=<%= version %>' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
25
+ config.gem 'database_cleaner', :lib => false, :version => '>=0.4.3' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))
26
+ <% if driver == :capybara -%>
27
+ config.gem 'capybara', :lib => false, :version => '>=0.3.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/capybara'))
28
+ <% else -%>
29
+ config.gem 'webrat', :lib => false, :version => '>=0.6.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
30
+ <% end -%>
31
+ <% if framework == :rspec -%>
32
+ config.gem 'rspec', :lib => false, :version => '>=1.3.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
33
+ config.gem 'rspec-rails', :lib => false, :version => '>=1.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
34
+ <% end %>
35
+ <% if spork? -%>
36
+ config.gem 'spork', :lib => false, :version => '>=0.7.5' unless File.directory?(File.join(Rails.root, 'vendor/plugins/spork'))
37
+ <% end %>
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
4
+ if vendored_cucumber_bin
5
+ load File.expand_path(vendored_cucumber_bin)
6
+ else
7
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
8
+ require 'cucumber'
9
+ load Cucumber::BINARY
10
+ end
@@ -0,0 +1,187 @@
1
+ <%= Cucumber::Helper.embed_file('support/edit_warning.txt') %>
2
+
3
+ require 'uri'
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+
6
+ module WithinHelpers
7
+ def with_scope(locator)
8
+ locator ? within(locator) { yield } : yield
9
+ end
10
+ end
11
+ World(WithinHelpers)
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 "([^\"]*)"(?: within "([^\"]*)")?$/ do |button, selector|
22
+ with_scope(selector) do
23
+ click_button(button)
24
+ end
25
+ end
26
+
27
+ When /^(?:|I )follow "([^\"]*)"(?: within "([^\"]*)")?$/ do |link, selector|
28
+ with_scope(selector) do
29
+ click_link(link)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, value, selector|
34
+ with_scope(selector) do
35
+ fill_in(field, :with => value)
36
+ end
37
+ end
38
+
39
+ When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
40
+ with_scope(selector) do
41
+ fill_in(field, :with => value)
42
+ end
43
+ end
44
+
45
+ # Use this to fill in an entire form with data from a table. Example:
46
+ #
47
+ # When I fill in the following:
48
+ # | Account Number | 5002 |
49
+ # | Expiry date | 2009-11-01 |
50
+ # | Note | Nice guy |
51
+ # | Wants Email? | |
52
+ #
53
+ # TODO: Add support for checkbox, select og option
54
+ # based on naming conventions.
55
+ #
56
+ When /^(?:|I )fill in the following(?: within "([^\"]*)")?:$/ do |selector, fields|
57
+ with_scope(selector) do
58
+ fields.rows_hash.each do |name, value|
59
+ When %{I fill in "#{name}" with "#{value}"}
60
+ end
61
+ end
62
+ end
63
+
64
+ When /^(?:|I )select "([^\"]*)" from "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
65
+ with_scope(selector) do
66
+ select(value, :from => field)
67
+ end
68
+ end
69
+
70
+ When /^(?:|I )check "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
71
+ with_scope(selector) do
72
+ check(field)
73
+ end
74
+ end
75
+
76
+ When /^(?:|I )uncheck "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
77
+ with_scope(selector) do
78
+ uncheck(field)
79
+ end
80
+ end
81
+
82
+ When /^(?:|I )choose "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
83
+ with_scope(selector) do
84
+ choose(field)
85
+ end
86
+ end
87
+
88
+ When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"(?: within "([^\"]*)")?$/ do |path, field, selector|
89
+ with_scope(selector) do
90
+ attach_file(field, path)
91
+ end
92
+ end
93
+
94
+ Then /^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
95
+ with_scope(selector) do
96
+ if defined?(Spec::Rails::Matchers)
97
+ page.should have_content(text)
98
+ else
99
+ assert page.has_content?(text)
100
+ end
101
+ end
102
+ end
103
+
104
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
105
+ regexp = Regexp.new(regexp)
106
+ with_scope(selector) do
107
+ if defined?(Spec::Rails::Matchers)
108
+ page.should have_xpath('//*', :text => regexp)
109
+ else
110
+ assert page.has_xpath?('//*', :text => regexp)
111
+ end
112
+ end
113
+ end
114
+
115
+ Then /^(?:|I )should not see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
116
+ with_scope(selector) do
117
+ if defined?(Spec::Rails::Matchers)
118
+ page.should have_no_content(text)
119
+ else
120
+ assert page.has_no_content?(text)
121
+ end
122
+ end
123
+ end
124
+
125
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
126
+ regexp = Regexp.new(regexp)
127
+ with_scope(selector) do
128
+ if defined?(Spec::Rails::Matchers)
129
+ page.should have_no_xpath('//*', :text => regexp)
130
+ else
131
+ assert page.has_no_xpath?('//*', :text => regexp)
132
+ end
133
+ end
134
+ end
135
+
136
+ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/ do |field, selector, value|
137
+ with_scope(selector) do
138
+ if defined?(Spec::Rails::Matchers)
139
+ find_field(field).value.should =~ /#{value}/
140
+ else
141
+ assert_match(/#{value}/, field_labeled(field).value)
142
+ end
143
+ end
144
+ end
145
+
146
+ Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should not contain "([^\"]*)"$/ do |field, selector, value|
147
+ with_scope(selector) do
148
+ if defined?(Spec::Rails::Matchers)
149
+ find_field(field).value.should_not =~ /#{value}/
150
+ else
151
+ assert_no_match(/#{value}/, find_field(field).value)
152
+ end
153
+ end
154
+ end
155
+
156
+ Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should be checked$/ do |label, selector|
157
+ with_scope(selector) do
158
+ if defined?(Spec::Rails::Matchers)
159
+ find_field(label)['checked'].should == 'checked'
160
+ else
161
+ assert field_labeled(label)['checked'] == 'checked'
162
+ end
163
+ end
164
+ end
165
+
166
+ Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should not be checked$/ do |label, selector|
167
+ with_scope(selector) do
168
+ if defined?(Spec::Rails::Matchers)
169
+ find_field(label)['checked'].should_not == 'checked'
170
+ else
171
+ assert field_labeled(label)['checked'] != 'checked'
172
+ end
173
+ end
174
+ end
175
+
176
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
177
+ current_path = URI.parse(current_url).select(:path, :query).compact.join('?')
178
+ if defined?(Spec::Rails::Matchers)
179
+ current_path.should == path_to(page_name)
180
+ else
181
+ assert_equal path_to(page_name), current_path
182
+ end
183
+ end
184
+
185
+ Then /^show me the page$/ do
186
+ save_and_open_page
187
+ end