prosperity 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +31 -0
- data/app/assets/javascripts/prosperity/application.js.coffee +42 -0
- data/app/assets/stylesheets/prosperity/application.css.scss +19 -0
- data/app/controllers/prosperity/application_controller.rb +4 -0
- data/app/controllers/prosperity/metrics_controller.rb +9 -0
- data/app/helpers/prosperity/application_helper.rb +7 -0
- data/app/helpers/prosperity/metrics_helper.rb +11 -0
- data/app/views/layouts/prosperity/application.html.haml +37 -0
- data/app/views/prosperity/metrics/index.html.haml +7 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20131026214127_test.rb +4 -0
- data/lib/prosperity/engine.rb +9 -0
- data/lib/prosperity/exception.rb +11 -0
- data/lib/prosperity/extractors/base.rb +11 -0
- data/lib/prosperity/extractors/count.rb +18 -0
- data/lib/prosperity/extractors/group.rb +23 -0
- data/lib/prosperity/metric.rb +48 -0
- data/lib/prosperity/metric_finder.rb +14 -0
- data/lib/prosperity/metrics/option.rb +9 -0
- data/lib/prosperity/metrics.rb +5 -0
- data/lib/prosperity/period.rb +11 -0
- data/lib/prosperity/periods.rb +6 -0
- data/lib/prosperity/version.rb +3 -0
- data/lib/prosperity.rb +4 -0
- data/lib/tasks/prosperity_tasks.rake +4 -0
- data/spec/controllers/prosperity/metrics_controller_spec.rb +14 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +8 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/javascripts/users.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/spec/dummy/app/assets/stylesheets/users.css +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/users_controller.rb +58 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/users_helper.rb +2 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/app/prosperity/users_metric.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/users/_form.html.erb +25 -0
- data/spec/dummy/app/views/users/edit.html.erb +6 -0
- data/spec/dummy/app/views/users/index.html.erb +29 -0
- data/spec/dummy/app/views/users/new.html.erb +5 -0
- data/spec/dummy/app/views/users/show.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +24 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20131026214807_create_users.rb +10 -0
- data/spec/dummy/db/schema.rb +26 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +18945 -0
- data/spec/dummy/log/test.log +1992 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/34a577735054231563e7022ea73e1468db9203ba/application.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_alerts.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_badges.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_bootstrap.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_breadcrumbs.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_button-groups.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_buttons.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_carousel.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_close.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_code.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_component-animations.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_dropdowns.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_forms.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_glyphicons.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_grid.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_input-groups.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_jumbotron.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_labels.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_list-group.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_media.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_mixins.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_modals.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_navbar.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_navs.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_normalize.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_pager.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_pagination.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_panels.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_popovers.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_print.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_progress-bars.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_responsive-utilities.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_scaffolding.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_tables.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_thumbnails.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_tooltip.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_type.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_utilities.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_variables.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_wells.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/be34d2a735e9e523a3c8b9414be4508380964813/bootstrap.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/043337ddb7f545a88004b2eb2a069b4d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/05ee6e5d8777628542d4ed27eab34c5a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/07080bfb6d1d7b60d61990c547c0f47a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/073948f1a0c619142ecfcb14a5806302 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/07e8fb2db7d85e29590a6b05160ca825 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0800f54ee19cf3cee10b956fa9786799 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/12eb9637e2c654371ecf7033d5a5cb36 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1502b34f91cda1f4222490f78c0fea39 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1533bcf4a8f5a745dfda80cebd88d217 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/177ca1f3e92db4f8a8f6e7ad9786ebfc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/18d7d771937643bc7e9210b1a80e5763 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/197492ed379339e17a0f5d01d3b01b8c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1c55cf24465f311353197ce336df0178 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1cb94582c835e73b3fd3c276f9a7de56 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/203047a4141cf08162077e7290421bbb +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/210050da208fb75a75b701bfa4e8470f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/29a6c93aeb91d07a5533b3adba7697d0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/29ac2be474969468157245a7f8737fa4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/314e44d29ecc7449c9ca3b754329c245 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3162d1398d6940ee5e933b7ab4d2273d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3d80e2a5faaf2bd987d804c17aead745 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4155a156cc6ffb880b56dbc34346fbc0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4166fe47cddf4ba18c53b843d69b4c5f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4432a4b71ce9551df8d4b3860f4b9be3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5479c7b4fba9179d4d1dc59ae64964c1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5a3ab9afd151c265cf11c621c0ddbe00 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/647038c58f26163a9217646e1e5f09ae +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/64e0150fafbd9aaa3822efa1abb0211d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6536a3eb4b5d05368d260a46f2485ead +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/65c2d908dbca1bc833ae0b552f6c27fa +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6882b260ae69f1594eff540d803e5ac3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/726d3f6850549a59954f0bf5584cfd9f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/75f2f1e32219e0b89c069e43b49e0e49 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7ab9ac7cc2529219a4c68fd7854d5c0f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7abbc975e6786a54d660e0cf19aab1f0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7bac3aca131c870ad5b07d8ccdc86e06 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7ffb7c821c008cd2a390dc7aba74361f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/80392355fc6e00cf69b2cd46978ebcbe +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8084620ce7f95d2b2aeb65c977c62af1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/874b42463fefbb0bce47775722ebb4ae +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/87ef8ddd2847d19f22a16d726b88b433 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/91ae0bd43f98b4f1f111e0bdc178302c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9a7970620504bfe92af14fd57ee08365 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9c8440c4efec99d4a380eeda42f089c7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9e4cf41800946fd32bcfa3591b304eb6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a2b14d5c46db32da9183354fb3fcd0bf +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a6d6196cfd275dea0718553a95f997a5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a7a8652a3fb42ef81fac3ab77949f82d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a9d839f632f9ce73fc221b79b39b0924 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bae0ea1201e2ec9420712ff54b3254aa +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c05c4a514cf0b61ad7b223ee732cd6df +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c29c465933e7e86d6f6224f5e78c5baf +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c975834a35907ecd2d314bbd6844ee88 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cebc6db0bbb8120f430da3970b173d2f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cf4affc50c6303e717d6514380d1f417 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d0194b0fba4290072cfff0be06b348fd +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d8487b3a1dc72a1361b96fbbc93255c6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d8b357d5741711da2dd710af0e15d268 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e02b5049cf477b43a72b4a00e2fceb46 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e0be9bf6ab486a790bda60b51224b404 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e22a1b318499e7f06ea9274e18ab004f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e298cc3a8203ab1fb6978a90254f8926 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e2a9bdd87a2d19256837fce6544a122c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e868f358fe87542c483951a2d9f532b6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e8a6adf580ebd1942f4aabe6738678c2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ea081ed20ad78a3e8f41a529b6baa2e1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ec956e1f28c818063bb61958fe5ae855 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ed71f99e0a9653296abd5d6f501dd898 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/eee3cb53f216eaa12dd927f144640d0d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/efe6f2d16d3a1819817efb8734daf8af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f03e99bdb4159ae3485ca2858716e19b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f29bc513eb7c7d4b79d53d51363f7f1f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/fc2c22310cbb7abb26ae64d4aafa37cb +0 -0
- data/spec/dummy/tmp/restart.txt +0 -0
- data/spec/helpers/prosperity/metrics_helper_spec.rb +6 -0
- data/spec/lib/prosperity/extractors/base_spec.rb +8 -0
- data/spec/lib/prosperity/extractors/count_spec.rb +35 -0
- data/spec/lib/prosperity/extractors/group_spec.rb +34 -0
- data/spec/lib/prosperity/metric_finder_spec.rb +20 -0
- data/spec/lib/prosperity/metric_spec.rb +49 -0
- data/spec/lib/prosperity/metrics/option_spec.rb +7 -0
- data/spec/lib/prosperity/period_spec.rb +7 -0
- data/spec/lib/prosperity/periods_spec.rb +7 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/test_database.rb +18 -0
- data/spec/test_files/metrics/users_metric.rb +4 -0
- data/vendor/assets/javascripts/chart.js +1426 -0
- data/vendor/assets/stylesheets/bootstrap-theme.min.css +9 -0
- data/vendor/assets/stylesheets/bootstrap.min.css +9 -0
- metadata +526 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Prosperity
|
4
|
+
describe Metric do
|
5
|
+
context "A simple scope metric" do
|
6
|
+
subject do
|
7
|
+
Class.new(Metric) do
|
8
|
+
scope { User }
|
9
|
+
end.new
|
10
|
+
end
|
11
|
+
|
12
|
+
it "groups by created_at by default" do
|
13
|
+
subject.group_by.should == :created_at
|
14
|
+
end
|
15
|
+
|
16
|
+
it "gets the scope" do
|
17
|
+
subject.scope.should == User
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "a metric missing the scope" do
|
22
|
+
subject do
|
23
|
+
Class.new(Metric) do
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "raises an exception when accessing the scope" do
|
28
|
+
expect { subject.scope }.to raise_exception(MissingScope)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "A simple scope metric with multiple options" do
|
33
|
+
subject do
|
34
|
+
Class.new(Metric) do
|
35
|
+
scope { User }
|
36
|
+
options "active" do |scope|
|
37
|
+
scope.active
|
38
|
+
end
|
39
|
+
end.new
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have multiple options" do
|
43
|
+
subject.options.size.should == 2
|
44
|
+
subject.options['default'].should be_present
|
45
|
+
subject.options['active'].should be_present
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
|
3
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
require 'pry-debugger'
|
7
|
+
|
8
|
+
Dir[File.join(__dir__, "support/**/*.rb")].each {|f| require f }
|
9
|
+
TEST_FILES = File.join(__dir__, "test_files")
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
config.filter_run :focus
|
15
|
+
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Create a dummy schema for testing
|
2
|
+
class User < ActiveRecord::Base
|
3
|
+
end
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.before(:suite) do
|
7
|
+
m = ActiveRecord::Migration
|
8
|
+
m.verbose = false
|
9
|
+
|
10
|
+
m.drop_table :users if ActiveRecord::Base.connection.tables.include?("users")
|
11
|
+
|
12
|
+
m.create_table :users do |t|
|
13
|
+
t.string :email
|
14
|
+
t.string :name
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|