saphira 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +29 -0
- data/Rakefile +39 -0
- data/app/assets/images/saphira/icons/32x32/direction_up.png +0 -0
- data/app/assets/images/saphira/icons/32x32/file.png +0 -0
- data/app/assets/images/saphira/icons/32x32/folder.png +0 -0
- data/app/assets/javascripts/saphira/application.js +9 -0
- data/app/assets/javascripts/saphira/file_items.js +2 -0
- data/app/assets/stylesheets/saphira/application.css +7 -0
- data/app/assets/stylesheets/saphira/file_items.css +17 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/saphira/application_controller.rb +4 -0
- data/app/controllers/saphira/file_items_controller.rb +104 -0
- data/app/helpers/saphira/application_helper.rb +4 -0
- data/app/helpers/saphira/file_items_helper.rb +4 -0
- data/app/models/saphira/file_item.rb +83 -0
- data/app/views/layouts/saphira/application.html.erb +14 -0
- data/app/views/saphira/file_items/_form.html.erb +33 -0
- data/app/views/saphira/file_items/edit_file.html.erb +6 -0
- data/app/views/saphira/file_items/edit_folder.html.erb +6 -0
- data/app/views/saphira/file_items/index.html.erb +30 -0
- data/app/views/saphira/file_items/new_file.html.erb +5 -0
- data/app/views/saphira/file_items/new_folder.html.erb +5 -0
- data/app/views/saphira/file_items/show.html.erb +39 -0
- data/config/initializers/acts_as_taggable_on.rb +1 -0
- data/config/initializers/awesome_nested_set.rb +1 -0
- data/config/initializers/dragonfly.rb +7 -0
- data/config/initializers/exifr.rb +2 -0
- data/config/initializers/friendly_id.rb +1 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20110904170134_create_saphira_file_items.rb +23 -0
- data/db/migrate/20110904170241_acts_as_taggable_on_migration.rb +28 -0
- data/lib/saphira/engine.rb +5 -0
- data/lib/saphira/version.rb +3 -0
- data/lib/saphira.rb +4 -0
- data/lib/tasks/saphira_tasks.rake +4 -0
- data/test/dummy/Guardfile +8 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/cucumber.yml +8 -0
- data/test/dummy/config/database.yml +28 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +30 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20110904172951_create_saphira_file_items.rb +23 -0
- data/test/dummy/db/migrate/20110904172952_acts_as_taggable_on_migration.rb +28 -0
- data/test/dummy/db/schema.rb +54 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/features/manage_file_items.feature +35 -0
- data/test/dummy/features/step_definitions/file_item_steps.rb +18 -0
- data/test/dummy/features/step_definitions/web_steps.rb +211 -0
- data/test/dummy/features/support/env.rb +50 -0
- data/test/dummy/features/support/files/eos-550d-wrong-orientation.jpg +0 -0
- data/test/dummy/features/support/paths.rb +38 -0
- data/test/dummy/features/support/selectors.rb +39 -0
- data/test/dummy/lib/tasks/cucumber.rake +65 -0
- data/test/dummy/log/development.log +524 -0
- data/test/dummy/log/test.log +362 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/cucumber +10 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/system/files/development/2011/09/04/20_16_51_527_IMG_0074.JPG +0 -0
- data/test/dummy/system/files/development/2011/09/04/20_16_51_527_IMG_0074.JPG.meta +1 -0
- data/test/dummy/system/files/test/2011/09/04/20_14_52_22_eos_550d_wrong_orientation.jpg +0 -0
- data/test/dummy/system/files/test/2011/09/04/20_14_52_22_eos_550d_wrong_orientation.jpg.meta +1 -0
- data/test/dummy/tmp/cache/assets/C54/230/sprockets%2F63597bd80af49501176a9c782c200818 +0 -0
- data/test/dummy/tmp/cache/assets/C8A/C90/sprockets%2Fb0034d98e259fe21084231df778476e5 +0 -0
- data/test/dummy/tmp/cache/assets/CBB/220/sprockets%2Fe50398a56291b292932098dbaf6f60e7 +0 -0
- data/test/dummy/tmp/cache/assets/CED/3A0/sprockets%2F5598ef34994d21041804d8edaae45e75 +0 -0
- data/test/dummy/tmp/cache/assets/D0F/940/sprockets%2Fe5a0c84816880ab73280e1d7c6c6b53f +0 -0
- data/test/dummy/tmp/cache/assets/D25/A40/sprockets%2F3597585a09358e74b9addba0fc954d87 +0 -0
- data/test/dummy/tmp/cache/assets/D28/040/sprockets%2F54bad3bcb77f949259960f3f80837af9 +0 -0
- data/test/dummy/tmp/cache/assets/D8B/C20/sprockets%2F5b4cb2011e99baa41b98122dabfe94d0 +0 -0
- data/test/dummy/tmp/cache/assets/DA9/040/sprockets%2F840de459a6d1c9d87c8dcaf24f128b6c +0 -0
- data/test/dummy/tmp/cache/assets/DD1/040/sprockets%2Fd417bfb346f42b08fa70df9d17c9a4ee +0 -0
- data/test/dummy/tmp/cache/assets/DF8/F80/sprockets%2Fdda7c25be0e8e262ebc270da9775abd4 +0 -0
- data/test/dummy/tmp/cache/assets/E32/DF0/sprockets%2Fbd8fed5e48cbc136c85e9c4ab6d1e3b4 +0 -0
- data/test/dummy/tmp/dragonfly/cache/body/11/4316e3371abd942602830d5ce3e55d4ba94ec5 +0 -0
- data/test/dummy/tmp/dragonfly/cache/body/3e/f63b348d8ad48be7f3d8869f255af8d5d8b19f +8982 -0
- data/test/dummy/tmp/dragonfly/cache/body/61/e9711fd55eccdf62882cb8d127b22664f7023f +3 -0
- data/test/dummy/tmp/dragonfly/cache/body/a1/d3d5a6ed952ccf4816b4a96d4767ce9bae8164 +5 -0
- data/test/dummy/tmp/dragonfly/cache/body/c2/d1fe276d6e527c155855e99dc19d239b6d71f3 +7 -0
- data/test/dummy/tmp/dragonfly/cache/body/cb/052a86fcf83c49b8a1c5ca5f29b11ba31d4038 +17 -0
- data/test/dummy/tmp/dragonfly/cache/body/d4/ff9b03ee9e54acce72e6b793693031079eb150 +332 -0
- data/test/dummy/tmp/dragonfly/cache/meta/24/d0aebc1b6d4ac3b10caa6cfabf89b0ad8551c5 +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/37/fb962d39887389e020d58ef1f745ef1a6107cc +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/78/da9e9f151eb605b427b43e2098640de3fd4a6d +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/8a/00f63a175cfe09352e9103621040457aafc9e8 +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/a0/d65624dcf4c7e6827639f25060a3bf4bd6020d +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/ee/fe74949a8c2a0bbc077385a12944d9f98a12e0 +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/f9/67ac04386c59253bd80f4034d18af166cc5691 +0 -0
- data/test/fixtures/saphira/file_items.yml +25 -0
- data/test/functional/saphira/file_items_controller_test.rb +51 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/saphira_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- data/test/unit/helpers/saphira/file_items_helper_test.rb +6 -0
- data/test/unit/saphira/file_item_test.rb +9 -0
- metadata +276 -0
@@ -0,0 +1,211 @@
|
|
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
|
+
#
|
20
|
+
|
21
|
+
|
22
|
+
require 'uri'
|
23
|
+
require 'cgi'
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
26
|
+
|
27
|
+
module WithinHelpers
|
28
|
+
def with_scope(locator)
|
29
|
+
locator ? within(*selector_for(locator)) { yield } : yield
|
30
|
+
end
|
31
|
+
end
|
32
|
+
World(WithinHelpers)
|
33
|
+
|
34
|
+
# Single-line step scoper
|
35
|
+
When /^(.*) within (.*[^:])$/ do |step, parent|
|
36
|
+
with_scope(parent) { When step }
|
37
|
+
end
|
38
|
+
|
39
|
+
# Multi-line step scoper
|
40
|
+
When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
|
41
|
+
with_scope(parent) { When "#{step}:", table_or_string }
|
42
|
+
end
|
43
|
+
|
44
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
45
|
+
visit path_to(page_name)
|
46
|
+
end
|
47
|
+
|
48
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
49
|
+
visit path_to(page_name)
|
50
|
+
end
|
51
|
+
|
52
|
+
When /^(?:|I )press "([^"]*)"$/ do |button|
|
53
|
+
click_button(button)
|
54
|
+
end
|
55
|
+
|
56
|
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
57
|
+
click_link(link)
|
58
|
+
end
|
59
|
+
|
60
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
61
|
+
fill_in(field, :with => value)
|
62
|
+
end
|
63
|
+
|
64
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
65
|
+
fill_in(field, :with => value)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Use this to fill in an entire form with data from a table. Example:
|
69
|
+
#
|
70
|
+
# When I fill in the following:
|
71
|
+
# | Account Number | 5002 |
|
72
|
+
# | Expiry date | 2009-11-01 |
|
73
|
+
# | Note | Nice guy |
|
74
|
+
# | Wants Email? | |
|
75
|
+
#
|
76
|
+
# TODO: Add support for checkbox, select og option
|
77
|
+
# based on naming conventions.
|
78
|
+
#
|
79
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
80
|
+
fields.rows_hash.each do |name, value|
|
81
|
+
When %{I fill in "#{name}" with "#{value}"}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
86
|
+
select(value, :from => field)
|
87
|
+
end
|
88
|
+
|
89
|
+
When /^(?:|I )check "([^"]*)"$/ do |field|
|
90
|
+
check(field)
|
91
|
+
end
|
92
|
+
|
93
|
+
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
94
|
+
uncheck(field)
|
95
|
+
end
|
96
|
+
|
97
|
+
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
98
|
+
choose(field)
|
99
|
+
end
|
100
|
+
|
101
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
102
|
+
attach_file(field, File.expand_path(path))
|
103
|
+
end
|
104
|
+
|
105
|
+
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
106
|
+
if page.respond_to? :should
|
107
|
+
page.should have_content(text)
|
108
|
+
else
|
109
|
+
assert page.has_content?(text)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
114
|
+
regexp = Regexp.new(regexp)
|
115
|
+
|
116
|
+
if page.respond_to? :should
|
117
|
+
page.should have_xpath('//*', :text => regexp)
|
118
|
+
else
|
119
|
+
assert page.has_xpath?('//*', :text => regexp)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
124
|
+
if page.respond_to? :should
|
125
|
+
page.should have_no_content(text)
|
126
|
+
else
|
127
|
+
assert page.has_no_content?(text)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
132
|
+
regexp = Regexp.new(regexp)
|
133
|
+
|
134
|
+
if page.respond_to? :should
|
135
|
+
page.should have_no_xpath('//*', :text => regexp)
|
136
|
+
else
|
137
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
142
|
+
with_scope(parent) do
|
143
|
+
field = find_field(field)
|
144
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
145
|
+
if field_value.respond_to? :should
|
146
|
+
field_value.should =~ /#{value}/
|
147
|
+
else
|
148
|
+
assert_match(/#{value}/, field_value)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
154
|
+
with_scope(parent) do
|
155
|
+
field = find_field(field)
|
156
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
157
|
+
if field_value.respond_to? :should_not
|
158
|
+
field_value.should_not =~ /#{value}/
|
159
|
+
else
|
160
|
+
assert_no_match(/#{value}/, field_value)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
166
|
+
with_scope(parent) do
|
167
|
+
field_checked = find_field(label)['checked']
|
168
|
+
if field_checked.respond_to? :should
|
169
|
+
field_checked.should be_true
|
170
|
+
else
|
171
|
+
assert field_checked
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
177
|
+
with_scope(parent) do
|
178
|
+
field_checked = find_field(label)['checked']
|
179
|
+
if field_checked.respond_to? :should
|
180
|
+
field_checked.should be_false
|
181
|
+
else
|
182
|
+
assert !field_checked
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
188
|
+
current_path = URI.parse(current_url).path
|
189
|
+
if current_path.respond_to? :should
|
190
|
+
current_path.should == path_to(page_name)
|
191
|
+
else
|
192
|
+
assert_equal path_to(page_name), current_path
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
197
|
+
query = URI.parse(current_url).query
|
198
|
+
actual_params = query ? CGI.parse(query) : {}
|
199
|
+
expected_params = {}
|
200
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
201
|
+
|
202
|
+
if actual_params.respond_to? :should
|
203
|
+
actual_params.should == expected_params
|
204
|
+
else
|
205
|
+
assert_equal expected_params, actual_params
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
Then /^show me the page$/ do
|
210
|
+
save_and_open_page
|
211
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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
|
+
DatabaseCleaner.strategy = :transaction
|
36
|
+
rescue NameError
|
37
|
+
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
38
|
+
end
|
39
|
+
|
40
|
+
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
|
41
|
+
# See the DatabaseCleaner documentation for details. Example:
|
42
|
+
#
|
43
|
+
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
44
|
+
# DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
48
|
+
# DatabaseCleaner.strategy = :transaction
|
49
|
+
# end
|
50
|
+
#
|
Binary file
|
@@ -0,0 +1,38 @@
|
|
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
|
+
when /the new file_item page/
|
14
|
+
new_file_item_path
|
15
|
+
|
16
|
+
when /"([^"]*)"/
|
17
|
+
return $1
|
18
|
+
|
19
|
+
# Add more mappings here.
|
20
|
+
# Here is an example that pulls values out of the Regexp:
|
21
|
+
#
|
22
|
+
# when /^(.*)'s profile page$/i
|
23
|
+
# user_profile_path(User.find_by_login($1))
|
24
|
+
|
25
|
+
else
|
26
|
+
begin
|
27
|
+
page_name =~ /^the (.*) page$/
|
28
|
+
path_components = $1.split(/\s+/)
|
29
|
+
self.send(path_components.push('path').join('_').to_sym)
|
30
|
+
rescue NoMethodError, ArgumentError
|
31
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
32
|
+
"Now, go and add a mapping in #{__FILE__}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,39 @@
|
|
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)
|
@@ -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
|