rapid-app 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/Gemfile +11 -0
- data/Rakefile +4 -0
- data/lib/rapid/app/settings.rb +259 -0
- data/lib/rapid/app/skeleton.rb +213 -0
- data/lib/rapid/app/version.rb +5 -0
- data/lib/rapid/app.rb +13 -0
- data/lib/rapid-app.rb +5 -0
- data/rapid-app.gemspec +33 -0
- data/spec/rapid/app/skeleton_spec.rb +50 -0
- data/spec/rapid/app_spec.rb +12 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/more_string_matchers.rb +21 -0
- data/spec/support/rapid.rb +1 -0
- data/spec/templates/app/controllers/application_controller_spec.rb +32 -0
- data/spec/templates/app/helpers/application_helper_spec.rb +32 -0
- data/spec/templates/app/mailers/test_mailer_spec.rb +22 -0
- data/spec/templates/app/views/test_mailer/test_email.text.erb_spec.rb +36 -0
- data/spec/templates/config/application_spec.rb +168 -0
- data/spec/templates/config/boot_spec.rb +17 -0
- data/spec/templates/config/cucumber.yml_spec.rb +22 -0
- data/spec/templates/config/deploy/production_spec.rb +155 -0
- data/spec/templates/config/deploy_spec.rb +156 -0
- data/spec/templates/config/environment_spec.rb +22 -0
- data/spec/templates/config/environments/development_spec.rb +50 -0
- data/spec/templates/config/environments/production_spec.rb +50 -0
- data/spec/templates/config/environments/test_spec.rb +50 -0
- data/spec/templates/config/initializers/airbrake_spec.rb +70 -0
- data/spec/templates/config/initializers/backtrace_silencers_spec.rb +17 -0
- data/spec/templates/config/initializers/email_spec.rb +106 -0
- data/spec/templates/config/initializers/mime_types_spec.rb +17 -0
- data/spec/templates/config/initializers/secret_token_spec.rb +36 -0
- data/spec/templates/config/initializers/session_store_spec.rb +36 -0
- data/spec/templates/config/initializers/wrap_parameters_spec.rb +17 -0
- data/spec/templates/config/roodi.yml_spec.rb +92 -0
- data/spec/templates/config/routes_spec.rb +36 -0
- data/spec/templates/config/schedule_spec.rb +22 -0
- data/spec/templates/config.ru_spec.rb +22 -0
- data/spec/templates/db/migrate/create_jobs_spec.rb +17 -0
- data/spec/templates/features/step_definitions/email_steps_spec.rb +17 -0
- data/spec/templates/features/step_definitions/web_steps/browsing_steps_spec.rb +17 -0
- data/spec/templates/features/step_definitions/web_steps/debug_steps_spec.rb +17 -0
- data/spec/templates/features/step_definitions/web_steps/form_steps_spec.rb +17 -0
- data/spec/templates/features/step_definitions/web_steps/step_scoper_spec.rb +17 -0
- data/spec/templates/features/support/email_spec.rb +17 -0
- data/spec/templates/features/support/env_spec.rb +56 -0
- data/spec/templates/features/support/paths_spec.rb +22 -0
- data/spec/templates/features/support/selectors_spec.rb +22 -0
- data/spec/templates/features/support/with_scope_spec.rb +17 -0
- data/spec/templates/lib/tasks/cucumber.rake_spec.rb +17 -0
- data/spec/templates/lib/tasks/test.rake_spec.rb +147 -0
- data/spec/templates/lib/tasks/test_mailer.rake_spec.rb +17 -0
- data/spec/templates/rspec_spec.rb +17 -0
- data/spec/templates/script/delayed_job_spec.rb +17 -0
- data/spec/templates/script/rails_spec.rb +17 -0
- data/spec/templates/spec/factories_spec.rb +27 -0
- data/spec/templates/spec/spec_helper_spec.rb +56 -0
- data/spec/templates/test/test_helper_spec.rb +17 -0
- data/templates/app/controllers/application_controller.rb +3 -0
- data/templates/app/helpers/application_helper.rb +2 -0
- data/templates/app/mailers/test_mailer.rb +7 -0
- data/templates/app/views/test_mailer/test_email.text.erb +4 -0
- data/templates/config/application.rb +32 -0
- data/templates/config/boot.rb +6 -0
- data/templates/config/cucumber.yml +8 -0
- data/templates/config/deploy/production.rb +37 -0
- data/templates/config/deploy.rb +43 -0
- data/templates/config/environment.rb +5 -0
- data/templates/config/environments/development.rb +35 -0
- data/templates/config/environments/production.rb +64 -0
- data/templates/config/environments/test.rb +46 -0
- data/templates/config/initializers/airbrake.rb +9 -0
- data/templates/config/initializers/backtrace_silencers.rb +7 -0
- data/templates/config/initializers/email.rb +10 -0
- data/templates/config/initializers/mime_types.rb +5 -0
- data/templates/config/initializers/secret_token.rb +7 -0
- data/templates/config/initializers/session_store.rb +8 -0
- data/templates/config/initializers/wrap_parameters.rb +14 -0
- data/templates/config/roodi.yml +13 -0
- data/templates/config/routes.rb +3 -0
- data/templates/config/schedule.rb +1 -0
- data/templates/config.ru +4 -0
- data/templates/db/migrate/create_jobs.rb +22 -0
- data/templates/features/step_definitions/email_steps.rb +194 -0
- data/templates/features/step_definitions/web_steps/browsing_steps.rb +82 -0
- data/templates/features/step_definitions/web_steps/debug_steps.rb +3 -0
- data/templates/features/step_definitions/web_steps/form_steps.rb +210 -0
- data/templates/features/step_definitions/web_steps/step_scoper.rb +9 -0
- data/templates/features/support/email.rb +2 -0
- data/templates/features/support/env.rb +55 -0
- data/templates/features/support/paths.rb +27 -0
- data/templates/features/support/selectors.rb +24 -0
- data/templates/features/support/with_scope.rb +6 -0
- data/templates/lib/tasks/cucumber.rake +65 -0
- data/templates/lib/tasks/test.rake +49 -0
- data/templates/lib/tasks/test_mailer.rake +10 -0
- data/templates/rspec +2 -0
- data/templates/script/delayed_job +5 -0
- data/templates/script/rails +6 -0
- data/templates/spec/factories.rb +1 -0
- data/templates/spec/spec_helper.rb +47 -0
- data/templates/test/test_helper.rb +13 -0
- metadata +316 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Use this to fill in an entire form with data from a table. Example:
|
|
2
|
+
#
|
|
3
|
+
# When I fill in the following:
|
|
4
|
+
# | Account Number | 5002 |
|
|
5
|
+
# | Expiry date | 2009-11-01 |
|
|
6
|
+
# | Note | Nice guy |
|
|
7
|
+
# | Wants Email? | |
|
|
8
|
+
# | Sex (select) | Male |
|
|
9
|
+
# | Accept user agrement (checkbox) | check |
|
|
10
|
+
# | Send me letters (checkbox) | uncheck |
|
|
11
|
+
# | radio 1 (radio) | choose |
|
|
12
|
+
# | Avatar (file) | avatar.png |
|
|
13
|
+
#
|
|
14
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
|
15
|
+
|
|
16
|
+
select_tag = /^(.+\S+)\s*(?:\(select\))$/
|
|
17
|
+
check_box_tag = /^(.+\S+)\s*(?:\(checkbox\))$/
|
|
18
|
+
radio_button = /^(.+\S+)\s*(?:\(radio\))$/
|
|
19
|
+
file_field = /^(.+\S+)\s*(?:\(file\))$/
|
|
20
|
+
|
|
21
|
+
fields.rows_hash.each do |name, value|
|
|
22
|
+
case name
|
|
23
|
+
when select_tag
|
|
24
|
+
When %(I select "#{value}" from "#{$1}")
|
|
25
|
+
when check_box_tag
|
|
26
|
+
case value
|
|
27
|
+
when 'check'
|
|
28
|
+
When %(I check "#{$1}")
|
|
29
|
+
when 'uncheck'
|
|
30
|
+
When %(I uncheck "#{$1}")
|
|
31
|
+
else
|
|
32
|
+
raise 'checkbox values: check|uncheck!'
|
|
33
|
+
end
|
|
34
|
+
when radio_button
|
|
35
|
+
When %{I choose "#{$1}"}
|
|
36
|
+
when file_field
|
|
37
|
+
When %{I attach the file "#{value}" to "#{$1}"}
|
|
38
|
+
else
|
|
39
|
+
When %{I fill in "#{name}" with "#{value}"}
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
|
45
|
+
fill_in(field, :with => value)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
When /^(?:|I )fill in "([^"]*)" with:$/ do |field, value|
|
|
49
|
+
fill_in(field, :with => value)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
|
53
|
+
select(value, :from => field)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
When /^(?:|I )check "([^"]*)"$/ do |field|
|
|
57
|
+
check(field)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
|
61
|
+
uncheck(field)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
|
65
|
+
choose(field)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |file, field|
|
|
69
|
+
path = File.expand_path(File.join(SUPPORT_DIR,"attachments/#{file}"))
|
|
70
|
+
raise RuntimeError, "file '#{path}' does not exists" unless File.exists?(path)
|
|
71
|
+
|
|
72
|
+
attach_file(field, path)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
|
76
|
+
with_scope(parent) do
|
|
77
|
+
field = find_field(field)
|
|
78
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
|
79
|
+
if field_value.respond_to? :should
|
|
80
|
+
field_value.should =~ /#{value}/
|
|
81
|
+
else
|
|
82
|
+
assert_match(/#{value}/, field_value)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
|
88
|
+
with_scope(parent) do
|
|
89
|
+
field = find_field(field)
|
|
90
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
|
91
|
+
if field_value.respond_to? :should_not
|
|
92
|
+
field_value.should_not =~ /#{value}/
|
|
93
|
+
else
|
|
94
|
+
assert_no_match(/#{value}/, field_value)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
|
100
|
+
with_scope(parent) do
|
|
101
|
+
field_checked = find_field(label)['checked']
|
|
102
|
+
if field_checked.respond_to? :should
|
|
103
|
+
field_checked.should be_true
|
|
104
|
+
else
|
|
105
|
+
assert field_checked
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
|
111
|
+
with_scope(parent) do
|
|
112
|
+
field_checked = find_field(label)['checked']
|
|
113
|
+
if field_checked.respond_to? :should
|
|
114
|
+
field_checked.should be_false
|
|
115
|
+
else
|
|
116
|
+
assert !field_checked
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
When /^(?:|I )press "([^"]*)"$/ do |button|
|
|
122
|
+
click_button(button)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
Then /^the select "([^"]*)" should have following options:$/ do |field, options|
|
|
126
|
+
options = options.transpose.raw
|
|
127
|
+
if options.size > 1
|
|
128
|
+
raise 'table should have only one column in this step!'
|
|
129
|
+
else
|
|
130
|
+
options = options.first
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
actual_options = find_field(field).all('option').map { |option| option.text }
|
|
134
|
+
|
|
135
|
+
if options.respond_to?(:should)
|
|
136
|
+
options.should eq(actual_options)
|
|
137
|
+
else
|
|
138
|
+
assert_equal options, actual_options
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
When /^(?:I|i) select following values from "([^"]*)":$/ do |field, values|
|
|
143
|
+
values = values.transpose.raw
|
|
144
|
+
if values.size > 1
|
|
145
|
+
raise 'table should have only one column in this step!'
|
|
146
|
+
else
|
|
147
|
+
values = values.first
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
values.each do |value|
|
|
151
|
+
select(value, :from => field)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
When /^(?:I|i) unselect following values from "([^"]*)":$/ do |field, values|
|
|
156
|
+
values = values.transpose.raw
|
|
157
|
+
if values.size > 1
|
|
158
|
+
raise 'table should have only one column in this step!'
|
|
159
|
+
else
|
|
160
|
+
values = values.first
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
values.each do |value|
|
|
164
|
+
unselect(value, :from => field)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
Then /^the following values should be selected in "([^"]*)":$/ do |select_box, values|
|
|
169
|
+
values = values.transpose.raw
|
|
170
|
+
if values.size > 1
|
|
171
|
+
raise 'table should have only one column in this step!'
|
|
172
|
+
else
|
|
173
|
+
values = values.first
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
select_box=find_field(select_box)
|
|
177
|
+
unless select_box['multiple']
|
|
178
|
+
raise "this is not multiple select box!"
|
|
179
|
+
else
|
|
180
|
+
values.each do |value|
|
|
181
|
+
if select_box.respond_to?(:should)
|
|
182
|
+
select_box.value.should include(value)
|
|
183
|
+
else
|
|
184
|
+
assert select_box.value.include?(value)
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
Then /^the following values should not be selected in "([^"]*)":$/ do |select_box, values|
|
|
191
|
+
values = values.transpose.raw
|
|
192
|
+
if values.size > 1
|
|
193
|
+
raise 'table should have only one column in this step!'
|
|
194
|
+
else
|
|
195
|
+
values = values.first
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
select_box=find_field(select_box)
|
|
199
|
+
unless select_box['multiple']
|
|
200
|
+
raise "this is not multiple select box!"
|
|
201
|
+
else
|
|
202
|
+
values.each do |value|
|
|
203
|
+
if select_box.respond_to?(:should)
|
|
204
|
+
select_box.value.should_not include(value)
|
|
205
|
+
else
|
|
206
|
+
assert !select_box.value.include?(value)
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Single-line step scoper
|
|
2
|
+
When /^(.*) within ([^:]+)$/ do |step, parent|
|
|
3
|
+
with_scope(parent) { When step }
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
# Multi-line step scoper
|
|
7
|
+
When /^(.*) within ([^:]+):$/ do |step, parent, table_or_string|
|
|
8
|
+
with_scope(parent) { When "#{step}:", table_or_string }
|
|
9
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
|
5
|
+
# files.
|
|
6
|
+
|
|
7
|
+
require 'cucumber/rails'
|
|
8
|
+
|
|
9
|
+
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
|
10
|
+
# order to ease the transition to Capybara we set the default here. If you'd
|
|
11
|
+
# prefer to use XPath just remove this line and adjust any selectors in your
|
|
12
|
+
# steps to use the XPath syntax.
|
|
13
|
+
Capybara.default_selector = :css
|
|
14
|
+
|
|
15
|
+
# By default, any exception happening in your Rails application will bubble up
|
|
16
|
+
# to Cucumber so that your scenario will fail. This is a different from how
|
|
17
|
+
# your application behaves in the production environment, where an error page will
|
|
18
|
+
# be rendered instead.
|
|
19
|
+
#
|
|
20
|
+
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
|
21
|
+
# exceptions and display an error page (just like when the app is running in production).
|
|
22
|
+
# Typical scenarios where you want to do this is when you test your error pages.
|
|
23
|
+
# There are two ways to allow Rails to rescue exceptions:
|
|
24
|
+
#
|
|
25
|
+
# 1) Tag your scenario (or feature) with @allow-rescue
|
|
26
|
+
#
|
|
27
|
+
# 2) Set the value below to true. Beware that doing this globally is not
|
|
28
|
+
# recommended as it will mask a lot of errors for you!
|
|
29
|
+
#
|
|
30
|
+
ActionController::Base.allow_rescue = false
|
|
31
|
+
|
|
32
|
+
# Remove/comment out the lines below if your app doesn't have a database.
|
|
33
|
+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
|
34
|
+
begin
|
|
35
|
+
<% if database.mongoid? %>
|
|
36
|
+
DatabaseCleaner.orm = 'mongoid'
|
|
37
|
+
DatabaseCleaner.strategy = :truncation
|
|
38
|
+
<% elsif database.active_record? %>
|
|
39
|
+
DatabaseCleaner.strategy = :transaction
|
|
40
|
+
<% end %>
|
|
41
|
+
rescue NameError
|
|
42
|
+
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
|
|
46
|
+
# See the DatabaseCleaner documentation for details. Example:
|
|
47
|
+
#
|
|
48
|
+
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
|
49
|
+
# DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
|
53
|
+
# DatabaseCleaner.strategy = :transaction
|
|
54
|
+
# end
|
|
55
|
+
#
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
<%= test.cucumber.paths.body %>
|
|
14
|
+
else
|
|
15
|
+
begin
|
|
16
|
+
page_name =~ /the (.*) page/
|
|
17
|
+
path_components = $1.split(/\s+/)
|
|
18
|
+
self.send(path_components.push('path').join('_').to_sym)
|
|
19
|
+
rescue Object => e
|
|
20
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
|
21
|
+
"Now, go and add a mapping in #{__FILE__}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
World(NavigationHelpers)
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
<%= test.cucumber.selectors.body %>
|
|
14
|
+
when /"(.+)"/
|
|
15
|
+
$1
|
|
16
|
+
|
|
17
|
+
else
|
|
18
|
+
raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
|
|
19
|
+
"Now, go and add a mapping in #{__FILE__}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
World(HtmlSelectorsHelpers)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
|
5
|
+
# files.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
|
9
|
+
|
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
|
12
|
+
|
|
13
|
+
begin
|
|
14
|
+
require 'cucumber/rake/task'
|
|
15
|
+
|
|
16
|
+
namespace :cucumber do
|
|
17
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
|
20
|
+
t.profile = 'default'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
|
24
|
+
t.binary = vendored_cucumber_bin
|
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
|
26
|
+
t.profile = 'wip'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
|
30
|
+
t.binary = vendored_cucumber_bin
|
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
|
32
|
+
t.profile = 'rerun'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
desc 'Run all features'
|
|
36
|
+
task :all => [:ok, :wip]
|
|
37
|
+
|
|
38
|
+
task :statsetup do
|
|
39
|
+
require 'rails/code_statistics'
|
|
40
|
+
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
|
41
|
+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
desc 'Alias for cucumber:ok'
|
|
45
|
+
task :cucumber => 'cucumber:ok'
|
|
46
|
+
|
|
47
|
+
task :default => :cucumber
|
|
48
|
+
|
|
49
|
+
task :features => :cucumber do
|
|
50
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
|
54
|
+
task 'db:test:prepare' do
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
task :stats => 'cucumber:statsetup'
|
|
58
|
+
rescue LoadError
|
|
59
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
|
60
|
+
task :cucumber do
|
|
61
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<% if test.roodi? %>
|
|
2
|
+
task :roodi do
|
|
3
|
+
result = system "roodi --config=config/roodi.yml app/**/*.rb"
|
|
4
|
+
exit false if result == false
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
<% end %>
|
|
8
|
+
<% if test.coverage? %>
|
|
9
|
+
namespace :rcov do
|
|
10
|
+
|
|
11
|
+
rcov_opts = '--exclude osx\/objc,cucumber.rb,cucumber\/,gems\/,spec\/,features\/ --aggregate coverage.data'
|
|
12
|
+
|
|
13
|
+
<% if test.rspec? %>
|
|
14
|
+
desc "Run all specs with rcov"
|
|
15
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
16
|
+
t.rcov = true
|
|
17
|
+
t.pattern = "./spec/**/*_spec.rb"
|
|
18
|
+
t.rcov_opts = rcov_opts
|
|
19
|
+
end
|
|
20
|
+
<% end %>
|
|
21
|
+
|
|
22
|
+
<% if test.cucumber? %>
|
|
23
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features and produce a coverage report') do |t|
|
|
24
|
+
# t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
|
26
|
+
t.profile = 'default'
|
|
27
|
+
t.rcov = true
|
|
28
|
+
t.rcov_opts = "#{rcov_opts} --failure-threshold <%= test.coverage.threshold %>"
|
|
29
|
+
end
|
|
30
|
+
<% end %>
|
|
31
|
+
|
|
32
|
+
desc "Run specs and features and produce a coverage report"
|
|
33
|
+
task :all do
|
|
34
|
+
rm "coverage.data" if File.exist?("coverage.data")
|
|
35
|
+
<% if test.rspec? %>
|
|
36
|
+
Rake::Task['rcov:spec'].invoke
|
|
37
|
+
<% end %>
|
|
38
|
+
<% if test.cucumber? %>
|
|
39
|
+
Rake::Task['rcov:cucumber'].invoke
|
|
40
|
+
<% end %>
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
<% end %>
|
|
46
|
+
namespace :test do
|
|
47
|
+
desc "<%= test.tasks_description %>"
|
|
48
|
+
task :all => <%= test.tasks %>
|
|
49
|
+
end
|
data/templates/rspec
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
|
6
|
+
require 'rails/commands'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= test.rspec.factories.body %>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
|
4
|
+
require 'rspec/rails'
|
|
5
|
+
|
|
6
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
7
|
+
# in spec/support/ and its subdirectories.
|
|
8
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
|
9
|
+
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
# == Mock Framework
|
|
12
|
+
#
|
|
13
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
|
14
|
+
#
|
|
15
|
+
# config.mock_with :mocha
|
|
16
|
+
# config.mock_with :flexmock
|
|
17
|
+
# config.mock_with :rr
|
|
18
|
+
config.mock_with :rspec
|
|
19
|
+
|
|
20
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
21
|
+
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
22
|
+
|
|
23
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
24
|
+
# examples within a transaction, remove the following line or assign false
|
|
25
|
+
# instead of true.
|
|
26
|
+
# config.use_transactional_fixtures = true
|
|
27
|
+
|
|
28
|
+
# Clean up the database
|
|
29
|
+
require 'database_cleaner'
|
|
30
|
+
config.before(:suite) do
|
|
31
|
+
<% if database.mongoid? %>
|
|
32
|
+
DatabaseCleaner.orm = 'mongoid'
|
|
33
|
+
DatabaseCleaner.strategy = :truncation
|
|
34
|
+
<% elsif database.active_record? %>
|
|
35
|
+
DatabaseCleaner.strategy = :transaction
|
|
36
|
+
<% end %>
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
config.before(:each) do
|
|
40
|
+
DatabaseCleaner.clean
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
config.after(:all) do
|
|
44
|
+
DatabaseCleaner.clean
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
|
3
|
+
require 'rails/test_help'
|
|
4
|
+
|
|
5
|
+
class ActiveSupport::TestCase
|
|
6
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
7
|
+
#
|
|
8
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
9
|
+
# -- they do not yet inherit this setting
|
|
10
|
+
fixtures :all
|
|
11
|
+
|
|
12
|
+
# Add more helper methods to be used by all tests here...
|
|
13
|
+
end
|