mongodb_logger 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.rvmrc +1 -1
- data/.travis.yml +5 -4
- data/Appraisals +9 -0
- data/CHANGELOG.md +20 -3
- data/README.md +58 -35
- data/Rakefile +33 -96
- data/app/assets/javascripts/analytics.js.coffee +5 -4
- data/app/assets/javascripts/logs.js.coffee +11 -11
- data/app/assets/javascripts/mongodb_logger.js +2 -1
- data/app/assets/javascripts/vendors/jquery-1.9.1.min.js +5 -0
- data/app/assets/javascripts/vendors/jquery.pjax.min.js +15 -13
- data/app/assets/javascripts/vendors/mustache.min.js +10 -0
- data/app/assets/stylesheets/layout.css +20 -15
- data/app/assets/stylesheets/mongodb_logger.css +0 -3
- data/bin/mongodb_logger_web +1 -2
- data/features/rails.feature +20 -8
- data/features/step_definitions/mongodb_logger_web_steps.rb +2 -3
- data/features/step_definitions/rails_application_steps.rb +84 -58
- data/features/step_definitions/rake_steps.rb +10 -0
- data/features/support/aruba.rb +5 -0
- data/features/support/env.rb +11 -5
- data/features/support/rails.rb +55 -67
- data/gemfiles/rails31.gemfile +8 -0
- data/gemfiles/rails32.gemfile +8 -0
- data/lib/mongodb_logger.rb +10 -3
- data/lib/mongodb_logger/adapters/base.rb +5 -1
- data/lib/mongodb_logger/adapters/mongo.rb +17 -13
- data/lib/mongodb_logger/adapters/moped.rb +17 -11
- data/lib/mongodb_logger/capistrano.rb +8 -0
- data/lib/mongodb_logger/logger.rb +13 -26
- data/lib/mongodb_logger/rack_middleware.rb +24 -0
- data/lib/mongodb_logger/railtie.rb +4 -4
- data/lib/mongodb_logger/server.rb +43 -68
- data/lib/mongodb_logger/server/helpers.rb +5 -0
- data/lib/mongodb_logger/server/{content_for.rb → helpers/content_for.rb} +0 -0
- data/lib/mongodb_logger/server/helpers/mustache_helpers.rb +66 -0
- data/lib/mongodb_logger/server/{partials.rb → helpers/partials.rb} +0 -0
- data/lib/mongodb_logger/server/{sprokets.rb → helpers/sprokets.rb} +4 -4
- data/lib/mongodb_logger/server/{view_helpers.rb → helpers/view_helpers.rb} +22 -38
- data/lib/mongodb_logger/server/model.rb +4 -0
- data/lib/mongodb_logger/server/model/additional_filter.rb +15 -23
- data/lib/mongodb_logger/server/model/analytic.rb +24 -32
- data/lib/mongodb_logger/server/model/base.rb +21 -0
- data/lib/mongodb_logger/server/model/filter.rb +12 -20
- data/lib/mongodb_logger/server/mustache/logs/info.rb +15 -0
- data/lib/mongodb_logger/server/templates/logs/info.mustache +25 -0
- data/lib/mongodb_logger/server/views/layout.erb +28 -26
- data/lib/mongodb_logger/server/views/shared/_log.erb +1 -1
- data/lib/mongodb_logger/server/views/shared/_tabs.erb +2 -2
- data/lib/mongodb_logger/server/views/shared/layout/_mustache.erb +6 -0
- data/lib/mongodb_logger/server/views/show_log.erb +2 -2
- data/lib/mongodb_logger/server_config.rb +4 -4
- data/lib/mongodb_logger/utils/migrate.rb +50 -0
- data/lib/mongodb_logger/utils/progressbar.rb +79 -0
- data/lib/mongodb_logger/version.rb +1 -1
- data/mongodb_logger.gemspec +15 -8
- data/{test/config/samples → spec/factories/config}/database.yml +0 -0
- data/{test/config/samples → spec/factories/config}/database_no_file_logging.yml +0 -0
- data/{test/config/samples → spec/factories/config}/database_replica_set.yml +0 -0
- data/{test/config/samples → spec/factories/config}/database_with_auth.yml +0 -0
- data/spec/factories/config/database_with_capsize.yml +9 -0
- data/{test/config/samples → spec/factories/config}/database_with_collection.yml +0 -0
- data/{test/config/samples → spec/factories/config}/database_with_url.yml +0 -0
- data/{test/config/samples → spec/factories/config}/mongodb_logger.yml +0 -0
- data/{test/config/samples → spec/factories/config}/mongoid.yml +0 -0
- data/{test/config/samples → spec/factories/config}/server_config.yml +0 -0
- data/spec/javascripts/support/jasmine.yml +1 -5
- data/spec/mongodb_logger_spec.rb +257 -0
- data/spec/rails_spec/controllers/tests_controller_spec_rails.rb +128 -0
- data/spec/rails_spec/spec_helper_rails.rb +13 -0
- data/spec/spec_helper.rb +17 -0
- data/{test/test_helper.rb → spec/support/mongodb_logger_helper.rb} +44 -63
- data/spec/support/mongodb_logger_macros.rb +22 -0
- data/spec/support/rails.rb +40 -0
- data/spec/utils/migrate_spec.rb +32 -0
- data/{lib/tasks → tasks}/mongodb_logger.rake +14 -6
- metadata +198 -78
- data/SUPPORTED_RAILS_VERSIONS +0 -16
- data/TESTING.md +0 -24
- data/app/assets/javascripts/vendors/jquery-1.8.3.min.js +0 -2
- data/features/support/terminal.rb +0 -95
- data/lib/mongodb_logger/server/views/shared/_log_info.erb +0 -27
- data/test/Gemfile_tests +0 -9
- data/test/active_record.rb +0 -13
- data/test/log/.gitkeep +0 -0
- data/test/rails.rb +0 -22
- data/test/rails/app/controllers/order_controller.rb +0 -23
- data/test/rails/test/functional/order_controller_test.rb +0 -116
- data/test/rails/test/test_helper.rb +0 -10
- data/test/shoulda_macros/log_macros.rb +0 -13
- data/test/test.sh +0 -7
- data/test/unit/mongodb_logger_replica_test.rb +0 -56
- data/test/unit/mongodb_logger_test.rb +0 -307
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm ruby-
|
1
|
+
rvm ruby-2.0.0-p0@mongodb_logger_gems --create
|
data/.travis.yml
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
before_install:
|
3
|
-
- gem install bundler --pre
|
4
3
|
- "export DISPLAY=:99.0"
|
5
4
|
- "sh -e /etc/init.d/xvfb start"
|
6
|
-
|
5
|
+
before_script:
|
6
|
+
- bundle exec rake appraisal:install
|
7
7
|
services:
|
8
8
|
- mongodb
|
9
9
|
rvm:
|
10
10
|
- 1.9.2
|
11
11
|
- 1.9.3
|
12
|
+
- 2.0.0
|
12
13
|
- jruby-19mode
|
14
|
+
- rbx-19mode
|
13
15
|
- ruby-head
|
14
16
|
- jruby-head
|
15
17
|
notifications:
|
@@ -18,8 +20,7 @@ branches:
|
|
18
20
|
only:
|
19
21
|
- master
|
20
22
|
- development
|
21
|
-
- adapters
|
22
23
|
matrix:
|
23
24
|
allow_failures:
|
24
25
|
- rvm: ruby-head
|
25
|
-
- rvm: jruby-head
|
26
|
+
- rvm: jruby-head
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## v0.5.0
|
2
|
+
|
3
|
+
* Moved to new rspec and cucumber testing, fixed testing in travis
|
4
|
+
* Added migration task for changed capped collection size ([#49](https://github.com/le0pard/mongodb_logger/issues/49))
|
5
|
+
* Moved some part of web ui on mustache templates (now no need load info from server for right info tab)
|
6
|
+
* Change dependency from json to multi\_json gem
|
7
|
+
* Fix js problems on web page
|
8
|
+
* Cleanup and DRY the code
|
9
|
+
|
10
|
+
## v0.4.2
|
11
|
+
|
12
|
+
* Fix problem with session keys (keys with dots is invalid for BSON)
|
13
|
+
|
14
|
+
## v0.4.1
|
15
|
+
|
16
|
+
* One gem for jruby and MRI
|
17
|
+
|
1
18
|
## v0.4.0
|
2
19
|
|
3
20
|
* Support adapters: mongo and moped
|
@@ -7,7 +24,7 @@
|
|
7
24
|
|
8
25
|
## v0.3.3
|
9
26
|
|
10
|
-
* Mount assets separately or compile it by rake task
|
27
|
+
* Mount assets separately or compile it by rake task
|
11
28
|
* Capistrano recipe for compiling assets
|
12
29
|
|
13
30
|
## v0.3.2
|
@@ -54,7 +71,7 @@
|
|
54
71
|
|
55
72
|
## v0.2.2
|
56
73
|
|
57
|
-
* Fix set custom collection in config and add tests on it
|
74
|
+
* Fix set custom collection in config and add tests on it
|
58
75
|
|
59
76
|
## v0.2.1
|
60
77
|
|
@@ -62,4 +79,4 @@
|
|
62
79
|
|
63
80
|
## v0.2.0
|
64
81
|
|
65
|
-
* Public release
|
82
|
+
* Public release
|
data/README.md
CHANGED
@@ -1,19 +1,23 @@
|
|
1
|
-
# MongodbLogger
|
1
|
+
# MongodbLogger
|
2
|
+
[![Build Status](https://travis-ci.org/le0pard/mongodb_logger.png)](https://travis-ci.org/le0pard/mongodb_logger)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/le0pard/mongodb_logger.png)](https://codeclimate.com/github/le0pard/mongodb_logger)
|
2
4
|
|
3
|
-
MongodbLogger is a alternative logger for Rails
|
5
|
+
MongodbLogger is a alternative logger for Rails, which log all requests of you application into MongoDB database.
|
4
6
|
It:
|
5
7
|
|
6
|
-
* simple to integrate into existing Rails
|
8
|
+
* simple to integrate into existing Rails application;
|
7
9
|
* allow to store all logs from web cluster into one scalable storage - MongoDB;
|
8
10
|
* flexible schema of MongoDB allow to store and search any information from logs;
|
9
11
|
* web panel allow filter logs, build graphs using MapReduce by information from logs;
|
10
12
|
|
11
|
-
## Rails
|
13
|
+
## Rails support
|
12
14
|
|
13
|
-
Please note the latest version is compatible with rails 3.1.x or newer.
|
15
|
+
Please note the latest version is compatible with rails 3.1.x or newer.
|
14
16
|
|
15
17
|
For rails 3.0.x latest version 0.2.8.
|
16
18
|
|
19
|
+
Doesn't support the Rails version below 3.
|
20
|
+
|
17
21
|
## Installation
|
18
22
|
|
19
23
|
1. Add the following to your Gemfile then refresh your dependencies by executing "bundle install" (or just simple "bundle"):
|
@@ -24,15 +28,15 @@ For rails 3.0.x latest version 0.2.8.
|
|
24
28
|
|
25
29
|
gem "mongo"
|
26
30
|
gem "bson_ext"
|
27
|
-
|
28
|
-
or
|
31
|
+
|
32
|
+
or
|
29
33
|
|
30
34
|
gem "moped"
|
31
35
|
|
32
36
|
1. Add the following line to your ApplicationController:
|
33
37
|
|
34
38
|
include MongodbLogger::Base
|
35
|
-
|
39
|
+
|
36
40
|
1. For use with Heroku you need to prevent the rails\_log\_stdout plugin from being added by Heroku:
|
37
41
|
|
38
42
|
mkdir vendor/plugins/rails_log_stdout
|
@@ -69,7 +73,7 @@ For rails 3.0.x latest version 0.2.8.
|
|
69
73
|
host: localhost
|
70
74
|
port: 27017
|
71
75
|
replica_set: true
|
72
|
-
|
76
|
+
|
73
77
|
Also you can use "url" parameter for setup connection to mongodb:
|
74
78
|
|
75
79
|
development:
|
@@ -78,7 +82,7 @@ For rails 3.0.x latest version 0.2.8.
|
|
78
82
|
|
79
83
|
|
80
84
|
1. For using with MongoDB Replica Set (more info you can read by this link [http://www.mongodb.org/display/DOCS/Replica+Sets](http://www.mongodb.org/display/DOCS/Replica+Sets)). In config set list of [host, port] in key "hosts":
|
81
|
-
|
85
|
+
|
82
86
|
development:
|
83
87
|
database: my_app
|
84
88
|
capsize: <%= 10.megabytes %>
|
@@ -88,30 +92,30 @@ For rails 3.0.x latest version 0.2.8.
|
|
88
92
|
- - 127.0.0.1
|
89
93
|
- 27018
|
90
94
|
- - 127.0.0.1
|
91
|
-
- 27019
|
95
|
+
- 27019
|
92
96
|
|
93
97
|
1. For assets pipeline you can generate all js/css file into folder by rake task:
|
94
98
|
|
95
99
|
rake mongodb_logger:assets:compile[public/assets]
|
96
|
-
|
100
|
+
|
97
101
|
## Assets pipeline
|
98
|
-
|
102
|
+
|
99
103
|
For capistrano possible compile assets by receipt. Add this to config/deploy.rb:
|
100
104
|
|
101
105
|
require 'mongodb_logger/capistrano'
|
102
106
|
set :mongodb_logger_assets_dir, "public/assets" # where to put mongodb assets
|
103
107
|
after 'deploy:update_code', 'mongodb_logger:precompile'
|
104
|
-
|
108
|
+
|
105
109
|
Also you can serve assets from rails app. You need just mount it separately:
|
106
|
-
|
110
|
+
|
107
111
|
mount MongodbLogger::Server.new, :at => "/mongodb", :as => :mongodb
|
108
112
|
mount MongodbLogger::Assets.instance, :at => "/mongodb/assets", :as => :mongodb_assets # assets
|
109
|
-
|
110
|
-
|
113
|
+
|
114
|
+
|
111
115
|
## Usage
|
112
116
|
|
113
117
|
After success instalation of gem, a new MongoDB document (record) will be created for each request on your application,
|
114
|
-
by default will record the following information: Runtime, IP Address, Request Time, Controller, Method,
|
118
|
+
by default will record the following information: Runtime, IP Address, Request Time, Controller, Method,
|
115
119
|
Action, Params, Application Name and All messages sent to the logger. The structure of the MongoDB document looks like this:
|
116
120
|
|
117
121
|
{
|
@@ -151,48 +155,67 @@ For send email or do something on exception you can add callback:
|
|
151
155
|
# do something with this data, for example - send email (better - by background job)
|
152
156
|
end
|
153
157
|
end
|
154
|
-
|
158
|
+
|
155
159
|
In this callback send record without "\_id", because logger not wait for insert response from MongoDB.
|
156
160
|
|
161
|
+
## Migrate to another size of capped collection
|
162
|
+
|
163
|
+
If you need change capper collection size, you should change the "capsize" key in mongodb\_config and run this task for migration:
|
164
|
+
|
165
|
+
rake mongodb_logger:migrate
|
166
|
+
|
167
|
+
## Rack Middleware
|
168
|
+
|
169
|
+
If you want use MongodbLogger in Rack app which is mounted to your Rails app, you can try to use rack middleware:
|
170
|
+
|
171
|
+
use MongodbLogger::RackMiddleware
|
172
|
+
|
173
|
+
## Rails::Engine
|
174
|
+
|
175
|
+
If you want use MongodbLogger with some of Rails::Engine, you can do this (example for Spree):
|
176
|
+
|
177
|
+
Spree::BaseController.send :include, MongodbLogger::Base
|
178
|
+
Spree::Admin::BaseController.send :include, MongodbLogger::Base # for admin
|
179
|
+
|
157
180
|
## The Front End
|
158
181
|
|
159
|
-
To setup web interface in you Rails application, first of all create autoload file in you Rails application
|
160
|
-
|
182
|
+
To setup web interface in you Rails application, first of all create autoload file in you Rails application
|
183
|
+
|
161
184
|
File: you\_rails\_app/config/initializers/mongodb\_logger.rb (example)
|
162
|
-
|
185
|
+
|
163
186
|
require 'mongodb_logger/server' # required
|
164
187
|
# this secure you web interface by basic auth, but you can skip this, if you no need this
|
165
188
|
MongodbLogger::Server.use Rack::Auth::Basic do |username, password|
|
166
189
|
[username, password] == ['admin', 'password']
|
167
190
|
end
|
168
|
-
|
191
|
+
|
169
192
|
and just mount MongodbLogger::Server in rails routes:
|
170
193
|
|
171
194
|
File: you\_rails\_app/config/routes.rb
|
172
|
-
|
195
|
+
|
173
196
|
mount MongodbLogger::Server.new, :at => "/mongodb"
|
174
|
-
|
197
|
+
|
175
198
|
Now you can see web interface by url "http://localhost:3000/mongodb"
|
176
199
|
|
177
200
|
If you've installed MongodbLogger as a gem and want running the front end without Rails application, you can do it by this command:
|
178
201
|
|
179
202
|
mongodb_logger_web config.yml
|
180
|
-
|
203
|
+
|
181
204
|
where config.yml is config, similar to config of Rails apps, but without Rails.env. Example:
|
182
|
-
|
205
|
+
|
183
206
|
database: app_logs_dev
|
184
207
|
host: localhost
|
185
208
|
port: 27017
|
186
209
|
collection: development_log # set for see development logs
|
187
|
-
|
210
|
+
|
188
211
|
parameter "collection" should be set, if your set custom for your Rails application or start this front end not for production
|
189
|
-
enviroment (by default taken "production\_log" collection, in Rails application gem generate "#{Rails.env}\_log" collection,
|
212
|
+
enviroment (by default taken "production\_log" collection, in Rails application gem generate "#{Rails.env}\_log" collection,
|
190
213
|
if it is not defined in config).
|
191
214
|
|
192
215
|
It's a thin layer around rackup so it's configurable as well:
|
193
216
|
|
194
217
|
mongodb_logger_web config.yml -p 8282
|
195
|
-
|
218
|
+
|
196
219
|
### Passenger, Unicorn, Thin, etc.
|
197
220
|
|
198
221
|
Using Passenger, Unicorn, Thin, etc? MongodbLogger ships with a `config.ru` you can use. See guide:
|
@@ -207,17 +230,17 @@ Don't forget setup MONGODBLOGGERCONFIG env variable, which provide information a
|
|
207
230
|
MONGODBLOGGERCONFIG=examples/server_config.yml unicorn
|
208
231
|
|
209
232
|
## Demo Application with MongodbLogger
|
210
|
-
|
233
|
+
|
211
234
|
Demo: [http://demo-mongodb-logger.catware.org/](http://demo-mongodb-logger.catware.org/)
|
212
|
-
|
235
|
+
|
213
236
|
Demo Sources: [https://github.com/le0pard/mongodb_logger_example_heroku](https://github.com/le0pard/mongodb_logger_example_heroku)
|
214
|
-
|
237
|
+
|
215
238
|
|
216
239
|
## Querying via the Rails console
|
217
240
|
|
218
241
|
And now, for a couple quick examples on getting ahold of this log data...
|
219
242
|
First, here's how to get a handle on the MongoDB from within a Rails console:
|
220
|
-
|
243
|
+
|
221
244
|
>> db = Rails.logger.mongo_adapter.connection
|
222
245
|
=> #<Mongo::DB:0x007fdc7c65adc8 @name="monkey_logs_dev" ... >
|
223
246
|
>> collection = Rails.logger.mongo_adapter.collection
|
@@ -242,7 +265,7 @@ Demo Sources: [https://github.com/le0pard/mongodb_logger_example_heroku](https:/
|
|
242
265
|
Find all requests with an exception that contains "RoutingError" in the message or stack trace:
|
243
266
|
|
244
267
|
>> collection.find({"messages.error" => /RoutingError/})
|
245
|
-
|
268
|
+
|
246
269
|
Find all requests with errors:
|
247
270
|
|
248
271
|
>> collection.find({"is_exception" => true})
|
data/Rakefile
CHANGED
@@ -5,132 +5,69 @@ require 'bundler'
|
|
5
5
|
Bundler.require
|
6
6
|
require 'rake'
|
7
7
|
require 'rake/testtask'
|
8
|
-
require '
|
9
|
-
require '
|
10
|
-
|
11
|
-
|
8
|
+
require 'bundler/gem_tasks'
|
9
|
+
require 'appraisal'
|
10
|
+
require 'rspec/core/rake_task'
|
11
|
+
begin
|
12
|
+
require 'cucumber/rake/task'
|
13
|
+
rescue LoadError
|
14
|
+
$stderr.puts "Please install cucumber: `gem install cucumber`"
|
15
|
+
exit 1
|
16
|
+
end
|
12
17
|
|
13
18
|
#########################################
|
14
19
|
### TESTS
|
15
20
|
#########################################
|
16
21
|
|
17
|
-
desc 'Default: run
|
18
|
-
task :default => [:
|
19
|
-
|
22
|
+
desc 'Default: run tests'
|
23
|
+
task :default => [:spec, "mongodb_logger:tests"]
|
24
|
+
|
25
|
+
namespace :mongodb_logger do
|
26
|
+
task :tests do
|
27
|
+
exec 'rake appraisal cucumber '\
|
28
|
+
'&& FEATURE=features/mongodb_logger_web.feature rake cucumber '\
|
29
|
+
end
|
30
|
+
end
|
31
|
+
desc "run specs"
|
32
|
+
task :spec do
|
33
|
+
RSpec::Core::RakeTask.new
|
34
|
+
end
|
20
35
|
|
21
36
|
desc "Clean out the tmp directory"
|
22
37
|
task :clean do
|
23
|
-
exec "rm -rf tmp"
|
38
|
+
exec "rm -rf tmp/*"
|
24
39
|
end
|
25
40
|
|
26
|
-
desc 'Test unit
|
41
|
+
desc 'Test unit'
|
27
42
|
Rake::TestTask.new(:test) do |test|
|
28
|
-
test.libs << 'lib'
|
43
|
+
test.libs << 'lib'
|
29
44
|
test.test_files = ['test/unit/mongodb_logger_test.rb']
|
30
45
|
test.verbose = true
|
31
46
|
end
|
32
47
|
|
33
48
|
namespace :test do
|
34
|
-
|
35
49
|
desc "Run replica set tests (not for CI)"
|
36
50
|
Rake::TestTask.new(:replica_set) do |test|
|
37
|
-
test.libs << 'lib'
|
51
|
+
test.libs << 'lib'
|
38
52
|
test.pattern = 'test/unit/mongodb_logger_replica_test.rb'
|
39
53
|
test.verbose = true
|
40
54
|
end
|
41
|
-
|
42
55
|
end
|
43
56
|
|
57
|
+
def cucumber_opts
|
58
|
+
opts = "--tags ~@wip --format progress "
|
44
59
|
|
45
|
-
|
46
|
-
LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
|
47
|
-
|
48
|
-
if ENV['CI']
|
49
|
-
# for ci testing only major rails versions
|
50
|
-
if 'java' == RUBY_PLATFORM
|
51
|
-
RAILS_VERSIONS = ['3.1.6', '3.2.9']
|
52
|
-
else
|
53
|
-
RAILS_VERSIONS = ['3.1.6', '3.2.9']
|
54
|
-
end
|
55
|
-
else
|
56
|
-
RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n")
|
57
|
-
end
|
60
|
+
opts << ENV["FEATURE"] and return if ENV["FEATURE"]
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
desc "Vendor test gems: Run this once to prepare your test environment"
|
64
|
-
task :vendor_test_gems do
|
65
|
-
old_gem_path = ENV['GEM_PATH']
|
66
|
-
old_gem_home = ENV['GEM_HOME']
|
67
|
-
ENV['GEM_PATH'] = LOCAL_GEM_ROOT
|
68
|
-
ENV['GEM_HOME'] = LOCAL_GEM_ROOT
|
69
|
-
LOCAL_GEMS.each do |gem_name, version|
|
70
|
-
gem_file_pattern = [gem_name, version || '*'].compact.join('-')
|
71
|
-
version_option = version ? "-v #{version}" : ''
|
72
|
-
pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}")
|
73
|
-
existing = Dir.glob(pattern).first
|
74
|
-
unless existing
|
75
|
-
command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}"
|
76
|
-
puts "Vendoring #{gem_file_pattern}..."
|
77
|
-
unless system("#{command} 2>&1")
|
78
|
-
puts "Command failed: #{command}"
|
79
|
-
exit(1)
|
80
|
-
end
|
81
|
-
end
|
62
|
+
case ENV["BUNDLE_GEMFILE"]
|
63
|
+
when /rails/
|
64
|
+
opts << "features/rails.feature"
|
82
65
|
end
|
83
|
-
ENV['GEM_PATH'] = old_gem_path
|
84
|
-
ENV['GEM_HOME'] = old_gem_home
|
85
66
|
end
|
86
67
|
|
87
68
|
Cucumber::Rake::Task.new(:cucumber) do |t|
|
88
69
|
t.fork = true
|
89
|
-
t.cucumber_opts =
|
90
|
-
end
|
91
|
-
|
92
|
-
task :cucumber => [:vendor_test_gems]
|
93
|
-
|
94
|
-
def run_rails_cucumbr_task(version, additional_cucumber_args)
|
95
|
-
puts "Testing Rails #{version}"
|
96
|
-
if version.empty?
|
97
|
-
raise "No Rails version specified - make sure ENV['RAILS_VERSION'] is set, e.g. with `rake cucumber:rails:all`"
|
98
|
-
end
|
99
|
-
ENV['RAILS_VERSION'] = version
|
100
|
-
system("cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/rails.feature")
|
101
|
-
end
|
102
|
-
|
103
|
-
def define_rails_cucumber_tasks(additional_cucumber_args = '')
|
104
|
-
namespace :rails do
|
105
|
-
RAILS_VERSIONS.each do |version|
|
106
|
-
desc "Test integration of the gem with Rails #{version}"
|
107
|
-
task version => [:vendor_test_gems] do
|
108
|
-
exit 1 unless run_rails_cucumbr_task(version, additional_cucumber_args)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
desc "Test integration of the gem with all Rails versions"
|
113
|
-
task :all do
|
114
|
-
results = RAILS_VERSIONS.map do |version|
|
115
|
-
run_rails_cucumbr_task(version, additional_cucumber_args)
|
116
|
-
end
|
117
|
-
|
118
|
-
exit 1 unless results.all?
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def define_web_cucumber_tasks(additional_cucumber_args = '')
|
124
|
-
desc "Test web of the gem"
|
125
|
-
task :web do
|
126
|
-
puts "Testing Web"
|
127
|
-
system("cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/mongodb_logger_web.feature")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
namespace :cucumber do
|
132
|
-
define_rails_cucumber_tasks
|
133
|
-
define_web_cucumber_tasks
|
70
|
+
t.cucumber_opts = cucumber_opts
|
134
71
|
end
|
135
72
|
|
136
73
|
begin
|