cucumber-rails 1.0.6 → 1.1.0
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.
- data/Gemfile.lock +4 -4
- data/History.md +42 -0
- data/cucumber-rails.gemspec +2 -2
- data/features/allow_rescue.feature +1 -2
- data/features/capybara_javascript_drivers.feature +14 -0
- data/features/install_cucumber_rails.feature +0 -3
- data/features/mongoid.feature +6 -0
- data/features/multiple_databases.feature +0 -1
- data/features/step_definitions/cucumber_rails_steps.rb +293 -0
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +10 -15
- data/lib/generators/cucumber/install/install_generator.rb +0 -22
- metadata +50 -59
- data/features/named_selectors.feature +0 -33
- data/features/pseudo_class_selectors.feature +0 -24
- data/features/select_dates.feature +0 -141
- data/lib/generators/cucumber/install/templates/support/paths.rb +0 -33
- data/lib/generators/cucumber/install/templates/support/selectors.rb +0 -39
- data/lib/generators/cucumber/install/templates/support/web_steps_warning.txt +0 -19
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
cucumber-rails (1.0
|
|
4
|
+
cucumber-rails (1.1.0)
|
|
5
5
|
capybara (>= 1.1.1)
|
|
6
|
-
cucumber (>= 1.0
|
|
6
|
+
cucumber (>= 1.1.0)
|
|
7
7
|
nokogiri (>= 1.5.0)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
@@ -97,7 +97,7 @@ GEM
|
|
|
97
97
|
bson (>= 1.3.1)
|
|
98
98
|
mongoid (2.2.1)
|
|
99
99
|
activemodel (~> 3.0)
|
|
100
|
-
mongo (
|
|
100
|
+
mongo (>= 1.3, < 1.4)
|
|
101
101
|
tzinfo (~> 0.3.22)
|
|
102
102
|
multi_json (1.0.3)
|
|
103
103
|
nokogiri (1.5.0)
|
|
@@ -152,7 +152,7 @@ GEM
|
|
|
152
152
|
sprockets (2.0.0)
|
|
153
153
|
hike (~> 1.2)
|
|
154
154
|
rack (~> 1.0)
|
|
155
|
-
tilt (
|
|
155
|
+
tilt (~> 1.1, != 1.3.0)
|
|
156
156
|
sqlite3 (1.3.4)
|
|
157
157
|
term-ansicolor (1.0.6)
|
|
158
158
|
thor (0.14.6)
|
data/History.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
+
## [v1.1.0](https://github.com/cucumber/cucumber-rails/compare/v1.0.6...v1.1.0)
|
|
2
|
+
|
|
3
|
+
### Removed features
|
|
4
|
+
|
|
5
|
+
The following files will no longer be generated if you are running `rails generate cucumber:install`:
|
|
6
|
+
|
|
7
|
+
* features/step_definitions/web_steps.rb
|
|
8
|
+
* features/support/paths.rb
|
|
9
|
+
* features/support/selectors.rb
|
|
10
|
+
|
|
11
|
+
The reason behind this is that the steps defined in `web_steps.rb` leads people to write scenarios of a
|
|
12
|
+
very imperative nature that are hard to read and hard to maintain. Cucumber scenarios should not be a series
|
|
13
|
+
of steps that describe what a user clicks. Instead, they should express what a user *does*. Example:
|
|
14
|
+
|
|
15
|
+
Given I have signed up as "user@host.com"
|
|
16
|
+
|
|
17
|
+
with a Step Definition that perhaps looks like this:
|
|
18
|
+
|
|
19
|
+
Given /^I have signed up as "([^"]*)"$/ do |email|
|
|
20
|
+
visit(signup_path)
|
|
21
|
+
fill_in('Email', :with => email)
|
|
22
|
+
fill_in('Email', :with => email)
|
|
23
|
+
fill_in('Password', :with => 's3cr3t')
|
|
24
|
+
fill_in('Password Confirmation', :with => 's3cr3t')
|
|
25
|
+
click_button('Sign up')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Moving user interface details from the scenarios and down to the step definitions makes scenarios
|
|
29
|
+
much easier to read. If you change the user interface you only have to change a step definition or two
|
|
30
|
+
instead of a lot of scenarios that explicitly describe how to sign up.
|
|
31
|
+
|
|
32
|
+
You can learn more about the reasoning behind this change at the following links:
|
|
33
|
+
|
|
34
|
+
* [Cucumber mailing list: Removing web_steps.rb in Cucumber 1.1.0](http://groups.google.com/group/cukes/browse_thread/thread/26f80b93c94f2952)
|
|
35
|
+
* [Cucumber-Rails issue #174: Remove web_steps.rb since it encourages people to write poor tests.](https://github.com/cucumber/cucumber-rails/issues/174)
|
|
36
|
+
* [Refuctoring your Cukes by Matt Wynne](http://skillsmatter.com/podcast/home/refuctoring-your-cukes)
|
|
37
|
+
* [Imperative vs Declarative Scenarios in User Stories by Ben Mabey](http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html)
|
|
38
|
+
* [Whose domain is it anyway? by Dan North](http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/)
|
|
39
|
+
* [You're Cuking it Wrong by Jonas Nicklas](http://elabs.se/blog/15-you-re-cuking-it-wrong)
|
|
40
|
+
|
|
41
|
+
You can learn more about what Capybara has to offer in Capybara's [README](https://github.com/jnicklas/capybara).
|
|
42
|
+
|
|
1
43
|
## [v1.0.6](https://github.com/cucumber/cucumber-rails/compare/v1.0.5...v1.0.6)
|
|
2
44
|
|
|
3
45
|
### Bugfixes
|
data/cucumber-rails.gemspec
CHANGED
|
@@ -3,14 +3,14 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = 'cucumber-rails'
|
|
6
|
-
s.version = '1.0
|
|
6
|
+
s.version = '1.1.0'
|
|
7
7
|
s.authors = ["Aslak Hellesøy", "Dennis Blöte", "Rob Holland"]
|
|
8
8
|
s.description = "Cucumber Generators and Runtime for Rails"
|
|
9
9
|
s.summary = "#{s.name}-#{s.version}"
|
|
10
10
|
s.email = 'cukes@googlegroups.com'
|
|
11
11
|
s.homepage = "http://cukes.info"
|
|
12
12
|
|
|
13
|
-
s.add_runtime_dependency('cucumber', '>= 1.0
|
|
13
|
+
s.add_runtime_dependency('cucumber', '>= 1.1.0')
|
|
14
14
|
s.add_runtime_dependency('nokogiri', '>= 1.5.0')
|
|
15
15
|
s.add_runtime_dependency('capybara', '>= 1.1.1')
|
|
16
16
|
s.add_development_dependency('rails', '>= 3.1.0')
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
Feature: Allow Cucumber to rescue exceptions
|
|
2
2
|
|
|
3
|
-
Background: A controller that raises an exception
|
|
3
|
+
Background: A controller that raises an exception
|
|
4
4
|
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
|
5
|
-
And I remove the file "features/step_definitions/web_steps.rb"
|
|
6
5
|
And I write to "app/controllers/posts_controller.rb" with:
|
|
7
6
|
"""
|
|
8
7
|
class PostsController < ApplicationController
|
|
@@ -3,6 +3,20 @@ Feature: Capybara Javascript Drivers
|
|
|
3
3
|
Background: A simple calendar app
|
|
4
4
|
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
|
5
5
|
And I successfully run `bundle exec rails g scaffold appointment name:string when:datetime`
|
|
6
|
+
And I write to "features/step_definitions/date_time_steps.rb" with:
|
|
7
|
+
"""
|
|
8
|
+
When /^(?:|I )select "([^"]+)" as the "([^"]+)" time$/ do |time, selector|
|
|
9
|
+
select_time(selector, :with => time)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
When /^(?:|I )select "([^"]+)" as the "([^"]+)" date$/ do |date, selector|
|
|
13
|
+
select_date(selector, :with => date)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
When /^(?:|I )select "([^"]+)" as the "([^"]+)" date and time$/ do |datetime, selector|
|
|
17
|
+
select_datetime(selector, :with => datetime)
|
|
18
|
+
end
|
|
19
|
+
"""
|
|
6
20
|
|
|
7
21
|
Scenario Outline: Use a particular driver
|
|
8
22
|
Given I write to "features/create_appointment.feature" with:
|
|
@@ -8,9 +8,6 @@ Feature: Rails 3
|
|
|
8
8
|
Then the following files should exist:
|
|
9
9
|
| config/cucumber.yml |
|
|
10
10
|
| script/cucumber |
|
|
11
|
-
| features/step_definitions/web_steps.rb |
|
|
12
11
|
| features/support/env.rb |
|
|
13
|
-
| features/support/paths.rb |
|
|
14
|
-
| features/support/selectors.rb |
|
|
15
12
|
| lib/tasks/cucumber.rake |
|
|
16
13
|
And the file "features/support/env.rb" should contain "require 'cucumber/rails'"
|
data/features/mongoid.feature
CHANGED
|
@@ -20,6 +20,12 @@ Feature: Mongoid
|
|
|
20
20
|
Scenario: Tests
|
|
21
21
|
When I go to the home page
|
|
22
22
|
"""
|
|
23
|
+
And I write to "features/step_definitions/web_steps.rb" with:
|
|
24
|
+
"""
|
|
25
|
+
When /^I go to the home page$/ do
|
|
26
|
+
visit '/'
|
|
27
|
+
end
|
|
28
|
+
"""
|
|
23
29
|
And I overwrite "features/support/env.rb" with:
|
|
24
30
|
"""
|
|
25
31
|
require 'cucumber/rails'
|
|
@@ -5,7 +5,6 @@ Feature: Multiple Databases
|
|
|
5
5
|
|
|
6
6
|
Background: A Rails 3 app utilizing multiple database repositories exists
|
|
7
7
|
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
|
8
|
-
And I remove the file "features/step_definitions/web_steps.rb"
|
|
9
8
|
And I append to "config/database.yml" with:
|
|
10
9
|
"""
|
|
11
10
|
|
|
@@ -1,3 +1,293 @@
|
|
|
1
|
+
module WebSteps
|
|
2
|
+
def create_web_steps
|
|
3
|
+
write_file('features/step_definitions/web_steps.rb', <<-EOF)
|
|
4
|
+
# web_steps.rb used to be in Cucumber-Rails, but was removed in 1.1.0. We're still using them in the tests because
|
|
5
|
+
# the tests were written while we still thought web_steps.rb was a good idea. We don't think so anymore:
|
|
6
|
+
#
|
|
7
|
+
# http://groups.google.com/group/cukes/browse_thread/thread/26f80b93c94f2952
|
|
8
|
+
# https://github.com/cucumber/cucumber-rails/issues/174
|
|
9
|
+
# http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
|
|
10
|
+
# http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
|
|
11
|
+
# http://elabs.se/blog/15-you-re-cuking-it-wrong
|
|
12
|
+
#
|
|
13
|
+
# I'm sure someone will find this and paste it into their own projects. Go ahead. It's a bad idea.
|
|
14
|
+
# You have been warned.
|
|
15
|
+
#
|
|
16
|
+
# Aslak
|
|
17
|
+
|
|
18
|
+
require 'uri'
|
|
19
|
+
require 'cgi'
|
|
20
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
|
21
|
+
|
|
22
|
+
module WithinHelpers
|
|
23
|
+
def with_scope(locator)
|
|
24
|
+
locator ? within(*selector_for(locator)) { yield } : yield
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
World(WithinHelpers)
|
|
28
|
+
|
|
29
|
+
# Single-line step scoper
|
|
30
|
+
When /^(.*) within (.*[^:])$/ do |step, parent|
|
|
31
|
+
with_scope(parent) { When step }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Multi-line step scoper
|
|
35
|
+
When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
|
|
36
|
+
with_scope(parent) { When "\#{step}:", table_or_string }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
|
40
|
+
visit path_to(page_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
|
44
|
+
visit path_to(page_name)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
When /^(?:|I )press "([^"]*)"$/ do |button|
|
|
48
|
+
click_button(button)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
|
52
|
+
click_link(link)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
|
56
|
+
fill_in(field, :with => value)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
|
60
|
+
fill_in(field, :with => value)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Use this to fill in an entire form with data from a table. Example:
|
|
64
|
+
#
|
|
65
|
+
# When I fill in the following:
|
|
66
|
+
# | Account Number | 5002 |
|
|
67
|
+
# | Expiry date | 2009-11-01 |
|
|
68
|
+
# | Note | Nice guy |
|
|
69
|
+
# | Wants Email? | |
|
|
70
|
+
#
|
|
71
|
+
# TODO: Add support for checkbox, select or option
|
|
72
|
+
# based on naming conventions.
|
|
73
|
+
#
|
|
74
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
|
75
|
+
fields.rows_hash.each do |name, value|
|
|
76
|
+
When %{I fill in "\#{name}" with "\#{value}"}
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
|
81
|
+
select(value, :from => field)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
When /^(?:|I )check "([^"]*)"$/ do |field|
|
|
85
|
+
check(field)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
|
89
|
+
uncheck(field)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
|
93
|
+
choose(field)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
|
97
|
+
attach_file(field, File.expand_path(path))
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
|
101
|
+
if page.respond_to? :should
|
|
102
|
+
page.should have_content(text)
|
|
103
|
+
else
|
|
104
|
+
assert page.has_content?(text)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
Then /^(?:|I )should see \\/([^\\/]*)\\/$/ do |regexp|
|
|
109
|
+
regexp = Regexp.new(regexp)
|
|
110
|
+
|
|
111
|
+
if page.respond_to? :should
|
|
112
|
+
page.should have_xpath('//*', :text => regexp)
|
|
113
|
+
else
|
|
114
|
+
assert page.has_xpath?('//*', :text => regexp)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
|
119
|
+
if page.respond_to? :should
|
|
120
|
+
page.should have_no_content(text)
|
|
121
|
+
else
|
|
122
|
+
assert page.has_no_content?(text)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
Then /^(?:|I )should not see \\/([^\\/]*)\\/$/ do |regexp|
|
|
127
|
+
regexp = Regexp.new(regexp)
|
|
128
|
+
|
|
129
|
+
if page.respond_to? :should
|
|
130
|
+
page.should have_no_xpath('//*', :text => regexp)
|
|
131
|
+
else
|
|
132
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
|
137
|
+
with_scope(parent) do
|
|
138
|
+
field = find_field(field)
|
|
139
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
|
140
|
+
if field_value.respond_to? :should
|
|
141
|
+
field_value.should =~ /\#{value}/
|
|
142
|
+
else
|
|
143
|
+
assert_match(/\#{value}/, field_value)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
|
149
|
+
with_scope(parent) do
|
|
150
|
+
field = find_field(field)
|
|
151
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
|
152
|
+
if field_value.respond_to? :should_not
|
|
153
|
+
field_value.should_not =~ /\#{value}/
|
|
154
|
+
else
|
|
155
|
+
assert_no_match(/\#{value}/, field_value)
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
Then /^the "([^"]*)" field should have the error "([^"]*)"$/ do |field, error_message|
|
|
161
|
+
element = find_field(field)
|
|
162
|
+
classes = element.find(:xpath, '..')[:class].split(' ')
|
|
163
|
+
|
|
164
|
+
form_for_input = element.find(:xpath, 'ancestor::form[1]')
|
|
165
|
+
using_formtastic = form_for_input[:class].include?('formtastic')
|
|
166
|
+
error_class = using_formtastic ? 'error' : 'field_with_errors'
|
|
167
|
+
|
|
168
|
+
if classes.respond_to? :should
|
|
169
|
+
classes.should include(error_class)
|
|
170
|
+
else
|
|
171
|
+
assert classes.include?(error_class)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
if page.respond_to?(:should)
|
|
175
|
+
if using_formtastic
|
|
176
|
+
error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
|
|
177
|
+
error_paragraph.should have_content(error_message)
|
|
178
|
+
else
|
|
179
|
+
page.should have_content("\#{field.titlecase} \#{error_message}")
|
|
180
|
+
end
|
|
181
|
+
else
|
|
182
|
+
if using_formtastic
|
|
183
|
+
error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
|
|
184
|
+
assert error_paragraph.has_content?(error_message)
|
|
185
|
+
else
|
|
186
|
+
assert page.has_content?("\#{field.titlecase} \#{error_message}")
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
Then /^the "([^"]*)" field should have no error$/ do |field|
|
|
192
|
+
element = find_field(field)
|
|
193
|
+
classes = element.find(:xpath, '..')[:class].split(' ')
|
|
194
|
+
if classes.respond_to? :should
|
|
195
|
+
classes.should_not include('field_with_errors')
|
|
196
|
+
classes.should_not include('error')
|
|
197
|
+
else
|
|
198
|
+
assert !classes.include?('field_with_errors')
|
|
199
|
+
assert !classes.include?('error')
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
|
204
|
+
with_scope(parent) do
|
|
205
|
+
field_checked = find_field(label)['checked']
|
|
206
|
+
if field_checked.respond_to? :should
|
|
207
|
+
field_checked.should be_true
|
|
208
|
+
else
|
|
209
|
+
assert field_checked
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
|
215
|
+
with_scope(parent) do
|
|
216
|
+
field_checked = find_field(label)['checked']
|
|
217
|
+
if field_checked.respond_to? :should
|
|
218
|
+
field_checked.should be_false
|
|
219
|
+
else
|
|
220
|
+
assert !field_checked
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
|
226
|
+
current_path = URI.parse(current_url).path
|
|
227
|
+
if current_path.respond_to? :should
|
|
228
|
+
current_path.should == path_to(page_name)
|
|
229
|
+
else
|
|
230
|
+
assert_equal path_to(page_name), current_path
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
|
235
|
+
query = URI.parse(current_url).query
|
|
236
|
+
actual_params = query ? CGI.parse(query) : {}
|
|
237
|
+
expected_params = {}
|
|
238
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
|
239
|
+
|
|
240
|
+
if actual_params.respond_to? :should
|
|
241
|
+
actual_params.should == expected_params
|
|
242
|
+
else
|
|
243
|
+
assert_equal expected_params, actual_params
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
Then /^show me the page$/ do
|
|
248
|
+
save_and_open_page
|
|
249
|
+
end
|
|
250
|
+
EOF
|
|
251
|
+
|
|
252
|
+
write_file('features/support/paths.rb', <<-EOF)
|
|
253
|
+
module NavigationHelpers
|
|
254
|
+
# Maps a name to a path. Used by the
|
|
255
|
+
#
|
|
256
|
+
# When /^I go to (.+)$/ do |page_name|
|
|
257
|
+
#
|
|
258
|
+
# step definition in web_steps.rb
|
|
259
|
+
#
|
|
260
|
+
def path_to(page_name)
|
|
261
|
+
case page_name
|
|
262
|
+
|
|
263
|
+
when /^the home\s?page$/
|
|
264
|
+
'/'
|
|
265
|
+
|
|
266
|
+
# Add more mappings here.
|
|
267
|
+
# Here is an example that pulls values out of the Regexp:
|
|
268
|
+
#
|
|
269
|
+
# when /^(.*)'s profile page$/i
|
|
270
|
+
# user_profile_path(User.find_by_login($1))
|
|
271
|
+
|
|
272
|
+
else
|
|
273
|
+
begin
|
|
274
|
+
page_name =~ /^the (.*) page$/
|
|
275
|
+
path_components = $1.split(/\s+/)
|
|
276
|
+
self.send(path_components.push('path').join('_').to_sym)
|
|
277
|
+
rescue NoMethodError, ArgumentError
|
|
278
|
+
raise "Can't find mapping from \"\#{page_name}\" to a path.\\n" +
|
|
279
|
+
"Now, go and add a mapping in \#{__FILE__}"
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
World(NavigationHelpers)
|
|
286
|
+
EOF
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
World(WebSteps)
|
|
290
|
+
|
|
1
291
|
Given /^I have created a new Rails 3 app "([^"]*)" with cucumber\-rails support and cucumber-rails is outside of test group$/ do |app_name|
|
|
2
292
|
steps %Q{
|
|
3
293
|
When I successfully run `rails new #{app_name}`
|
|
@@ -17,6 +307,7 @@ Given /^I have created a new Rails 3 app "([^"]*)" with cucumber\-rails support
|
|
|
17
307
|
"""
|
|
18
308
|
And I successfully run `bundle exec rails generate cucumber:install`
|
|
19
309
|
}
|
|
310
|
+
create_web_steps
|
|
20
311
|
if(ENV['ARUBA_REPORT_DIR'])
|
|
21
312
|
@aruba_report_start = Time.new
|
|
22
313
|
sleep(1)
|
|
@@ -42,6 +333,7 @@ Given /^I have created a new Rails 3 app "([^"]*)" with cucumber\-rails support$
|
|
|
42
333
|
"""
|
|
43
334
|
And I successfully run `bundle exec rails generate cucumber:install`
|
|
44
335
|
}
|
|
336
|
+
create_web_steps
|
|
45
337
|
if(ENV['ARUBA_REPORT_DIR'])
|
|
46
338
|
@aruba_report_start = Time.new
|
|
47
339
|
sleep(1)
|
|
@@ -87,6 +379,7 @@ Given /^a project without ActiveRecord$/ do
|
|
|
87
379
|
"""
|
|
88
380
|
And I remove the file "config/database.yml"
|
|
89
381
|
}
|
|
382
|
+
create_web_steps
|
|
90
383
|
if(ENV['ARUBA_REPORT_DIR'])
|
|
91
384
|
@aruba_report_start = Time.new
|
|
92
385
|
sleep(1)
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
module Cucumber
|
|
2
2
|
module Rails
|
|
3
3
|
module Capybara
|
|
4
|
+
# This module defines methods for selecting dates and times
|
|
4
5
|
module SelectDatesAndTimes
|
|
5
|
-
|
|
6
|
+
# Select a Rails date with label +field+
|
|
7
|
+
# The +options+ hash should contain a Date parseable date (as a string)
|
|
8
|
+
def select_date(field, options)
|
|
6
9
|
date = Date.parse(options[:with])
|
|
7
10
|
base_dom_id = get_base_dom_id_from_label_tag(field)
|
|
8
11
|
|
|
@@ -11,7 +14,9 @@ module Cucumber
|
|
|
11
14
|
find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
|
|
12
15
|
end
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
# Select a Rails time with label +field+
|
|
18
|
+
# The +options+ hash should contain a Time parseable time (as a string)
|
|
19
|
+
def select_time(field, options)
|
|
15
20
|
time = Time.zone.parse(options[:with])
|
|
16
21
|
base_dom_id = get_base_dom_id_from_label_tag(field)
|
|
17
22
|
|
|
@@ -19,7 +24,9 @@ module Cucumber
|
|
|
19
24
|
find(:xpath, ".//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
|
|
20
25
|
end
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
# Select a Rails date and time with label +field+
|
|
28
|
+
# The +options+ hash should contain a Date/Time parseable time (as a string)
|
|
29
|
+
def select_datetime(field, options)
|
|
23
30
|
select_date(field, options)
|
|
24
31
|
select_time(field, options)
|
|
25
32
|
end
|
|
@@ -36,15 +43,3 @@ module Cucumber
|
|
|
36
43
|
end
|
|
37
44
|
|
|
38
45
|
World(::Cucumber::Rails::Capybara::SelectDatesAndTimes)
|
|
39
|
-
|
|
40
|
-
When /^(?:|I )select "([^"]+)" as the "([^"]+)" time$/ do |time, selector|
|
|
41
|
-
select_time(selector, :with => time)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
When /^(?:|I )select "([^"]+)" as the "([^"]+)" date$/ do |date, selector|
|
|
45
|
-
select_date(selector, :with => date)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
When /^(?:|I )select "([^"]+)" as the "([^"]+)" date and time$/ do |datetime, selector|
|
|
49
|
-
select_datetime(selector, :with => datetime)
|
|
50
|
-
end
|
|
@@ -6,15 +6,9 @@ module Cucumber
|
|
|
6
6
|
|
|
7
7
|
DEFAULT_SHEBANG = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
|
8
8
|
|
|
9
|
-
argument :language, :type => :string, :banner => "LANG", :optional => true
|
|
10
|
-
|
|
11
|
-
class_option :rspec, :type => :boolean, :desc => "Use RSpec"
|
|
12
|
-
class_option :testunit, :type => :boolean, :desc => "Use Test::Unit"
|
|
13
9
|
class_option :spork, :type => :boolean, :desc => "Use Spork"
|
|
14
10
|
class_option :skip_database, :type => :boolean, :desc => "Skip modification of database.yml", :aliases => '-D', :default => false
|
|
15
11
|
|
|
16
|
-
attr_reader :framework
|
|
17
|
-
|
|
18
12
|
def create_templates
|
|
19
13
|
template 'config/cucumber.yml.erb', 'config/cucumber.yml'
|
|
20
14
|
end
|
|
@@ -26,18 +20,10 @@ module Cucumber
|
|
|
26
20
|
|
|
27
21
|
def create_step_definitions
|
|
28
22
|
empty_directory 'features/step_definitions'
|
|
29
|
-
|
|
30
|
-
template "step_definitions/web_steps.rb.erb", 'features/step_definitions/web_steps.rb'
|
|
31
|
-
if language
|
|
32
|
-
template "step_definitions/web_steps_#{language}.rb.erb", "features/step_definitions/web_steps_#{language}.rb"
|
|
33
|
-
end
|
|
34
23
|
end
|
|
35
24
|
|
|
36
25
|
def create_feature_support
|
|
37
26
|
empty_directory 'features/support'
|
|
38
|
-
copy_file 'support/paths.rb', 'features/support/paths.rb'
|
|
39
|
-
copy_file 'support/selectors.rb', 'features/support/selectors.rb'
|
|
40
|
-
|
|
41
27
|
if spork?
|
|
42
28
|
template 'support/rails_spork.rb.erb', 'features/support/env.rb'
|
|
43
29
|
else
|
|
@@ -76,13 +62,5 @@ module Cucumber
|
|
|
76
62
|
ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
|
|
77
63
|
end
|
|
78
64
|
|
|
79
|
-
private
|
|
80
|
-
|
|
81
|
-
def framework_from_options
|
|
82
|
-
return 'rspec-rails' if options[:rspec]
|
|
83
|
-
return 'testunit' if options[:testunit]
|
|
84
|
-
return 'rspec-rails'
|
|
85
|
-
end
|
|
86
|
-
|
|
87
65
|
end
|
|
88
66
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cucumber-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -11,22 +11,22 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2011-09-
|
|
14
|
+
date: 2011-09-28 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: cucumber
|
|
18
|
-
requirement: &
|
|
18
|
+
requirement: &2169121020 !ruby/object:Gem::Requirement
|
|
19
19
|
none: false
|
|
20
20
|
requirements:
|
|
21
21
|
- - ! '>='
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: 1.0
|
|
23
|
+
version: 1.1.0
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
|
-
version_requirements: *
|
|
26
|
+
version_requirements: *2169121020
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: nokogiri
|
|
29
|
-
requirement: &
|
|
29
|
+
requirement: &2169120280 !ruby/object:Gem::Requirement
|
|
30
30
|
none: false
|
|
31
31
|
requirements:
|
|
32
32
|
- - ! '>='
|
|
@@ -34,10 +34,10 @@ dependencies:
|
|
|
34
34
|
version: 1.5.0
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
|
-
version_requirements: *
|
|
37
|
+
version_requirements: *2169120280
|
|
38
38
|
- !ruby/object:Gem::Dependency
|
|
39
39
|
name: capybara
|
|
40
|
-
requirement: &
|
|
40
|
+
requirement: &2169119720 !ruby/object:Gem::Requirement
|
|
41
41
|
none: false
|
|
42
42
|
requirements:
|
|
43
43
|
- - ! '>='
|
|
@@ -45,10 +45,10 @@ dependencies:
|
|
|
45
45
|
version: 1.1.1
|
|
46
46
|
type: :runtime
|
|
47
47
|
prerelease: false
|
|
48
|
-
version_requirements: *
|
|
48
|
+
version_requirements: *2169119720
|
|
49
49
|
- !ruby/object:Gem::Dependency
|
|
50
50
|
name: rails
|
|
51
|
-
requirement: &
|
|
51
|
+
requirement: &2169135520 !ruby/object:Gem::Requirement
|
|
52
52
|
none: false
|
|
53
53
|
requirements:
|
|
54
54
|
- - ! '>='
|
|
@@ -56,10 +56,10 @@ dependencies:
|
|
|
56
56
|
version: 3.1.0
|
|
57
57
|
type: :development
|
|
58
58
|
prerelease: false
|
|
59
|
-
version_requirements: *
|
|
59
|
+
version_requirements: *2169135520
|
|
60
60
|
- !ruby/object:Gem::Dependency
|
|
61
61
|
name: rake
|
|
62
|
-
requirement: &
|
|
62
|
+
requirement: &2169134700 !ruby/object:Gem::Requirement
|
|
63
63
|
none: false
|
|
64
64
|
requirements:
|
|
65
65
|
- - ! '>='
|
|
@@ -67,10 +67,10 @@ dependencies:
|
|
|
67
67
|
version: 0.9.2
|
|
68
68
|
type: :development
|
|
69
69
|
prerelease: false
|
|
70
|
-
version_requirements: *
|
|
70
|
+
version_requirements: *2169134700
|
|
71
71
|
- !ruby/object:Gem::Dependency
|
|
72
72
|
name: bundler
|
|
73
|
-
requirement: &
|
|
73
|
+
requirement: &2169134100 !ruby/object:Gem::Requirement
|
|
74
74
|
none: false
|
|
75
75
|
requirements:
|
|
76
76
|
- - ! '>='
|
|
@@ -78,10 +78,10 @@ dependencies:
|
|
|
78
78
|
version: 1.0.18
|
|
79
79
|
type: :development
|
|
80
80
|
prerelease: false
|
|
81
|
-
version_requirements: *
|
|
81
|
+
version_requirements: *2169134100
|
|
82
82
|
- !ruby/object:Gem::Dependency
|
|
83
83
|
name: aruba
|
|
84
|
-
requirement: &
|
|
84
|
+
requirement: &2169133480 !ruby/object:Gem::Requirement
|
|
85
85
|
none: false
|
|
86
86
|
requirements:
|
|
87
87
|
- - ! '>='
|
|
@@ -89,10 +89,10 @@ dependencies:
|
|
|
89
89
|
version: 0.4.6
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
|
-
version_requirements: *
|
|
92
|
+
version_requirements: *2169133480
|
|
93
93
|
- !ruby/object:Gem::Dependency
|
|
94
94
|
name: sqlite3
|
|
95
|
-
requirement: &
|
|
95
|
+
requirement: &2169132480 !ruby/object:Gem::Requirement
|
|
96
96
|
none: false
|
|
97
97
|
requirements:
|
|
98
98
|
- - ! '>='
|
|
@@ -100,10 +100,10 @@ dependencies:
|
|
|
100
100
|
version: 1.3.4
|
|
101
101
|
type: :development
|
|
102
102
|
prerelease: false
|
|
103
|
-
version_requirements: *
|
|
103
|
+
version_requirements: *2169132480
|
|
104
104
|
- !ruby/object:Gem::Dependency
|
|
105
105
|
name: rspec
|
|
106
|
-
requirement: &
|
|
106
|
+
requirement: &2169131800 !ruby/object:Gem::Requirement
|
|
107
107
|
none: false
|
|
108
108
|
requirements:
|
|
109
109
|
- - ! '>='
|
|
@@ -111,10 +111,10 @@ dependencies:
|
|
|
111
111
|
version: 2.6.0
|
|
112
112
|
type: :development
|
|
113
113
|
prerelease: false
|
|
114
|
-
version_requirements: *
|
|
114
|
+
version_requirements: *2169131800
|
|
115
115
|
- !ruby/object:Gem::Dependency
|
|
116
116
|
name: rspec-rails
|
|
117
|
-
requirement: &
|
|
117
|
+
requirement: &2169131260 !ruby/object:Gem::Requirement
|
|
118
118
|
none: false
|
|
119
119
|
requirements:
|
|
120
120
|
- - ! '>='
|
|
@@ -122,10 +122,10 @@ dependencies:
|
|
|
122
122
|
version: 2.6.1
|
|
123
123
|
type: :development
|
|
124
124
|
prerelease: false
|
|
125
|
-
version_requirements: *
|
|
125
|
+
version_requirements: *2169131260
|
|
126
126
|
- !ruby/object:Gem::Dependency
|
|
127
127
|
name: factory_girl
|
|
128
|
-
requirement: &
|
|
128
|
+
requirement: &2169130460 !ruby/object:Gem::Requirement
|
|
129
129
|
none: false
|
|
130
130
|
requirements:
|
|
131
131
|
- - ! '>='
|
|
@@ -133,10 +133,10 @@ dependencies:
|
|
|
133
133
|
version: 2.1.0
|
|
134
134
|
type: :development
|
|
135
135
|
prerelease: false
|
|
136
|
-
version_requirements: *
|
|
136
|
+
version_requirements: *2169130460
|
|
137
137
|
- !ruby/object:Gem::Dependency
|
|
138
138
|
name: database_cleaner
|
|
139
|
-
requirement: &
|
|
139
|
+
requirement: &2169129860 !ruby/object:Gem::Requirement
|
|
140
140
|
none: false
|
|
141
141
|
requirements:
|
|
142
142
|
- - ! '>='
|
|
@@ -144,10 +144,10 @@ dependencies:
|
|
|
144
144
|
version: 0.6.7
|
|
145
145
|
type: :development
|
|
146
146
|
prerelease: false
|
|
147
|
-
version_requirements: *
|
|
147
|
+
version_requirements: *2169129860
|
|
148
148
|
- !ruby/object:Gem::Dependency
|
|
149
149
|
name: mongoid
|
|
150
|
-
requirement: &
|
|
150
|
+
requirement: &2169129140 !ruby/object:Gem::Requirement
|
|
151
151
|
none: false
|
|
152
152
|
requirements:
|
|
153
153
|
- - ! '>='
|
|
@@ -155,10 +155,10 @@ dependencies:
|
|
|
155
155
|
version: 2.2.0
|
|
156
156
|
type: :development
|
|
157
157
|
prerelease: false
|
|
158
|
-
version_requirements: *
|
|
158
|
+
version_requirements: *2169129140
|
|
159
159
|
- !ruby/object:Gem::Dependency
|
|
160
160
|
name: bson_ext
|
|
161
|
-
requirement: &
|
|
161
|
+
requirement: &2169128140 !ruby/object:Gem::Requirement
|
|
162
162
|
none: false
|
|
163
163
|
requirements:
|
|
164
164
|
- - ! '>='
|
|
@@ -166,10 +166,10 @@ dependencies:
|
|
|
166
166
|
version: 1.3.1
|
|
167
167
|
type: :development
|
|
168
168
|
prerelease: false
|
|
169
|
-
version_requirements: *
|
|
169
|
+
version_requirements: *2169128140
|
|
170
170
|
- !ruby/object:Gem::Dependency
|
|
171
171
|
name: turn
|
|
172
|
-
requirement: &
|
|
172
|
+
requirement: &2169142900 !ruby/object:Gem::Requirement
|
|
173
173
|
none: false
|
|
174
174
|
requirements:
|
|
175
175
|
- - ! '>='
|
|
@@ -177,10 +177,10 @@ dependencies:
|
|
|
177
177
|
version: 0.8.2
|
|
178
178
|
type: :development
|
|
179
179
|
prerelease: false
|
|
180
|
-
version_requirements: *
|
|
180
|
+
version_requirements: *2169142900
|
|
181
181
|
- !ruby/object:Gem::Dependency
|
|
182
182
|
name: sass
|
|
183
|
-
requirement: &
|
|
183
|
+
requirement: &2169140500 !ruby/object:Gem::Requirement
|
|
184
184
|
none: false
|
|
185
185
|
requirements:
|
|
186
186
|
- - ! '>='
|
|
@@ -188,10 +188,10 @@ dependencies:
|
|
|
188
188
|
version: 3.1.7
|
|
189
189
|
type: :development
|
|
190
190
|
prerelease: false
|
|
191
|
-
version_requirements: *
|
|
191
|
+
version_requirements: *2169140500
|
|
192
192
|
- !ruby/object:Gem::Dependency
|
|
193
193
|
name: coffee-script
|
|
194
|
-
requirement: &
|
|
194
|
+
requirement: &2169139420 !ruby/object:Gem::Requirement
|
|
195
195
|
none: false
|
|
196
196
|
requirements:
|
|
197
197
|
- - ! '>='
|
|
@@ -199,10 +199,10 @@ dependencies:
|
|
|
199
199
|
version: 2.2.0
|
|
200
200
|
type: :development
|
|
201
201
|
prerelease: false
|
|
202
|
-
version_requirements: *
|
|
202
|
+
version_requirements: *2169139420
|
|
203
203
|
- !ruby/object:Gem::Dependency
|
|
204
204
|
name: uglifier
|
|
205
|
-
requirement: &
|
|
205
|
+
requirement: &2169138580 !ruby/object:Gem::Requirement
|
|
206
206
|
none: false
|
|
207
207
|
requirements:
|
|
208
208
|
- - ! '>='
|
|
@@ -210,10 +210,10 @@ dependencies:
|
|
|
210
210
|
version: 1.0.3
|
|
211
211
|
type: :development
|
|
212
212
|
prerelease: false
|
|
213
|
-
version_requirements: *
|
|
213
|
+
version_requirements: *2169138580
|
|
214
214
|
- !ruby/object:Gem::Dependency
|
|
215
215
|
name: jquery-rails
|
|
216
|
-
requirement: &
|
|
216
|
+
requirement: &2169137860 !ruby/object:Gem::Requirement
|
|
217
217
|
none: false
|
|
218
218
|
requirements:
|
|
219
219
|
- - ! '>='
|
|
@@ -221,10 +221,10 @@ dependencies:
|
|
|
221
221
|
version: 1.0.14
|
|
222
222
|
type: :development
|
|
223
223
|
prerelease: false
|
|
224
|
-
version_requirements: *
|
|
224
|
+
version_requirements: *2169137860
|
|
225
225
|
- !ruby/object:Gem::Dependency
|
|
226
226
|
name: yard
|
|
227
|
-
requirement: &
|
|
227
|
+
requirement: &2169136400 !ruby/object:Gem::Requirement
|
|
228
228
|
none: false
|
|
229
229
|
requirements:
|
|
230
230
|
- - ~>
|
|
@@ -232,10 +232,10 @@ dependencies:
|
|
|
232
232
|
version: 0.7.2
|
|
233
233
|
type: :development
|
|
234
234
|
prerelease: false
|
|
235
|
-
version_requirements: *
|
|
235
|
+
version_requirements: *2169136400
|
|
236
236
|
- !ruby/object:Gem::Dependency
|
|
237
237
|
name: rdiscount
|
|
238
|
-
requirement: &
|
|
238
|
+
requirement: &2169196680 !ruby/object:Gem::Requirement
|
|
239
239
|
none: false
|
|
240
240
|
requirements:
|
|
241
241
|
- - ~>
|
|
@@ -243,10 +243,10 @@ dependencies:
|
|
|
243
243
|
version: 1.6.8
|
|
244
244
|
type: :development
|
|
245
245
|
prerelease: false
|
|
246
|
-
version_requirements: *
|
|
246
|
+
version_requirements: *2169196680
|
|
247
247
|
- !ruby/object:Gem::Dependency
|
|
248
248
|
name: bcat
|
|
249
|
-
requirement: &
|
|
249
|
+
requirement: &2169195980 !ruby/object:Gem::Requirement
|
|
250
250
|
none: false
|
|
251
251
|
requirements:
|
|
252
252
|
- - ~>
|
|
@@ -254,7 +254,7 @@ dependencies:
|
|
|
254
254
|
version: 0.6.2
|
|
255
255
|
type: :development
|
|
256
256
|
prerelease: false
|
|
257
|
-
version_requirements: *
|
|
257
|
+
version_requirements: *2169195980
|
|
258
258
|
description: Cucumber Generators and Runtime for Rails
|
|
259
259
|
email: cukes@googlegroups.com
|
|
260
260
|
executables: []
|
|
@@ -292,13 +292,10 @@ files:
|
|
|
292
292
|
- features/install_cucumber_rails.feature
|
|
293
293
|
- features/mongoid.feature
|
|
294
294
|
- features/multiple_databases.feature
|
|
295
|
-
- features/named_selectors.feature
|
|
296
295
|
- features/no_database.feature
|
|
297
|
-
- features/pseudo_class_selectors.feature
|
|
298
296
|
- features/rerun_profile.feature
|
|
299
297
|
- features/rest_api.feature
|
|
300
298
|
- features/routing.feature
|
|
301
|
-
- features/select_dates.feature
|
|
302
299
|
- features/step_definitions/cucumber_rails_steps.rb
|
|
303
300
|
- features/support/env.rb
|
|
304
301
|
- features/test_unit.feature
|
|
@@ -338,11 +335,8 @@ files:
|
|
|
338
335
|
- lib/generators/cucumber/install/templates/support/_rails_prefork.rb.erb
|
|
339
336
|
- lib/generators/cucumber/install/templates/support/capybara.rb
|
|
340
337
|
- lib/generators/cucumber/install/templates/support/edit_warning.txt
|
|
341
|
-
- lib/generators/cucumber/install/templates/support/paths.rb
|
|
342
338
|
- lib/generators/cucumber/install/templates/support/rails.rb.erb
|
|
343
339
|
- lib/generators/cucumber/install/templates/support/rails_spork.rb.erb
|
|
344
|
-
- lib/generators/cucumber/install/templates/support/selectors.rb
|
|
345
|
-
- lib/generators/cucumber/install/templates/support/web_steps_warning.txt
|
|
346
340
|
- lib/generators/cucumber/install/templates/tasks/cucumber.rake.erb
|
|
347
341
|
- spec/cucumber/web/tableish_spec.rb
|
|
348
342
|
- spec/spec_helper.rb
|
|
@@ -360,7 +354,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
360
354
|
version: '0'
|
|
361
355
|
segments:
|
|
362
356
|
- 0
|
|
363
|
-
hash:
|
|
357
|
+
hash: -3221260629709489818
|
|
364
358
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
365
359
|
none: false
|
|
366
360
|
requirements:
|
|
@@ -369,13 +363,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
369
363
|
version: '0'
|
|
370
364
|
segments:
|
|
371
365
|
- 0
|
|
372
|
-
hash:
|
|
366
|
+
hash: -3221260629709489818
|
|
373
367
|
requirements: []
|
|
374
368
|
rubyforge_project:
|
|
375
369
|
rubygems_version: 1.8.10
|
|
376
370
|
signing_key:
|
|
377
371
|
specification_version: 3
|
|
378
|
-
summary: cucumber-rails-1.0
|
|
372
|
+
summary: cucumber-rails-1.1.0
|
|
379
373
|
test_files:
|
|
380
374
|
- features/allow_rescue.feature
|
|
381
375
|
- features/capybara_javascript_drivers.feature
|
|
@@ -387,13 +381,10 @@ test_files:
|
|
|
387
381
|
- features/install_cucumber_rails.feature
|
|
388
382
|
- features/mongoid.feature
|
|
389
383
|
- features/multiple_databases.feature
|
|
390
|
-
- features/named_selectors.feature
|
|
391
384
|
- features/no_database.feature
|
|
392
|
-
- features/pseudo_class_selectors.feature
|
|
393
385
|
- features/rerun_profile.feature
|
|
394
386
|
- features/rest_api.feature
|
|
395
387
|
- features/routing.feature
|
|
396
|
-
- features/select_dates.feature
|
|
397
388
|
- features/step_definitions/cucumber_rails_steps.rb
|
|
398
389
|
- features/support/env.rb
|
|
399
390
|
- features/test_unit.feature
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
Feature: Named Selectors
|
|
2
|
-
|
|
3
|
-
Scenario: Look within named selector
|
|
4
|
-
Given a project without ActiveRecord
|
|
5
|
-
And a cukes resource
|
|
6
|
-
And I write to "app/views/cukes/index.html.erb" with:
|
|
7
|
-
"""
|
|
8
|
-
<div class="foo">foo</div>
|
|
9
|
-
<div class="bar">bar</div>
|
|
10
|
-
"""
|
|
11
|
-
And I write to "features/tests.feature" with:
|
|
12
|
-
"""
|
|
13
|
-
Feature: Tests
|
|
14
|
-
Scenario: Tests
|
|
15
|
-
When I go to the cukes page
|
|
16
|
-
Then I should see "foo" within the foo div
|
|
17
|
-
And I should not see "bar" within the foo div
|
|
18
|
-
"""
|
|
19
|
-
And I overwrite "features/support/selectors.rb" with:
|
|
20
|
-
"""
|
|
21
|
-
module HtmlSelectorsHelpers
|
|
22
|
-
def selector_for(locator)
|
|
23
|
-
return '.foo' if locator == 'the foo div'
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
World(HtmlSelectorsHelpers)
|
|
27
|
-
"""
|
|
28
|
-
And I run `rake cucumber`
|
|
29
|
-
Then it should pass with:
|
|
30
|
-
"""
|
|
31
|
-
1 scenario (1 passed)
|
|
32
|
-
3 steps (3 passed)
|
|
33
|
-
"""
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Feature: Pseudo-class Selectors
|
|
2
|
-
|
|
3
|
-
Scenario: Look within css pseudo-class selectors
|
|
4
|
-
Given a project without ActiveRecord
|
|
5
|
-
And a cukes resource
|
|
6
|
-
And I write to "app/views/cukes/index.html.erb" with:
|
|
7
|
-
"""
|
|
8
|
-
<div>foo</div>
|
|
9
|
-
<div>bar</div>
|
|
10
|
-
"""
|
|
11
|
-
And I write to "features/tests.feature" with:
|
|
12
|
-
"""
|
|
13
|
-
Feature: Tests
|
|
14
|
-
Scenario: Tests
|
|
15
|
-
When I go to the cukes page
|
|
16
|
-
Then I should see "bar" within "div:nth-child(2)"
|
|
17
|
-
And I should not see "foo" within "div:nth-child(2)"
|
|
18
|
-
"""
|
|
19
|
-
And I run `rake cucumber`
|
|
20
|
-
Then it should pass with:
|
|
21
|
-
"""
|
|
22
|
-
1 scenario (1 passed)
|
|
23
|
-
3 steps (3 passed)
|
|
24
|
-
"""
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
Feature: Select dates
|
|
2
|
-
|
|
3
|
-
Background: A simple calendar app
|
|
4
|
-
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
|
5
|
-
|
|
6
|
-
Scenario: Select date and time
|
|
7
|
-
Given I successfully run `bundle exec rails g scaffold appointment name:string when:datetime`
|
|
8
|
-
And I write to "features/create_appointment.feature" with:
|
|
9
|
-
"""
|
|
10
|
-
Feature: Create appointments
|
|
11
|
-
Scenario: Constitution on May 17
|
|
12
|
-
Given I am on the new appointment page
|
|
13
|
-
And I fill in "Norway's constitution" for "Name"
|
|
14
|
-
And I select "2009-02-20 15:10:00 UTC" as the "When" date and time
|
|
15
|
-
And I press "Create Appointment"
|
|
16
|
-
Then I should see "Norway's constitution"
|
|
17
|
-
And I should see "2009-02-20 15:10:00 UTC"
|
|
18
|
-
"""
|
|
19
|
-
When I run `bundle exec rake db:migrate`
|
|
20
|
-
And I run `bundle exec rake cucumber`
|
|
21
|
-
Then it should pass with:
|
|
22
|
-
"""
|
|
23
|
-
1 scenario (1 passed)
|
|
24
|
-
6 steps (6 passed)
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
Scenario: Select date with label pointing to first select
|
|
28
|
-
Given I successfully run `bundle exec rails g scaffold appointment name:string when:date`
|
|
29
|
-
And I write to "features/create_appointment.feature" with:
|
|
30
|
-
"""
|
|
31
|
-
Feature: Create appointments
|
|
32
|
-
Scenario: Constitution on May 17
|
|
33
|
-
Given I am on the new appointment page
|
|
34
|
-
And I fill in "Norway's constitution" for "Name"
|
|
35
|
-
And I select "2009-02-20" as the "When" date
|
|
36
|
-
And I press "Create Appointment"
|
|
37
|
-
Then I should see "Norway's constitution"
|
|
38
|
-
And I should see "2009-02-20"
|
|
39
|
-
"""
|
|
40
|
-
And I write to "app/views/appointments/_form.html.erb" with:
|
|
41
|
-
"""
|
|
42
|
-
<%= form_for(@appointment) do |f| %>
|
|
43
|
-
<div class="field">
|
|
44
|
-
<%= f.label :name %><br />
|
|
45
|
-
<%= f.text_field :name %>
|
|
46
|
-
</div>
|
|
47
|
-
<div class="field">
|
|
48
|
-
<%= f.label :when, :for => "appointment_when_1i" %><br />
|
|
49
|
-
<%= f.date_select :when %>
|
|
50
|
-
</div>
|
|
51
|
-
<div class="actions">
|
|
52
|
-
<%= f.submit %>
|
|
53
|
-
</div>
|
|
54
|
-
<% end %>
|
|
55
|
-
"""
|
|
56
|
-
When I run `bundle exec rake db:migrate`
|
|
57
|
-
And I run `bundle exec rake cucumber`
|
|
58
|
-
Then it should pass with:
|
|
59
|
-
"""
|
|
60
|
-
1 scenario (1 passed)
|
|
61
|
-
6 steps (6 passed)
|
|
62
|
-
"""
|
|
63
|
-
|
|
64
|
-
Scenario: Select date when the order of fields is changed and label is set to the first select
|
|
65
|
-
Given I successfully run `bundle exec rails g scaffold appointment name:string when:date`
|
|
66
|
-
And I write to "features/create_appointment.feature" with:
|
|
67
|
-
"""
|
|
68
|
-
Feature: Create appointments
|
|
69
|
-
Scenario: Constitution on May 17
|
|
70
|
-
Given I am on the new appointment page
|
|
71
|
-
And I fill in "Norway's constitution" for "Name"
|
|
72
|
-
And I select "2009-02-20" as the "When" date
|
|
73
|
-
And I press "Create Appointment"
|
|
74
|
-
Then I should see "Norway's constitution"
|
|
75
|
-
And I should see "2009-02-20"
|
|
76
|
-
"""
|
|
77
|
-
And I write to "app/views/appointments/_form.html.erb" with:
|
|
78
|
-
"""
|
|
79
|
-
<%= form_for(@appointment) do |f| %>
|
|
80
|
-
<div class="field">
|
|
81
|
-
<%= f.label :name %><br />
|
|
82
|
-
<%= f.text_field :name %>
|
|
83
|
-
</div>
|
|
84
|
-
<div class="field">
|
|
85
|
-
<%= f.label :when, :for => "appointment_when_2i" %><br />
|
|
86
|
-
<%= f.date_select :when, :order=>[:month, :day, :year] %>
|
|
87
|
-
</div>
|
|
88
|
-
<div class="actions">
|
|
89
|
-
<%= f.submit %>
|
|
90
|
-
</div>
|
|
91
|
-
<% end %>
|
|
92
|
-
"""
|
|
93
|
-
When I run `bundle exec rake db:migrate`
|
|
94
|
-
And I run `bundle exec rake cucumber`
|
|
95
|
-
Then it should pass with:
|
|
96
|
-
"""
|
|
97
|
-
1 scenario (1 passed)
|
|
98
|
-
6 steps (6 passed)
|
|
99
|
-
"""
|
|
100
|
-
|
|
101
|
-
Scenario: Select correct date when scoped
|
|
102
|
-
Given I successfully run `bundle exec rails g scaffold appointment name:string when:date`
|
|
103
|
-
And I write to "features/create_appointment.feature" with:
|
|
104
|
-
"""
|
|
105
|
-
Feature: Create appointments
|
|
106
|
-
Scenario: Constitution on May 17
|
|
107
|
-
Given I am on the new appointment page
|
|
108
|
-
And I fill in "Norway's constitution" for "Name"
|
|
109
|
-
And I select "2009-02-20" as the "When" date
|
|
110
|
-
And I select "2009-03-20" as the "When" date within "#extra"
|
|
111
|
-
And I press "Create Appointment"
|
|
112
|
-
Then I should see "Norway's constitution"
|
|
113
|
-
And I should see "2009-02-20"
|
|
114
|
-
"""
|
|
115
|
-
And I write to "app/views/appointments/_form.html.erb" with:
|
|
116
|
-
"""
|
|
117
|
-
<%= form_for(@appointment) do |f| %>
|
|
118
|
-
<div class="field">
|
|
119
|
-
<%= f.label :name %><br />
|
|
120
|
-
<%= f.text_field :name %>
|
|
121
|
-
</div>
|
|
122
|
-
<div class="field">
|
|
123
|
-
<%= f.label :when, :for => "appointment_when_1i" %><br />
|
|
124
|
-
<%= f.date_select :when %>
|
|
125
|
-
</div>
|
|
126
|
-
<div class="actions">
|
|
127
|
-
<%= f.submit %>
|
|
128
|
-
</div>
|
|
129
|
-
<% end %>
|
|
130
|
-
<div id="extra">
|
|
131
|
-
<%= label_tag 'extra_when_1i', 'When' %>
|
|
132
|
-
<%= date_select "extra", "when" %>
|
|
133
|
-
</div>
|
|
134
|
-
"""
|
|
135
|
-
When I run `bundle exec rake db:migrate`
|
|
136
|
-
And I run `bundle exec rake cucumber`
|
|
137
|
-
Then it should pass with:
|
|
138
|
-
"""
|
|
139
|
-
1 scenario (1 passed)
|
|
140
|
-
7 steps (7 passed)
|
|
141
|
-
"""
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module NavigationHelpers
|
|
2
|
-
# Maps a name to a path. Used by the
|
|
3
|
-
#
|
|
4
|
-
# When /^I go to (.+)$/ do |page_name|
|
|
5
|
-
#
|
|
6
|
-
# step definition in web_steps.rb
|
|
7
|
-
#
|
|
8
|
-
def path_to(page_name)
|
|
9
|
-
case page_name
|
|
10
|
-
|
|
11
|
-
when /^the home\s?page$/
|
|
12
|
-
'/'
|
|
13
|
-
|
|
14
|
-
# Add more mappings here.
|
|
15
|
-
# Here is an example that pulls values out of the Regexp:
|
|
16
|
-
#
|
|
17
|
-
# when /^(.*)'s profile page$/i
|
|
18
|
-
# user_profile_path(User.find_by_login($1))
|
|
19
|
-
|
|
20
|
-
else
|
|
21
|
-
begin
|
|
22
|
-
page_name =~ /^the (.*) page$/
|
|
23
|
-
path_components = $1.split(/\s+/)
|
|
24
|
-
self.send(path_components.push('path').join('_').to_sym)
|
|
25
|
-
rescue NoMethodError, ArgumentError
|
|
26
|
-
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
|
27
|
-
"Now, go and add a mapping in #{__FILE__}"
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
World(NavigationHelpers)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
module HtmlSelectorsHelpers
|
|
2
|
-
# Maps a name to a selector. Used primarily by the
|
|
3
|
-
#
|
|
4
|
-
# When /^(.+) within (.+)$/ do |step, scope|
|
|
5
|
-
#
|
|
6
|
-
# step definitions in web_steps.rb
|
|
7
|
-
#
|
|
8
|
-
def selector_for(locator)
|
|
9
|
-
case locator
|
|
10
|
-
|
|
11
|
-
when "the page"
|
|
12
|
-
"html > body"
|
|
13
|
-
|
|
14
|
-
# Add more mappings here.
|
|
15
|
-
# Here is an example that pulls values out of the Regexp:
|
|
16
|
-
#
|
|
17
|
-
# when /^the (notice|error|info) flash$/
|
|
18
|
-
# ".flash.#{$1}"
|
|
19
|
-
|
|
20
|
-
# You can also return an array to use a different selector
|
|
21
|
-
# type, like:
|
|
22
|
-
#
|
|
23
|
-
# when /the header/
|
|
24
|
-
# [:xpath, "//header"]
|
|
25
|
-
|
|
26
|
-
# This allows you to provide a quoted selector as the scope
|
|
27
|
-
# for "within" steps as was previously the default for the
|
|
28
|
-
# web steps:
|
|
29
|
-
when /^"(.+)"$/
|
|
30
|
-
$1
|
|
31
|
-
|
|
32
|
-
else
|
|
33
|
-
raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
|
|
34
|
-
"Now, go and add a mapping in #{__FILE__}"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
World(HtmlSelectorsHelpers)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# TL;DR: YOU SHOULD DELETE THIS FILE
|
|
2
|
-
#
|
|
3
|
-
# This file was generated by Cucumber-Rails and is only here to get you a head start
|
|
4
|
-
# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
|
|
5
|
-
# visit pages, interact with widgets and make assertions about page content.
|
|
6
|
-
#
|
|
7
|
-
# If you use these step definitions as basis for your features you will quickly end up
|
|
8
|
-
# with features that are:
|
|
9
|
-
#
|
|
10
|
-
# * Hard to maintain
|
|
11
|
-
# * Verbose to read
|
|
12
|
-
#
|
|
13
|
-
# A much better approach is to write your own higher level step definitions, following
|
|
14
|
-
# the advice in the following blog posts:
|
|
15
|
-
#
|
|
16
|
-
# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
|
|
17
|
-
# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
|
|
18
|
-
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
|
|
19
|
-
#
|