moses-vanity 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -1
- data/.travis.yml +4 -2
- data/Appraisals +15 -0
- data/CHANGELOG +7 -0
- data/Gemfile +16 -19
- data/Gemfile.lock +110 -0
- data/README.rdoc +10 -9
- data/Rakefile +2 -1
- data/gemfiles/rails3.gemfile +20 -0
- data/gemfiles/rails3.gemfile.lock +135 -0
- data/gemfiles/rails31.gemfile +20 -0
- data/gemfiles/rails31.gemfile.lock +146 -0
- data/gemfiles/rails32.gemfile +20 -0
- data/gemfiles/rails32.gemfile.lock +144 -0
- data/lib/vanity/adapters/active_record_adapter.rb +6 -6
- data/lib/vanity/experiment/base.rb +4 -0
- data/lib/vanity/frameworks/rails.rb +11 -4
- data/lib/vanity/metric/active_record.rb +9 -1
- data/lib/vanity/playground.rb +2 -1
- data/lib/vanity/version.rb +1 -1
- data/test/dummy/Rakefile +7 -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 +44 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +5 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +26 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -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/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/log/server.log +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/experiment/ab_test.rb +7 -3
- data/test/experiment/base_test.rb +3 -3
- data/test/metric/active_record_test.rb +46 -16
- data/test/passenger_test.rb +4 -2
- data/test/rails_helper_test.rb +4 -2
- data/test/rails_test.rb +116 -93
- data/test/test_helper.rb +32 -10
- metadata +61 -3
data/test/experiment/ab_test.rb
CHANGED
@@ -13,7 +13,11 @@ class AbTestController < ActionController::Base
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_capture
|
16
|
-
|
16
|
+
if Rails.version.to_i == 3
|
17
|
+
render :inline=>"<%= ab_test :simple do |value| %><%= value %><% end %>"
|
18
|
+
else
|
19
|
+
render :inline=>"<% ab_test :simple do |value| %><%= value %><% end %>"
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def track
|
@@ -230,7 +234,7 @@ class AbTestTest < ActionController::TestCase
|
|
230
234
|
# -- A/B helper methods --
|
231
235
|
|
232
236
|
def test_fail_if_no_experiment
|
233
|
-
assert_raise
|
237
|
+
assert_raise Vanity::NoExperimentError do
|
234
238
|
get :test_render
|
235
239
|
end
|
236
240
|
end
|
@@ -276,7 +280,7 @@ class AbTestTest < ActionController::TestCase
|
|
276
280
|
metrics :coolness
|
277
281
|
end
|
278
282
|
responses = Array.new(100) do
|
279
|
-
@controller.send(:cookies).
|
283
|
+
@controller.send(:cookies).each{ |cookie| @controller.send(:cookies).delete(cookie.first) }
|
280
284
|
get :track
|
281
285
|
@response.body
|
282
286
|
end
|
@@ -34,7 +34,7 @@ class ExperimentTest < Test::Unit::TestCase
|
|
34
34
|
# -- Loading experiments --
|
35
35
|
|
36
36
|
def test_fails_if_cannot_load_named_experiment
|
37
|
-
assert_raises
|
37
|
+
assert_raises Vanity::NoExperimentError do
|
38
38
|
experiment(:ice_cream_flavor)
|
39
39
|
end
|
40
40
|
end
|
@@ -93,7 +93,7 @@ class ExperimentTest < Test::Unit::TestCase
|
|
93
93
|
f.write <<-RUBY
|
94
94
|
ab_test "Ice Cream Flavor" do
|
95
95
|
metrics :happiness
|
96
|
-
expects(:save)
|
96
|
+
expects(:save).at_least_once
|
97
97
|
end
|
98
98
|
RUBY
|
99
99
|
end
|
@@ -102,7 +102,7 @@ class ExperimentTest < Test::Unit::TestCase
|
|
102
102
|
|
103
103
|
def test_experiment_has_created_timestamp
|
104
104
|
new_ab_test(:ice_cream_flavor) { metrics :happiness }
|
105
|
-
|
105
|
+
assert_kind_of Time, experiment(:ice_cream_flavor).created_at
|
106
106
|
assert_in_delta experiment(:ice_cream_flavor).created_at.to_i, Time.now.to_i, 1
|
107
107
|
end
|
108
108
|
|
@@ -7,7 +7,11 @@ class Sky < ActiveRecord::Base
|
|
7
7
|
t.timestamps
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
if defined?(Rails::Railtie)
|
11
|
+
scope :high, lambda { { :conditions=>"height >= 4" } }
|
12
|
+
else
|
13
|
+
named_scope :high, lambda { { :conditions=>"height >= 4" } }
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
|
@@ -207,13 +211,24 @@ context "ActiveRecord Metric" do
|
|
207
211
|
end
|
208
212
|
|
209
213
|
test "with after_save" do
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
214
|
+
if rails3?
|
215
|
+
File.open "tmp/experiments/metrics/sky_is_limit.rb", "w" do |f|
|
216
|
+
f.write <<-RUBY
|
217
|
+
metric "Sky is limit" do
|
218
|
+
model Sky, :conditions=>["height > 3"]
|
219
|
+
Sky.after_save { |sky| track!(:sky_is_limit) if sky.height_changed? && sky.height > 3 }
|
220
|
+
end
|
221
|
+
RUBY
|
222
|
+
end
|
223
|
+
else
|
224
|
+
File.open "tmp/experiments/metrics/sky_is_limit.rb", "w" do |f|
|
225
|
+
f.write <<-RUBY
|
226
|
+
metric "Sky is limit" do
|
227
|
+
model Sky, :conditions=>["height > 3"]
|
228
|
+
Sky.after_save { |sky| track! if sky.height_changed? && sky.height > 3 }
|
229
|
+
end
|
230
|
+
RUBY
|
231
|
+
end
|
217
232
|
end
|
218
233
|
Vanity.playground.metrics
|
219
234
|
times = 0
|
@@ -228,12 +243,22 @@ context "ActiveRecord Metric" do
|
|
228
243
|
end
|
229
244
|
|
230
245
|
test "do it youself" do
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
Sky
|
235
|
-
|
236
|
-
|
246
|
+
if rails3?
|
247
|
+
File.open "tmp/experiments/metrics/sky_is_limit.rb", "w" do |f|
|
248
|
+
f.write <<-RUBY
|
249
|
+
metric "Sky is limit" do
|
250
|
+
Sky.after_save { |sky| track!(:sky_is_limit) if sky.height_changed? && sky.height > 3 }
|
251
|
+
end
|
252
|
+
RUBY
|
253
|
+
end
|
254
|
+
else
|
255
|
+
File.open "tmp/experiments/metrics/sky_is_limit.rb", "w" do |f|
|
256
|
+
f.write <<-RUBY
|
257
|
+
metric "Sky is limit" do
|
258
|
+
Sky.after_save { |sky| track! if sky.height_changed? && sky.height > 3 }
|
259
|
+
end
|
260
|
+
RUBY
|
261
|
+
end
|
237
262
|
end
|
238
263
|
Vanity.playground.metrics
|
239
264
|
(1..5).each do |height|
|
@@ -271,7 +296,12 @@ context "ActiveRecord Metric" do
|
|
271
296
|
|
272
297
|
teardown do
|
273
298
|
Sky.delete_all
|
274
|
-
|
275
|
-
|
299
|
+
if rails3?
|
300
|
+
Sky.reset_callbacks(:create)
|
301
|
+
Sky.reset_callbacks(:save)
|
302
|
+
else
|
303
|
+
Sky.after_create.clear
|
304
|
+
Sky.after_save.clear
|
305
|
+
end
|
276
306
|
end
|
277
307
|
end
|
data/test/passenger_test.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "test/test_helper"
|
2
|
-
require "phusion_passenger/spawn_manager"
|
3
2
|
|
3
|
+
#not supported for rails3
|
4
|
+
unless defined?(Rails::Railtie)
|
5
|
+
require "phusion_passenger/spawn_manager"
|
4
6
|
class PassengerTest < Test::Unit::TestCase
|
5
7
|
def setup
|
6
8
|
super
|
@@ -39,5 +41,5 @@ class PassengerTest < Test::Unit::TestCase
|
|
39
41
|
@server.stop
|
40
42
|
File.unlink "test/myapp/config/vanity.yml"
|
41
43
|
end
|
42
|
-
|
44
|
+
end
|
43
45
|
end
|
data/test/rails_helper_test.rb
CHANGED
@@ -27,10 +27,12 @@ class RailsHelperTest < ActionView::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_vanity_track_url_for_returns_url_with_identity_and_metrics
|
30
|
-
|
30
|
+
self.expects(:url_for).with(:controller => "controller", :action => "action", :_identity => '123', :_track => :sugar_high)
|
31
|
+
vanity_track_url_for("123", :sugar_high, :controller => "controller", :action => "action")
|
31
32
|
end
|
32
33
|
|
33
34
|
def test_vanity_tracking_image
|
34
|
-
|
35
|
+
self.expects(:url_for).with(:controller => :vanity, :action => :image, :_identity => '123', :_track => :sugar_high).returns("/url")
|
36
|
+
assert_equal image_tag("/url", :width => "1px", :height => "1px", :alt => ""), vanity_tracking_image("123", :sugar_high, options = {})
|
35
37
|
end
|
36
38
|
end
|
data/test/rails_test.rb
CHANGED
@@ -6,10 +6,15 @@ class UseVanityController < ActionController::Base
|
|
6
6
|
def index
|
7
7
|
render :text=>ab_test(:pie_or_cake)
|
8
8
|
end
|
9
|
+
|
10
|
+
def js
|
11
|
+
ab_test(:pie_or_cake)
|
12
|
+
render :inline => "<%= vanity_js -%>"
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
# Pages accessible to everyone, e.g. sign in, community search.
|
12
|
-
class
|
17
|
+
class UseVanityControllerTest < ActionController::TestCase
|
13
18
|
tests UseVanityController
|
14
19
|
|
15
20
|
def setup
|
@@ -26,6 +31,12 @@ class UseVanityTest < ActionController::TestCase
|
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
34
|
+
def test_render_js_for_tests
|
35
|
+
Vanity.playground.use_js!
|
36
|
+
get :js
|
37
|
+
assert_match /script.*e=pie_or_cake.*script/m, @response.body
|
38
|
+
end
|
39
|
+
|
29
40
|
def test_chooses_sets_alternatives_for_rails_tests
|
30
41
|
experiment(:pie_or_cake).chooses(true)
|
31
42
|
get :index
|
@@ -39,9 +50,11 @@ class UseVanityTest < ActionController::TestCase
|
|
39
50
|
|
40
51
|
def test_vanity_cookie_is_persistent
|
41
52
|
get :index
|
42
|
-
|
43
|
-
|
44
|
-
|
53
|
+
cookie = @response["Set-Cookie"].to_s
|
54
|
+
assert_match /vanity_id=[a-f0-9]{32};/, cookie
|
55
|
+
expires = cookie[/expires=(.*)(;|$)/, 1]
|
56
|
+
assert expires
|
57
|
+
assert_in_delta Time.parse(expires), Time.now + 1.month, 1.day
|
45
58
|
end
|
46
59
|
|
47
60
|
def test_vanity_cookie_default_id
|
@@ -130,7 +143,7 @@ class UseVanityTest < ActionController::TestCase
|
|
130
143
|
|
131
144
|
def test_cookie_domain_from_rails_configuration
|
132
145
|
get :index
|
133
|
-
|
146
|
+
assert_match /domain=.foo.bar/, @response["Set-Cookie"] if ::Rails.respond_to?(:application)
|
134
147
|
end
|
135
148
|
|
136
149
|
# -- Load path --
|
@@ -161,100 +174,139 @@ $stdout << Vanity.playground.load_path
|
|
161
174
|
|
162
175
|
# -- Connection configuration --
|
163
176
|
|
164
|
-
|
165
|
-
|
177
|
+
if ENV['DB'] == 'redis'
|
178
|
+
def test_default_connection
|
179
|
+
assert_equal "redis://127.0.0.1:6379/0", load_rails(<<-RB)
|
166
180
|
initializer.after_initialize
|
167
181
|
$stdout << Vanity.playground.connection
|
168
|
-
|
169
|
-
|
182
|
+
RB
|
183
|
+
end
|
170
184
|
|
171
|
-
|
172
|
-
|
185
|
+
def test_connection_from_string
|
186
|
+
assert_equal "redis://192.168.1.1:6379/5", load_rails(<<-RB)
|
173
187
|
Vanity.playground.establish_connection "redis://192.168.1.1:6379/5"
|
174
188
|
initializer.after_initialize
|
175
189
|
$stdout << Vanity.playground.connection
|
176
|
-
|
177
|
-
|
190
|
+
RB
|
191
|
+
end
|
178
192
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
193
|
+
def test_connection_from_yaml
|
194
|
+
FileUtils.mkpath "tmp/config"
|
195
|
+
ENV["RAILS_ENV"] = "production"
|
196
|
+
File.open("tmp/config/vanity.yml", "w") do |io|
|
197
|
+
io.write <<-YML
|
184
198
|
production:
|
185
199
|
adapter: redis
|
186
200
|
host: somehost
|
187
201
|
database: 15
|
188
|
-
|
202
|
+
YML
|
203
|
+
end
|
204
|
+
assert_equal "redis://somehost:6379/15", load_rails(<<-RB)
|
205
|
+
initializer.after_initialize
|
206
|
+
$stdout << Vanity.playground.connection
|
207
|
+
RB
|
208
|
+
ensure
|
209
|
+
File.unlink "tmp/config/vanity.yml"
|
189
210
|
end
|
190
|
-
|
211
|
+
|
212
|
+
def test_connection_from_yaml_url
|
213
|
+
FileUtils.mkpath "tmp/config"
|
214
|
+
ENV["RAILS_ENV"] = "production"
|
215
|
+
File.open("tmp/config/vanity.yml", "w") do |io|
|
216
|
+
io.write <<-YML
|
217
|
+
production: redis://somehost/15
|
218
|
+
YML
|
219
|
+
end
|
220
|
+
assert_equal "redis://somehost:6379/15", load_rails(<<-RB)
|
191
221
|
initializer.after_initialize
|
192
222
|
$stdout << Vanity.playground.connection
|
193
|
-
|
194
|
-
|
195
|
-
|
223
|
+
RB
|
224
|
+
ensure
|
225
|
+
File.unlink "tmp/config/vanity.yml"
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_connection_from_yaml_with_erb
|
229
|
+
FileUtils.mkpath "tmp/config"
|
230
|
+
ENV["RAILS_ENV"] = "production"
|
231
|
+
# Pass storage URL through environment like heroku does
|
232
|
+
ENV["REDIS_URL"] = "redis://somehost:6379/15"
|
233
|
+
File.open("tmp/config/vanity.yml", "w") do |io|
|
234
|
+
io.write <<-YML
|
235
|
+
production: <%= ENV['REDIS_URL'] %>
|
236
|
+
YML
|
237
|
+
end
|
238
|
+
assert_equal "redis://somehost:6379/15", load_rails(<<-RB)
|
239
|
+
initializer.after_initialize
|
240
|
+
$stdout << Vanity.playground.connection
|
241
|
+
RB
|
242
|
+
ensure
|
243
|
+
File.unlink "tmp/config/vanity.yml"
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_connection_from_redis_yml
|
247
|
+
FileUtils.mkpath "tmp/config"
|
248
|
+
yml = File.open("tmp/config/redis.yml", "w")
|
249
|
+
yml << "production: internal.local:6379\n"
|
250
|
+
yml.flush
|
251
|
+
assert_equal "redis://internal.local:6379/0", load_rails(<<-RB)
|
252
|
+
initializer.after_initialize
|
253
|
+
$stdout << Vanity.playground.connection
|
254
|
+
RB
|
255
|
+
ensure
|
256
|
+
File.unlink yml.path
|
257
|
+
end
|
258
|
+
|
259
|
+
|
196
260
|
end
|
197
261
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
262
|
+
if ENV['DB'] == 'mongo'
|
263
|
+
def test_mongo_connection_from_yaml
|
264
|
+
FileUtils.mkpath "tmp/config"
|
265
|
+
File.open("tmp/config/vanity.yml", "w") do |io|
|
266
|
+
io.write <<-YML
|
202
267
|
mongodb:
|
203
268
|
adapter: mongodb
|
204
269
|
host: localhost
|
205
270
|
port: 27017
|
206
271
|
database: vanity_test
|
207
|
-
|
208
|
-
|
272
|
+
YML
|
273
|
+
end
|
209
274
|
|
210
|
-
|
275
|
+
assert_equal "mongodb://localhost:27017/vanity_test", load_rails(<<-RB, "mongodb")
|
211
276
|
initializer.after_initialize
|
212
277
|
$stdout << Vanity.playground.connection
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
278
|
+
RB
|
279
|
+
ensure
|
280
|
+
File.unlink "tmp/config/vanity.yml"
|
281
|
+
end
|
217
282
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
283
|
+
unless ENV['CI'] == 'true'
|
284
|
+
def test_mongodb_replica_set_connection
|
285
|
+
FileUtils.mkpath "tmp/config"
|
286
|
+
File.open("tmp/config/vanity.yml", "w") do |io|
|
287
|
+
io.write <<-YML
|
222
288
|
mongodb:
|
223
289
|
adapter: mongodb
|
224
290
|
hosts:
|
225
291
|
- localhost
|
226
292
|
port: 27017
|
227
293
|
database: vanity_test
|
228
|
-
|
229
|
-
|
294
|
+
YML
|
295
|
+
end
|
230
296
|
|
231
|
-
|
297
|
+
assert_equal "mongodb://localhost:27017/vanity_test", load_rails(<<-RB, "mongodb")
|
232
298
|
initializer.after_initialize
|
233
299
|
$stdout << Vanity.playground.connection
|
234
|
-
|
300
|
+
RB
|
235
301
|
|
236
|
-
|
302
|
+
assert_equal "Mongo::ReplSetConnection", load_rails(<<-RB, "mongodb")
|
237
303
|
initializer.after_initialize
|
238
304
|
$stdout << Vanity.playground.connection.mongo.class
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
def test_connection_from_yaml_url
|
245
|
-
FileUtils.mkpath "tmp/config"
|
246
|
-
ENV["RAILS_ENV"] = "production"
|
247
|
-
File.open("tmp/config/vanity.yml", "w") do |io|
|
248
|
-
io.write <<-YML
|
249
|
-
production: redis://somehost/15
|
250
|
-
YML
|
305
|
+
RB
|
306
|
+
ensure
|
307
|
+
File.unlink "tmp/config/vanity.yml"
|
308
|
+
end
|
251
309
|
end
|
252
|
-
assert_equal "redis://somehost:6379/15", load_rails(<<-RB)
|
253
|
-
initializer.after_initialize
|
254
|
-
$stdout << Vanity.playground.connection
|
255
|
-
RB
|
256
|
-
ensure
|
257
|
-
File.unlink "tmp/config/vanity.yml"
|
258
310
|
end
|
259
311
|
|
260
312
|
def test_connection_from_yaml_missing
|
@@ -273,37 +325,6 @@ $stdout << (Vanity.playground.connection rescue $!.message)
|
|
273
325
|
File.unlink "tmp/config/vanity.yml"
|
274
326
|
end
|
275
327
|
|
276
|
-
def test_connection_from_yaml_with_erb
|
277
|
-
FileUtils.mkpath "tmp/config"
|
278
|
-
ENV["RAILS_ENV"] = "production"
|
279
|
-
# Pass storage URL through environment like heroku does
|
280
|
-
ENV["REDIS_URL"] = "redis://somehost:6379/15"
|
281
|
-
File.open("tmp/config/vanity.yml", "w") do |io|
|
282
|
-
io.write <<-YML
|
283
|
-
production: <%= ENV['REDIS_URL'] %>
|
284
|
-
YML
|
285
|
-
end
|
286
|
-
assert_equal "redis://somehost:6379/15", load_rails(<<-RB)
|
287
|
-
initializer.after_initialize
|
288
|
-
$stdout << Vanity.playground.connection
|
289
|
-
RB
|
290
|
-
ensure
|
291
|
-
File.unlink "tmp/config/vanity.yml"
|
292
|
-
end
|
293
|
-
|
294
|
-
def test_connection_from_redis_yml
|
295
|
-
FileUtils.mkpath "tmp/config"
|
296
|
-
yml = File.open("tmp/config/redis.yml", "w")
|
297
|
-
yml << "production: internal.local:6379\n"
|
298
|
-
yml.flush
|
299
|
-
assert_equal "redis://internal.local:6379/0", load_rails(<<-RB)
|
300
|
-
initializer.after_initialize
|
301
|
-
$stdout << Vanity.playground.connection
|
302
|
-
RB
|
303
|
-
ensure
|
304
|
-
File.unlink yml.path
|
305
|
-
end
|
306
|
-
|
307
328
|
def test_collection_from_vanity_yaml
|
308
329
|
FileUtils.mkpath "tmp/config"
|
309
330
|
File.open("tmp/config/vanity.yml", "w") do |io|
|
@@ -384,6 +405,8 @@ require "vanity"
|
|
384
405
|
|
385
406
|
def teardown
|
386
407
|
super
|
387
|
-
|
408
|
+
if !rails3?
|
409
|
+
UseVanityController.send(:filter_chain).clear
|
410
|
+
end
|
388
411
|
end
|
389
412
|
end
|
data/test/test_helper.rb
CHANGED
@@ -4,21 +4,40 @@ $LOAD_PATH.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
|
4
4
|
ENV["RACK_ENV"] = "test"
|
5
5
|
ENV["DB"] ||= "redis"
|
6
6
|
|
7
|
-
RAILS_ROOT = File.expand_path("..")
|
8
7
|
require "test/unit"
|
9
8
|
require "mocha"
|
10
9
|
require "action_controller"
|
11
10
|
require "action_controller/test_case"
|
12
11
|
require "action_view/test_case"
|
13
12
|
require "active_record"
|
14
|
-
|
15
|
-
|
16
|
-
require "
|
13
|
+
|
14
|
+
begin
|
15
|
+
require "rails"
|
16
|
+
rescue LoadError
|
17
|
+
end
|
18
|
+
|
19
|
+
if defined?(Rails::Railtie)
|
20
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
21
|
+
require "rails/test_help"
|
22
|
+
else
|
23
|
+
RAILS_ROOT = File.expand_path("..")
|
24
|
+
require "initializer"
|
25
|
+
Rails.configuration = Rails::Configuration.new
|
26
|
+
|
27
|
+
ActionController::Routing::Routes.draw do |map|
|
28
|
+
map.connect ':controller/:action/:id'
|
29
|
+
end
|
30
|
+
require "phusion_passenger/events"
|
31
|
+
end
|
32
|
+
|
17
33
|
require "lib/vanity"
|
18
34
|
require "timecop"
|
19
35
|
require "webmock/test_unit"
|
20
|
-
require "ruby-debug"
|
21
36
|
|
37
|
+
#Do to load order differences in Rails boot and test requires we have to manually
|
38
|
+
#require these
|
39
|
+
require 'vanity/frameworks/rails'
|
40
|
+
Vanity::Rails.load!
|
22
41
|
|
23
42
|
if $VERBOSE
|
24
43
|
$logger = Logger.new(STDOUT)
|
@@ -40,6 +59,9 @@ class Test::Unit::TestCase
|
|
40
59
|
"mock"=>"mock:/"
|
41
60
|
}[ENV["DB"]] or raise "No support yet for #{ENV["DB"]}"
|
42
61
|
|
62
|
+
def rails3?
|
63
|
+
defined?(Rails::Railtie)
|
64
|
+
end
|
43
65
|
|
44
66
|
def setup
|
45
67
|
FileUtils.mkpath "tmp/experiments/metrics"
|
@@ -102,13 +124,13 @@ class Test::Unit::TestCase
|
|
102
124
|
|
103
125
|
end
|
104
126
|
|
105
|
-
ActionController::Routing::Routes.draw do |map|
|
106
|
-
map.connect ':controller/:action/:id'
|
107
|
-
end
|
108
|
-
|
109
127
|
|
128
|
+
if ENV["DB"] == "postgres"
|
129
|
+
ActiveRecord::Base.establish_connection :adapter=>"postgresql", :database=>"vanity_test"
|
130
|
+
else
|
131
|
+
ActiveRecord::Base.establish_connection :adapter=>"mysql", :database=>"vanity_test"
|
132
|
+
end
|
110
133
|
ActiveRecord::Base.logger = $logger
|
111
|
-
ActiveRecord::Base.establish_connection :adapter=>"mysql", :database=>"vanity_test"
|
112
134
|
|
113
135
|
if ENV["DB"] == "mysql" || ENV["DB"] == "postgres"
|
114
136
|
require "generators/templates/vanity_migration"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: moses-vanity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.8.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Assaf Arkin
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-04-14 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -49,8 +49,10 @@ files:
|
|
49
49
|
- .gitignore
|
50
50
|
- .rvmrc
|
51
51
|
- .travis.yml
|
52
|
+
- Appraisals
|
52
53
|
- CHANGELOG
|
53
54
|
- Gemfile
|
55
|
+
- Gemfile.lock
|
54
56
|
- MIT-LICENSE
|
55
57
|
- README.rdoc
|
56
58
|
- Rakefile
|
@@ -80,6 +82,12 @@ files:
|
|
80
82
|
- doc/metrics.textile
|
81
83
|
- doc/rails.textile
|
82
84
|
- doc/site.js
|
85
|
+
- gemfiles/rails3.gemfile
|
86
|
+
- gemfiles/rails3.gemfile.lock
|
87
|
+
- gemfiles/rails31.gemfile
|
88
|
+
- gemfiles/rails31.gemfile.lock
|
89
|
+
- gemfiles/rails32.gemfile
|
90
|
+
- gemfiles/rails32.gemfile.lock
|
83
91
|
- generators/templates/vanity_migration.rb
|
84
92
|
- generators/vanity_generator.rb
|
85
93
|
- lib/generators/templates/vanity_migration.rb
|
@@ -118,6 +126,31 @@ files:
|
|
118
126
|
- lib/vanity/templates/vanity.js
|
119
127
|
- lib/vanity/version.rb
|
120
128
|
- test/adapters/redis_adapter_test.rb
|
129
|
+
- test/dummy/Rakefile
|
130
|
+
- test/dummy/app/controllers/application_controller.rb
|
131
|
+
- test/dummy/app/helpers/application_helper.rb
|
132
|
+
- test/dummy/app/views/layouts/application.html.erb
|
133
|
+
- test/dummy/config.ru
|
134
|
+
- test/dummy/config/application.rb
|
135
|
+
- test/dummy/config/boot.rb
|
136
|
+
- test/dummy/config/database.yml
|
137
|
+
- test/dummy/config/environment.rb
|
138
|
+
- test/dummy/config/environments/development.rb
|
139
|
+
- test/dummy/config/environments/production.rb
|
140
|
+
- test/dummy/config/environments/test.rb
|
141
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
142
|
+
- test/dummy/config/initializers/inflections.rb
|
143
|
+
- test/dummy/config/initializers/mime_types.rb
|
144
|
+
- test/dummy/config/initializers/secret_token.rb
|
145
|
+
- test/dummy/config/initializers/session_store.rb
|
146
|
+
- test/dummy/config/locales/en.yml
|
147
|
+
- test/dummy/config/routes.rb
|
148
|
+
- test/dummy/log/development.log
|
149
|
+
- test/dummy/log/production.log
|
150
|
+
- test/dummy/log/server.log
|
151
|
+
- test/dummy/public/favicon.ico
|
152
|
+
- test/dummy/public/stylesheets/.gitkeep
|
153
|
+
- test/dummy/script/rails
|
121
154
|
- test/experiment/ab_test.rb
|
122
155
|
- test/experiment/base_test.rb
|
123
156
|
- test/experiments/age_and_zipcode.rb
|
@@ -149,7 +182,7 @@ licenses: []
|
|
149
182
|
post_install_message: To get started run vanity --help
|
150
183
|
rdoc_options:
|
151
184
|
- --title
|
152
|
-
- Vanity 1.
|
185
|
+
- Vanity 1.8.0
|
153
186
|
- --main
|
154
187
|
- README.rdoc
|
155
188
|
- --webcvs
|
@@ -177,6 +210,31 @@ specification_version: 3
|
|
177
210
|
summary: Experience Driven Development framework for Ruby
|
178
211
|
test_files:
|
179
212
|
- test/adapters/redis_adapter_test.rb
|
213
|
+
- test/dummy/Rakefile
|
214
|
+
- test/dummy/app/controllers/application_controller.rb
|
215
|
+
- test/dummy/app/helpers/application_helper.rb
|
216
|
+
- test/dummy/app/views/layouts/application.html.erb
|
217
|
+
- test/dummy/config.ru
|
218
|
+
- test/dummy/config/application.rb
|
219
|
+
- test/dummy/config/boot.rb
|
220
|
+
- test/dummy/config/database.yml
|
221
|
+
- test/dummy/config/environment.rb
|
222
|
+
- test/dummy/config/environments/development.rb
|
223
|
+
- test/dummy/config/environments/production.rb
|
224
|
+
- test/dummy/config/environments/test.rb
|
225
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
226
|
+
- test/dummy/config/initializers/inflections.rb
|
227
|
+
- test/dummy/config/initializers/mime_types.rb
|
228
|
+
- test/dummy/config/initializers/secret_token.rb
|
229
|
+
- test/dummy/config/initializers/session_store.rb
|
230
|
+
- test/dummy/config/locales/en.yml
|
231
|
+
- test/dummy/config/routes.rb
|
232
|
+
- test/dummy/log/development.log
|
233
|
+
- test/dummy/log/production.log
|
234
|
+
- test/dummy/log/server.log
|
235
|
+
- test/dummy/public/favicon.ico
|
236
|
+
- test/dummy/public/stylesheets/.gitkeep
|
237
|
+
- test/dummy/script/rails
|
180
238
|
- test/experiment/ab_test.rb
|
181
239
|
- test/experiment/base_test.rb
|
182
240
|
- test/experiments/age_and_zipcode.rb
|