active_hash_relation 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -0
  3. data/.travis.yml +15 -0
  4. data/README.md +68 -11
  5. data/active_hash_relation.gemspec +13 -0
  6. data/lib/active_hash_relation.rb +18 -12
  7. data/lib/active_hash_relation/aggregation.rb +3 -0
  8. data/lib/active_hash_relation/association_filters.rb +3 -0
  9. data/lib/active_hash_relation/column_filters.rb +45 -11
  10. data/lib/active_hash_relation/filter_applier.rb +37 -23
  11. data/lib/active_hash_relation/helpers.rb +22 -2
  12. data/lib/active_hash_relation/scope_filters.rb +8 -1
  13. data/lib/active_hash_relation/sort_filters.rb +12 -0
  14. data/lib/active_hash_relation/version.rb +1 -1
  15. data/lib/active_record/scope_names.rb +4 -19
  16. data/lib/generators/active_hash_relation/initialize_generator.rb +13 -0
  17. data/lib/generators/active_hash_relation/templates/active_hash_relation.rb +12 -0
  18. data/spec/config/initializers/active_hash_relation.rb +16 -0
  19. data/spec/db/migrate/001_basic_schema.rb +53 -0
  20. data/spec/dummy-rails4/.gitignore +13 -0
  21. data/spec/dummy-rails4/.ruby-version +1 -0
  22. data/spec/dummy-rails4/Gemfile +18 -0
  23. data/spec/dummy-rails4/README.md +3 -0
  24. data/spec/dummy-rails4/Rakefile +6 -0
  25. data/spec/dummy-rails4/app/controllers/application_controller.rb +5 -0
  26. data/spec/dummy-rails4/app/models/.keep +0 -0
  27. data/spec/dummy-rails4/app/models/address.rb +1 -0
  28. data/spec/dummy-rails4/app/models/micropost.rb +1 -0
  29. data/spec/dummy-rails4/app/models/relationship.rb +1 -0
  30. data/spec/dummy-rails4/app/models/user.rb +1 -0
  31. data/spec/dummy-rails4/bin/bundle +3 -0
  32. data/spec/dummy-rails4/bin/rails +4 -0
  33. data/spec/dummy-rails4/bin/rake +4 -0
  34. data/spec/dummy-rails4/bin/setup +29 -0
  35. data/spec/dummy-rails4/config.ru +4 -0
  36. data/spec/dummy-rails4/config/application.rb +35 -0
  37. data/spec/dummy-rails4/config/boot.rb +3 -0
  38. data/spec/dummy-rails4/config/database.yml +18 -0
  39. data/spec/dummy-rails4/config/environment.rb +5 -0
  40. data/spec/dummy-rails4/config/environments/development.rb +41 -0
  41. data/spec/dummy-rails4/config/environments/production.rb +79 -0
  42. data/spec/dummy-rails4/config/environments/test.rb +42 -0
  43. data/spec/dummy-rails4/config/initializers/active_hash_relation.rb +3 -0
  44. data/spec/dummy-rails4/config/initializers/assets.rb +11 -0
  45. data/spec/dummy-rails4/config/initializers/backtrace_silencers.rb +7 -0
  46. data/spec/dummy-rails4/config/initializers/cookies_serializer.rb +3 -0
  47. data/spec/dummy-rails4/config/initializers/filter_parameter_logging.rb +4 -0
  48. data/spec/dummy-rails4/config/initializers/inflections.rb +16 -0
  49. data/spec/dummy-rails4/config/initializers/mime_types.rb +4 -0
  50. data/spec/dummy-rails4/config/initializers/session_store.rb +3 -0
  51. data/spec/dummy-rails4/config/initializers/wrap_parameters.rb +14 -0
  52. data/spec/dummy-rails4/config/locales/en.yml +23 -0
  53. data/spec/dummy-rails4/config/routes.rb +56 -0
  54. data/spec/dummy-rails4/config/secrets.yml +22 -0
  55. data/spec/dummy-rails4/db/migrate/001_basic_schema.rb +1 -0
  56. data/spec/dummy-rails4/db/schema.rb +69 -0
  57. data/spec/dummy-rails4/spec/factories/factories.rb +1 -0
  58. data/spec/dummy-rails4/spec/rails_helper.rb +19 -0
  59. data/spec/dummy-rails4/spec/spec_helper.rb +99 -0
  60. data/spec/dummy-rails4/spec/support/support.rb +1 -0
  61. data/spec/dummy-rails4/spec/tests/tests_spec.rb +3 -0
  62. data/spec/dummy-rails5/.gitignore +17 -0
  63. data/spec/dummy-rails5/.rspec +2 -0
  64. data/spec/dummy-rails5/.ruby-version +1 -0
  65. data/spec/dummy-rails5/Gemfile +19 -0
  66. data/spec/dummy-rails5/README.md +3 -0
  67. data/spec/dummy-rails5/Rakefile +6 -0
  68. data/spec/dummy-rails5/app/controllers/application_controller.rb +3 -0
  69. data/spec/dummy-rails5/app/models/address.rb +1 -0
  70. data/spec/dummy-rails5/app/models/micropost.rb +1 -0
  71. data/spec/dummy-rails5/app/models/relationship.rb +1 -0
  72. data/spec/dummy-rails5/app/models/user.rb +1 -0
  73. data/spec/dummy-rails5/bin/bundle +3 -0
  74. data/spec/dummy-rails5/bin/rails +4 -0
  75. data/spec/dummy-rails5/bin/rake +4 -0
  76. data/spec/dummy-rails5/bin/setup +34 -0
  77. data/spec/dummy-rails5/bin/update +29 -0
  78. data/spec/dummy-rails5/config.ru +5 -0
  79. data/spec/dummy-rails5/config/application.rb +25 -0
  80. data/spec/dummy-rails5/config/boot.rb +3 -0
  81. data/spec/dummy-rails5/config/cable.yml +9 -0
  82. data/spec/dummy-rails5/config/database.yml +18 -0
  83. data/spec/dummy-rails5/config/environment.rb +5 -0
  84. data/spec/dummy-rails5/config/environments/development.rb +54 -0
  85. data/spec/dummy-rails5/config/environments/production.rb +86 -0
  86. data/spec/dummy-rails5/config/environments/test.rb +42 -0
  87. data/spec/dummy-rails5/config/initializers/active_hash_relation.rb +3 -0
  88. data/spec/dummy-rails5/config/initializers/application_controller_renderer.rb +6 -0
  89. data/spec/dummy-rails5/config/initializers/assets.rb +11 -0
  90. data/spec/dummy-rails5/config/initializers/backtrace_silencers.rb +7 -0
  91. data/spec/dummy-rails5/config/initializers/cookies_serializer.rb +5 -0
  92. data/spec/dummy-rails5/config/initializers/filter_parameter_logging.rb +4 -0
  93. data/spec/dummy-rails5/config/initializers/inflections.rb +16 -0
  94. data/spec/dummy-rails5/config/initializers/mime_types.rb +4 -0
  95. data/spec/dummy-rails5/config/initializers/new_framework_defaults.rb +24 -0
  96. data/spec/dummy-rails5/config/initializers/session_store.rb +3 -0
  97. data/spec/dummy-rails5/config/initializers/wrap_parameters.rb +14 -0
  98. data/spec/dummy-rails5/config/locales/en.yml +23 -0
  99. data/spec/dummy-rails5/config/puma.rb +47 -0
  100. data/spec/dummy-rails5/config/routes.rb +3 -0
  101. data/spec/dummy-rails5/config/secrets.yml +22 -0
  102. data/spec/dummy-rails5/config/spring.rb +6 -0
  103. data/spec/dummy-rails5/db/migrate/001_basic_schema.rb +2 -0
  104. data/spec/dummy-rails5/db/schema.rb +64 -0
  105. data/spec/dummy-rails5/spec/factories/factories.rb +1 -0
  106. data/spec/dummy-rails5/spec/rails_helper.rb +19 -0
  107. data/spec/dummy-rails5/spec/spec_helper.rb +99 -0
  108. data/spec/dummy-rails5/spec/support/support.rb +1 -0
  109. data/spec/dummy-rails5/spec/tests/tests_spec.rb +3 -0
  110. data/spec/factories/factories.rb +39 -0
  111. data/spec/models/address.rb +7 -0
  112. data/spec/models/application_record.rb +3 -0
  113. data/spec/models/micropost.rb +9 -0
  114. data/spec/models/relationship.rb +9 -0
  115. data/spec/models/user.rb +32 -0
  116. data/spec/support/support.rb +62 -0
  117. data/spec/tests/aggregations/avg_spec.rb +45 -0
  118. data/spec/tests/aggregations/max_spec.rb +45 -0
  119. data/spec/tests/aggregations/min_spec.rb +46 -0
  120. data/spec/tests/aggregations/sum_spec.rb +43 -0
  121. data/spec/tests/associations/belongs_to_spec.rb +96 -0
  122. data/spec/tests/associations/has_many_spec.rb +91 -0
  123. data/spec/tests/associations/has_one_spec.rb +89 -0
  124. data/spec/tests/booleans_spec.rb +29 -0
  125. data/spec/tests/limit_spec.rb +30 -0
  126. data/spec/tests/null_spec.rb +44 -0
  127. data/spec/tests/numbers_spec.rb +142 -0
  128. data/spec/tests/or_filter_spec.rb +98 -0
  129. data/spec/tests/primary_key_spec.rb +29 -0
  130. data/spec/tests/scopes_spec.rb +48 -0
  131. data/spec/tests/sorting_spec.rb +100 -0
  132. data/spec/tests/strings_spec.rb +86 -0
  133. metadata +392 -4
@@ -0,0 +1,11 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Version of your assets, change this if you want to expire all your assets.
4
+ Rails.application.config.assets.version = '1.0'
5
+
6
+ # Add additional assets to the asset load path
7
+ # Rails.application.config.assets.paths << Emoji.images_path
8
+
9
+ # Precompile additional assets.
10
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Specify a serializer for the signed and encrypted cookie jars.
4
+ # Valid options are :json, :marshal, and :hybrid.
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,24 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains migration options to ease your Rails 5.0 upgrade.
4
+ #
5
+ # Read the Rails 5.0 release notes for more info on each option.
6
+
7
+ # Enable per-form CSRF tokens. Previous versions had false.
8
+ Rails.application.config.action_controller.per_form_csrf_tokens = true
9
+
10
+ # Enable origin-checking CSRF mitigation. Previous versions had false.
11
+ Rails.application.config.action_controller.forgery_protection_origin_check = true
12
+
13
+ # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
14
+ # Previous versions had false.
15
+ ActiveSupport.to_time_preserves_timezone = true
16
+
17
+ # Require `belongs_to` associations by default. Previous versions had false.
18
+ Rails.application.config.active_record.belongs_to_required_by_default = true
19
+
20
+ # Do not halt callback chains when a callback returns false. Previous versions had true.
21
+ ActiveSupport.halt_callback_chains_on_return_false = false
22
+
23
+ # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
24
+ Rails.application.config.ssl_options = { hsts: { subdomains: true } }
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_rails5_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,47 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum, this matches the default thread size of Active Record.
6
+ #
7
+ threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
8
+ threads threads_count, threads_count
9
+
10
+ # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11
+ #
12
+ port ENV.fetch("PORT") { 3000 }
13
+
14
+ # Specifies the `environment` that Puma will run in.
15
+ #
16
+ environment ENV.fetch("RAILS_ENV") { "development" }
17
+
18
+ # Specifies the number of `workers` to boot in clustered mode.
19
+ # Workers are forked webserver processes. If using threads and workers together
20
+ # the concurrency of the application would be max `threads` * `workers`.
21
+ # Workers do not work on JRuby or Windows (both of which do not support
22
+ # processes).
23
+ #
24
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25
+
26
+ # Use the `preload_app!` method when specifying a `workers` number.
27
+ # This directive tells Puma to first boot the application and load code
28
+ # before forking the application. This takes advantage of Copy On Write
29
+ # process behavior so workers use less memory. If you use this option
30
+ # you need to make sure to reconnect any threads in the `on_worker_boot`
31
+ # block.
32
+ #
33
+ # preload_app!
34
+
35
+ # The code in the `on_worker_boot` will be called if you are using
36
+ # clustered mode by specifying a number of `workers`. After each worker
37
+ # process is booted this block will be run, if you are using `preload_app!`
38
+ # option you will want to use this block to reconnect to any threads
39
+ # or connections that may have been created at application boot, Ruby
40
+ # cannot share connections between processes.
41
+ #
42
+ # on_worker_boot do
43
+ # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44
+ # end
45
+
46
+ # Allow puma to be restarted by `rails restart` command.
47
+ plugin :tmp_restart
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rails secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 18597e9f6dc85291a8c172aca10f8c8f5af933001d5113d55cf61a878ad0fcdb17f0988ea8e40bc7587502837b754505f38a505f4e1a96bedab95dd334b6d668
15
+
16
+ test:
17
+ secret_key_base: f1b08127908b5be5942afd41298e4301ce6ed230f3f7a1be4752aab3529588ba1da79dcfe9b413ee60be59884b62882d165fd66f225b0933f6fc6892ae583f2e
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,6 @@
1
+ %w(
2
+ .ruby-version
3
+ .rbenv-vars
4
+ tmp/restart.txt
5
+ tmp/caching-dev.txt
6
+ ).each { |path| Spring.watch(path) }
@@ -0,0 +1,2 @@
1
+ require_relative '../../../db/migrate/001_basic_schema'
2
+
@@ -0,0 +1,64 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 1) do
14
+
15
+ # These are extensions that must be enabled in order to support this database
16
+ enable_extension "plpgsql"
17
+
18
+ create_table "addresses", force: :cascade do |t|
19
+ t.string "street"
20
+ t.string "city"
21
+ t.string "country"
22
+ t.integer "user_id"
23
+ t.datetime "created_at"
24
+ t.datetime "updated_at"
25
+ t.index ["user_id"], name: "index_addresses_on_user_id", unique: true, using: :btree
26
+ end
27
+
28
+ create_table "microposts", force: :cascade do |t|
29
+ t.text "content", null: false
30
+ t.integer "user_id", null: false
31
+ t.integer "likes", default: 0, null: false
32
+ t.integer "reposts", default: 0, null: false
33
+ t.integer "status", default: 0, null: false
34
+ t.datetime "created_at", null: false
35
+ t.datetime "updated_at", null: false
36
+ t.index ["user_id"], name: "index_microposts_on_user_id", using: :btree
37
+ end
38
+
39
+ create_table "relationships", force: :cascade do |t|
40
+ t.integer "follower_id"
41
+ t.integer "followed_id"
42
+ t.datetime "created_at", null: false
43
+ t.datetime "updated_at", null: false
44
+ t.index ["followed_id"], name: "index_relationships_on_followed_id", using: :btree
45
+ t.index ["follower_id", "followed_id"], name: "index_relationships_on_follower_id_and_followed_id", unique: true, using: :btree
46
+ t.index ["follower_id"], name: "index_relationships_on_follower_id", using: :btree
47
+ end
48
+
49
+ create_table "users", force: :cascade do |t|
50
+ t.string "name"
51
+ t.string "email", null: false
52
+ t.boolean "admin", default: false
53
+ t.boolean "verified", default: false
54
+ t.string "token", null: false
55
+ t.integer "microposts_count", default: 0, null: false
56
+ t.integer "followers_count", default: 0, null: false
57
+ t.integer "followings_count", default: 0, null: false
58
+ t.datetime "created_at", null: false
59
+ t.datetime "updated_at", null: false
60
+ t.index ["email"], name: "index_users_on_email", unique: true, using: :btree
61
+ end
62
+
63
+ add_foreign_key "microposts", "users"
64
+ end
@@ -0,0 +1 @@
1
+ require_relative '../../../factories/factories'
@@ -0,0 +1,19 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
4
+ require 'spec_helper'
5
+ require 'rspec/rails'
6
+ require File.expand_path('../../../../lib/active_hash_relation', __FILE__)
7
+
8
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
9
+
10
+ # Checks for pending migration and applies them before tests are run.
11
+ # If you are not using ActiveRecord, you can remove this line.
12
+ ActiveRecord::Migration.maintain_test_schema!
13
+
14
+ RSpec.configure do |config|
15
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
16
+ config.use_transactional_fixtures = true
17
+ config.infer_spec_type_from_file_location!
18
+ config.filter_rails_from_backtrace!
19
+ end
@@ -0,0 +1,99 @@
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
44
+ # have no way to turn it off -- the option exists only for backwards
45
+ # compatibility in RSpec 3). It causes shared context metadata to be
46
+ # inherited by the metadata hash of host groups and examples, rather than
47
+ # triggering implicit auto-inclusion in groups with matching metadata.
48
+ config.shared_context_metadata_behavior = :apply_to_host_groups
49
+
50
+ # The settings below are suggested to provide a good initial experience
51
+ # with RSpec, but feel free to customize to your heart's content.
52
+ =begin
53
+ # This allows you to limit a spec run to individual examples or groups
54
+ # you care about by tagging them with `:focus` metadata. When nothing
55
+ # is tagged with `:focus`, all examples get run. RSpec also provides
56
+ # aliases for `it`, `describe`, and `context` that include `:focus`
57
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
58
+ config.filter_run_when_matching :focus
59
+
60
+ # Allows RSpec to persist some state between runs in order to support
61
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
62
+ # you configure your source control system to ignore this file.
63
+ config.example_status_persistence_file_path = "spec/examples.txt"
64
+
65
+ # Limits the available syntax to the non-monkey patched syntax that is
66
+ # recommended. For more details, see:
67
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
68
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
70
+ config.disable_monkey_patching!
71
+
72
+ # Many RSpec users commonly either run the entire suite or an individual
73
+ # file, and it's useful to allow more verbose output when running an
74
+ # individual spec file.
75
+ if config.files_to_run.one?
76
+ # Use the documentation formatter for detailed output,
77
+ # unless a formatter has already been configured
78
+ # (e.g. via a command-line flag).
79
+ config.default_formatter = 'doc'
80
+ end
81
+
82
+ # Print the 10 slowest examples and example groups at the
83
+ # end of the spec run, to help surface which specs are running
84
+ # particularly slow.
85
+ config.profile_examples = 10
86
+
87
+ # Run specs in random order to surface order dependencies. If you find an
88
+ # order dependency and want to debug it, you can fix the order by providing
89
+ # the seed, which is printed after each run.
90
+ # --seed 1234
91
+ config.order = :random
92
+
93
+ # Seed global randomization in this process using the `--seed` CLI option.
94
+ # Setting this allows you to use `--seed` to deterministically reproduce
95
+ # test failures related to randomization by passing the same `--seed` value
96
+ # as the one that triggered the failure.
97
+ Kernel.srand config.seed
98
+ =end
99
+ end
@@ -0,0 +1 @@
1
+ require_relative '../../../support/support'
@@ -0,0 +1,3 @@
1
+ require 'rails_helper'
2
+
3
+ Dir[Rails.root.join('../tests/**/*.rb')].each { |f| require f }
@@ -0,0 +1,39 @@
1
+ FactoryGirl.define do
2
+ factory :address do
3
+ user
4
+
5
+ street { Faker::Address.street_address }
6
+ city { Faker::Address.city }
7
+ country { Faker::Address.country }
8
+ end
9
+ end
10
+
11
+ FactoryGirl.define do
12
+ factory :micropost do
13
+ content { Faker::Lorem.sentence }
14
+ likes { rand(1..1000) }
15
+ reposts { rand(1..1000) }
16
+ status { [:draft, :published, :archived].sample }
17
+ created_at { rand(1..1000).days.ago }
18
+
19
+ user
20
+ end
21
+ end
22
+
23
+ FactoryGirl.define do
24
+ factory :relationship do
25
+ association :follower, factory: :user
26
+ association :followed, factory: :user
27
+ end
28
+ end
29
+
30
+ FactoryGirl.define do
31
+ factory :user do
32
+ email { Faker::Internet.email }
33
+ name { Faker::Name.name }
34
+
35
+ factory :admin do
36
+ admin { true }
37
+ end
38
+ end
39
+ end