ar-octopus 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -2
- data/ar-octopus.gemspec +70 -5
- data/lib/octopus/has_and_belongs_to_many_association.rb +1 -5
- data/lib/octopus/model.rb +6 -16
- data/lib/octopus/proxy.rb +1 -6
- data/lib/octopus/scope_proxy.rb +7 -10
- data/sample_app/.gitignore +4 -0
- data/sample_app/.rspec +1 -0
- data/sample_app/Gemfile +22 -0
- data/sample_app/Gemfile.lock +149 -0
- data/sample_app/README +3 -0
- data/sample_app/Rakefile +7 -0
- data/sample_app/app/controllers/application_controller.rb +4 -0
- data/sample_app/app/helpers/application_helper.rb +2 -0
- data/sample_app/app/models/item.rb +2 -0
- data/sample_app/app/models/user.rb +2 -0
- data/sample_app/app/views/layouts/application.html.erb +14 -0
- data/sample_app/autotest/discover.rb +2 -0
- data/sample_app/config.ru +4 -0
- data/sample_app/config/application.rb +46 -0
- data/sample_app/config/boot.rb +13 -0
- data/sample_app/config/cucumber.yml +8 -0
- data/sample_app/config/database.yml +25 -0
- data/sample_app/config/environment.rb +5 -0
- data/sample_app/config/environments/development.rb +19 -0
- data/sample_app/config/environments/production.rb +46 -0
- data/sample_app/config/environments/test.rb +32 -0
- data/sample_app/config/initializers/backtrace_silencers.rb +7 -0
- data/sample_app/config/initializers/inflections.rb +10 -0
- data/sample_app/config/initializers/mime_types.rb +5 -0
- data/sample_app/config/initializers/secret_token.rb +7 -0
- data/sample_app/config/initializers/session_store.rb +8 -0
- data/sample_app/config/locales/en.yml +5 -0
- data/sample_app/config/routes.rb +58 -0
- data/sample_app/config/shards.yml +28 -0
- data/sample_app/db/migrate/20100720172715_create_users.rb +15 -0
- data/sample_app/db/migrate/20100720172730_create_items.rb +16 -0
- data/sample_app/db/migrate/20100720210335_create_sample_users.rb +11 -0
- data/sample_app/db/schema.rb +29 -0
- data/sample_app/db/seeds.rb +16 -0
- data/sample_app/doc/README_FOR_APP +2 -0
- data/sample_app/features/migrate.feature +44 -0
- data/sample_app/features/seed.feature +15 -0
- data/sample_app/features/step_definitions/seeds_steps.rb +15 -0
- data/sample_app/features/step_definitions/web_steps.rb +219 -0
- data/sample_app/features/support/env.rb +65 -0
- data/sample_app/features/support/paths.rb +33 -0
- data/sample_app/lib/tasks/.gitkeep +0 -0
- data/sample_app/lib/tasks/cucumber.rake +53 -0
- data/sample_app/public/404.html +26 -0
- data/sample_app/public/422.html +26 -0
- data/sample_app/public/500.html +26 -0
- data/sample_app/public/favicon.ico +0 -0
- data/sample_app/public/images/rails.png +0 -0
- data/sample_app/public/index.html +279 -0
- data/sample_app/public/javascripts/application.js +2 -0
- data/sample_app/public/javascripts/controls.js +965 -0
- data/sample_app/public/javascripts/dragdrop.js +974 -0
- data/sample_app/public/javascripts/effects.js +1123 -0
- data/sample_app/public/javascripts/prototype.js +4874 -0
- data/sample_app/public/javascripts/rails.js +118 -0
- data/sample_app/public/robots.txt +5 -0
- data/sample_app/public/stylesheets/.gitkeep +0 -0
- data/sample_app/script/cucumber +10 -0
- data/sample_app/script/rails +6 -0
- data/sample_app/spec/models/item_spec.rb +5 -0
- data/sample_app/spec/models/user_spec.rb +5 -0
- data/sample_app/spec/spec_helper.rb +27 -0
- data/sample_app/test/performance/browsing_test.rb +9 -0
- data/sample_app/test/test_helper.rb +13 -0
- data/sample_app/vendor/plugins/.gitkeep +0 -0
- data/spec/config/shards.yml +16 -18
- data/spec/database_models.rb +5 -0
- data/spec/octopus/model_spec.rb +77 -14
- data/spec/octopus/proxy_spec.rb +2 -0
- data/spec/octopus/replication_specs.rb +5 -0
- metadata +72 -8
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
7
|
+
# Mayor.create(:name => 'Daley', :city => cities.first)
|
8
|
+
Octopus.using(:asia) do
|
9
|
+
User.create!(:name => "Asia User")
|
10
|
+
end
|
11
|
+
|
12
|
+
Octopus.using(:america) do
|
13
|
+
users_america = User.create([{ :name => 'America User 1' }, { :name => 'America User 2' }])
|
14
|
+
end
|
15
|
+
|
16
|
+
User.create!(:name => "Teste")
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Feature: rake db:migrate
|
2
|
+
In order move data along shards
|
3
|
+
As a developer
|
4
|
+
I want to use the rake db:migrate command
|
5
|
+
|
6
|
+
Scenario: db:migrate should work with octopus
|
7
|
+
When I run inside my Rails project "rake db:migrate" with enviroment "development"
|
8
|
+
Then the output should contain "CreateUsers: migrating - Shard: master"
|
9
|
+
Then the output should contain "CreateUsers: migrating - Shard: asia"
|
10
|
+
Then the output should contain "CreateUsers: migrating - Shard: europe"
|
11
|
+
Then the output should contain "CreateUsers: migrating - Shard: america"
|
12
|
+
|
13
|
+
Scenario: db:migrate:redo should work with octopus
|
14
|
+
When I run inside my Rails project "rake db:migrate VERSION=20100720172715" with enviroment "development"
|
15
|
+
When I run inside my Rails project "rake db:migrate VERSION=20100720172730" with enviroment "development"
|
16
|
+
When I run inside my Rails project "rake db:migrate:redo" with enviroment "development"
|
17
|
+
Then the output should contain "CreateItems: reverting - Shard: master"
|
18
|
+
Then the output should contain "CreateItems: reverting - Shard: asia"
|
19
|
+
Then the output should contain "CreateItems: reverting - Shard: europe"
|
20
|
+
Then the output should contain "CreateItems: reverting - Shard: america"
|
21
|
+
Then the output should contain "CreateItems: migrating - Shard: master"
|
22
|
+
Then the output should contain "CreateItems: migrating - Shard: asia"
|
23
|
+
Then the output should contain "CreateItems: migrating - Shard: europe"
|
24
|
+
Then the output should contain "CreateItems: migrating - Shard: america"
|
25
|
+
|
26
|
+
Scenario: db:migrate finishing the migration
|
27
|
+
When I run inside my Rails project "rake db:migrate" with enviroment "development"
|
28
|
+
Then the output should contain "CreateSampleUsers: migrating - Shard: america"
|
29
|
+
Then the output should contain "CreateSampleUsers: migrating - Shard: master"
|
30
|
+
Then the output should contain "CreateSampleUsers: migrating - Shard: asia"
|
31
|
+
Then the output should contain "CreateSampleUsers: migrating - Shard: europe"
|
32
|
+
Then the output should not contain "An error has occurred, this and all later migrations canceled:"
|
33
|
+
Then the version of "dev_env" shard should be "20100720210335"
|
34
|
+
Then the version of "america" shard should be "nil"
|
35
|
+
Then the version of "europe" shard should be "nil"
|
36
|
+
Then the version of "asia" shard should be "nil"
|
37
|
+
|
38
|
+
Scenario: after running rake db:migrate
|
39
|
+
When I run inside my Rails project "rake db:abort_if_pending_migrations" with enviroment "development"
|
40
|
+
Then the output should contain "pending migrations"
|
41
|
+
When I run inside my Rails project "rake db:migrate" with enviroment "development"
|
42
|
+
When I run inside my Rails project "rake db:abort_if_pending_migrations" with enviroment "development"
|
43
|
+
Then the output should not contain "pending migrations"
|
44
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: rake db:seed
|
2
|
+
In order to create sample records in the database
|
3
|
+
As a developer
|
4
|
+
I want to use the rake db:seed command
|
5
|
+
|
6
|
+
Scenario: db:seed should fail
|
7
|
+
When I run inside my Rails project "rake db:seed" with enviroment "development"
|
8
|
+
Then the output should contain "pending migrations"
|
9
|
+
|
10
|
+
Scenario: db:seed should work with octopus
|
11
|
+
When I run inside my Rails project "rake db:migrate" with enviroment "development"
|
12
|
+
When I run inside my Rails project "rake db:seed" with enviroment "development"
|
13
|
+
Then the "asia" shard should have one user named "Asia User"
|
14
|
+
Then the "america" shard should have one user named "America User 1"
|
15
|
+
Then the "america" shard should have one user named "America User 2"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Then /^the "([^"]*)" shard should have one user named "([^"]*)"$/ do |shard_name, user_name|
|
2
|
+
# TODO - WTF?! - Why we need to instantiate a new proxy?
|
3
|
+
Thread.current[:connection_proxy] = nil
|
4
|
+
User.using(shard_name.to_sym).where(:name => user_name).count.should == 1
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^the version of "([^"]*)" shard should be "([^"]*)"$/ do |shard_name, version|
|
8
|
+
ab = ActiveRecord::Base.using(shard_name.to_sym).connection.select_value("select * from schema_migrations order by version desc limit 1;")
|
9
|
+
version = "" if version == "nil"
|
10
|
+
ab.to_s.should == version
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I run inside my Rails project "([^"]*)" with enviroment "([^"]*)"$/ do |command, enviroment|
|
14
|
+
run(unescape("cd #{Rails.root.to_s} && RAILS_ENV=#{enviroment} #{command}"), false)
|
15
|
+
end
|
@@ -0,0 +1,219 @@
|
|
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
|
+
require 'uri'
|
9
|
+
require 'cgi'
|
10
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
11
|
+
|
12
|
+
module WithinHelpers
|
13
|
+
def with_scope(locator)
|
14
|
+
locator ? within(locator) { yield } : yield
|
15
|
+
end
|
16
|
+
end
|
17
|
+
World(WithinHelpers)
|
18
|
+
|
19
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
20
|
+
visit path_to(page_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
24
|
+
visit path_to(page_name)
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
|
28
|
+
with_scope(selector) do
|
29
|
+
click_button(button)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
|
34
|
+
with_scope(selector) do
|
35
|
+
click_link(link)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
|
40
|
+
with_scope(selector) do
|
41
|
+
fill_in(field, :with => value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
|
46
|
+
with_scope(selector) do
|
47
|
+
fill_in(field, :with => value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Use this to fill in an entire form with data from a table. Example:
|
52
|
+
#
|
53
|
+
# When I fill in the following:
|
54
|
+
# | Account Number | 5002 |
|
55
|
+
# | Expiry date | 2009-11-01 |
|
56
|
+
# | Note | Nice guy |
|
57
|
+
# | Wants Email? | |
|
58
|
+
#
|
59
|
+
# TODO: Add support for checkbox, select og option
|
60
|
+
# based on naming conventions.
|
61
|
+
#
|
62
|
+
When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
|
63
|
+
with_scope(selector) do
|
64
|
+
fields.rows_hash.each do |name, value|
|
65
|
+
When %{I fill in "#{name}" with "#{value}"}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
|
71
|
+
with_scope(selector) do
|
72
|
+
select(value, :from => field)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
77
|
+
with_scope(selector) do
|
78
|
+
check(field)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
83
|
+
with_scope(selector) do
|
84
|
+
uncheck(field)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
89
|
+
with_scope(selector) do
|
90
|
+
choose(field)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
|
95
|
+
with_scope(selector) do
|
96
|
+
attach_file(field, path)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
Then /^(?:|I )should see JSON:$/ do |expected_json|
|
101
|
+
require 'json'
|
102
|
+
expected = JSON.pretty_generate(JSON.parse(expected_json))
|
103
|
+
actual = JSON.pretty_generate(JSON.parse(response.body))
|
104
|
+
expected.should == actual
|
105
|
+
end
|
106
|
+
|
107
|
+
Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
108
|
+
with_scope(selector) do
|
109
|
+
if page.respond_to? :should
|
110
|
+
page.should have_content(text)
|
111
|
+
else
|
112
|
+
assert page.has_content?(text)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
118
|
+
regexp = Regexp.new(regexp)
|
119
|
+
with_scope(selector) do
|
120
|
+
if page.respond_to? :should
|
121
|
+
page.should have_xpath('//*', :text => regexp)
|
122
|
+
else
|
123
|
+
assert page.has_xpath?('//*', :text => regexp)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
129
|
+
with_scope(selector) do
|
130
|
+
if page.respond_to? :should
|
131
|
+
page.should have_no_content(text)
|
132
|
+
else
|
133
|
+
assert page.has_no_content?(text)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
139
|
+
regexp = Regexp.new(regexp)
|
140
|
+
with_scope(selector) do
|
141
|
+
if page.respond_to? :should
|
142
|
+
page.should have_no_xpath('//*', :text => regexp)
|
143
|
+
else
|
144
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
|
150
|
+
with_scope(selector) do
|
151
|
+
field = find_field(field)
|
152
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
153
|
+
if field_value.respond_to? :should
|
154
|
+
field_value.should =~ /#{value}/
|
155
|
+
else
|
156
|
+
assert_match(/#{value}/, field_value)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
|
162
|
+
with_scope(selector) do
|
163
|
+
field = find_field(field)
|
164
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
165
|
+
if field_value.respond_to? :should_not
|
166
|
+
field_value.should_not =~ /#{value}/
|
167
|
+
else
|
168
|
+
assert_no_match(/#{value}/, field_value)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
|
174
|
+
with_scope(selector) do
|
175
|
+
field_checked = find_field(label)['checked']
|
176
|
+
if field_checked.respond_to? :should
|
177
|
+
field_checked.should be_true
|
178
|
+
else
|
179
|
+
assert field_checked
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
|
185
|
+
with_scope(selector) do
|
186
|
+
field_checked = find_field(label)['checked']
|
187
|
+
if field_checked.respond_to? :should
|
188
|
+
field_checked.should be_false
|
189
|
+
else
|
190
|
+
assert !field_checked
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
196
|
+
current_path = URI.parse(current_url).path
|
197
|
+
if current_path.respond_to? :should
|
198
|
+
current_path.should == path_to(page_name)
|
199
|
+
else
|
200
|
+
assert_equal path_to(page_name), current_path
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
205
|
+
query = URI.parse(current_url).query
|
206
|
+
actual_params = query ? CGI.parse(query) : {}
|
207
|
+
expected_params = {}
|
208
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
209
|
+
|
210
|
+
if actual_params.respond_to? :should
|
211
|
+
actual_params.should == expected_params
|
212
|
+
else
|
213
|
+
assert_equal expected_params, actual_params
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
Then /^show me the page$/ do
|
218
|
+
save_and_open_page
|
219
|
+
end
|
@@ -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
|
+
ENV["RAILS_ENV"] ||= "test"
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
9
|
+
|
10
|
+
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
11
|
+
require 'cucumber/rails/rspec'
|
12
|
+
require 'cucumber/rails/world'
|
13
|
+
require 'cucumber/rails/active_record'
|
14
|
+
require 'cucumber/web/tableish'
|
15
|
+
|
16
|
+
require 'capybara/rails'
|
17
|
+
require 'capybara/cucumber'
|
18
|
+
require 'capybara/session'
|
19
|
+
require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
|
20
|
+
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
21
|
+
# order to ease the transition to Capybara we set the default here. If you'd
|
22
|
+
# prefer to use XPath just remove this line and adjust any selectors in your
|
23
|
+
# steps to use the XPath syntax.
|
24
|
+
Capybara.default_selector = :css
|
25
|
+
|
26
|
+
# If you set this to false, any error raised from within your app will bubble
|
27
|
+
# up to your step definition and out to cucumber unless you catch it somewhere
|
28
|
+
# on the way. You can make Rails rescue errors and render error pages on a
|
29
|
+
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
|
30
|
+
#
|
31
|
+
# If you set this to true, Rails will rescue all errors and render error
|
32
|
+
# pages, more or less in the same way your application would behave in the
|
33
|
+
# default production environment. It's not recommended to do this for all
|
34
|
+
# of your scenarios, as this makes it hard to discover errors in your application.
|
35
|
+
ActionController::Base.allow_rescue = false
|
36
|
+
|
37
|
+
# If you set this to true, each scenario will run in a database transaction.
|
38
|
+
# You can still turn off transactions on a per-scenario basis, simply tagging
|
39
|
+
# a feature or scenario with the @no-txn tag. If you are using Capybara,
|
40
|
+
# tagging with @culerity or @javascript will also turn transactions off.
|
41
|
+
#
|
42
|
+
# If you set this to false, transactions will be off for all scenarios,
|
43
|
+
# regardless of whether you use @no-txn or not.
|
44
|
+
#
|
45
|
+
# Beware that turning transactions off will leave data in your database
|
46
|
+
# after each scenario, which can lead to hard-to-debug failures in
|
47
|
+
# subsequent scenarios. If you do this, we recommend you create a Before
|
48
|
+
# block that will explicitly put your database in a known state.
|
49
|
+
Cucumber::Rails::World.use_transactional_fixtures = true
|
50
|
+
# How to clean your database when transactions are turned off. See
|
51
|
+
# http://github.com/bmabey/database_cleaner for more info.
|
52
|
+
if defined?(ActiveRecord::Base)
|
53
|
+
begin
|
54
|
+
require 'database_cleaner'
|
55
|
+
DatabaseCleaner.strategy = :truncation
|
56
|
+
rescue LoadError => ignore_if_database_cleaner_not_present
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
Before do
|
61
|
+
`rm #{Rails.root.to_s}/db/america.sqlite3`
|
62
|
+
`rm #{Rails.root.to_s}/db/asia.sqlite3`
|
63
|
+
`rm #{Rails.root.to_s}/db/development.sqlite3`
|
64
|
+
`rm #{Rails.root.to_s}/db/europe.sqlite3`
|
65
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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 Object => e
|
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)
|
File without changes
|
@@ -0,0 +1,53 @@
|
|
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
|
+
end
|
38
|
+
desc 'Alias for cucumber:ok'
|
39
|
+
task :cucumber => 'cucumber:ok'
|
40
|
+
|
41
|
+
task :default => :cucumber
|
42
|
+
|
43
|
+
task :features => :cucumber do
|
44
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
45
|
+
end
|
46
|
+
rescue LoadError
|
47
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
48
|
+
task :cucumber do
|
49
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|