subdivision_select 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +24 -0
  4. data/app/assets/javascripts/subdivision_select.js +68 -0
  5. data/app/assets/stylesheets/subdivision_select/application.css +15 -0
  6. data/app/controllers/subdivision_select/subdivisions_controller.rb +7 -0
  7. data/app/helpers/subdivision_select/subdivisions_helper.rb +20 -0
  8. data/config/routes.rb +3 -0
  9. data/lib/subdivision_select.rb +4 -0
  10. data/lib/subdivision_select/engine.rb +21 -0
  11. data/lib/subdivision_select/subdivision_select_helper.rb +32 -0
  12. data/lib/subdivision_select/version.rb +3 -0
  13. data/lib/tasks/subdivision_select_tasks.rake +4 -0
  14. data/spec/controllers/subdivision_select/subdivisions_controller_spec.rb +22 -0
  15. data/spec/helpers/subdivision_select/subdivisions_helper_spec.rb +27 -0
  16. data/spec/rails_helper.rb +53 -0
  17. data/spec/spec_helper.rb +84 -0
  18. data/spec/test_app/README.rdoc +28 -0
  19. data/spec/test_app/Rakefile +7 -0
  20. data/spec/test_app/app/assets/javascripts/application.js +15 -0
  21. data/spec/test_app/app/assets/stylesheets/addresses_demo.css +30 -0
  22. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  23. data/spec/test_app/app/controllers/addresses_demo_controller.rb +7 -0
  24. data/spec/test_app/app/controllers/application_controller.rb +5 -0
  25. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  26. data/spec/test_app/app/views/addresses_demo/_form.html.erb +28 -0
  27. data/spec/test_app/app/views/addresses_demo/index.html.erb +32 -0
  28. data/spec/test_app/app/views/layouts/application.html.erb +16 -0
  29. data/spec/test_app/bin/bundle +3 -0
  30. data/spec/test_app/bin/rails +4 -0
  31. data/spec/test_app/bin/rake +4 -0
  32. data/spec/test_app/bin/setup +29 -0
  33. data/spec/test_app/config.ru +4 -0
  34. data/spec/test_app/config/application.rb +38 -0
  35. data/spec/test_app/config/boot.rb +5 -0
  36. data/spec/test_app/config/database.yml +25 -0
  37. data/spec/test_app/config/environment.rb +5 -0
  38. data/spec/test_app/config/environments/development.rb +42 -0
  39. data/spec/test_app/config/environments/production.rb +83 -0
  40. data/spec/test_app/config/environments/test.rb +43 -0
  41. data/spec/test_app/config/initializers/assets.rb +12 -0
  42. data/spec/test_app/config/initializers/backtrace_silencers.rb +9 -0
  43. data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
  44. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  45. data/spec/test_app/config/initializers/inflections.rb +16 -0
  46. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  47. data/spec/test_app/config/initializers/session_store.rb +3 -0
  48. data/spec/test_app/config/initializers/wrap_parameters.rb +15 -0
  49. data/spec/test_app/config/locales/en.yml +23 -0
  50. data/spec/test_app/config/routes.rb +7 -0
  51. data/spec/test_app/config/secrets.yml +22 -0
  52. data/spec/test_app/db/development.sqlite3 +0 -0
  53. data/spec/test_app/db/schema.rb +17 -0
  54. data/spec/test_app/db/test.sqlite3 +0 -0
  55. data/spec/test_app/log/development.log +15256 -0
  56. data/spec/test_app/log/test.log +3590 -0
  57. data/spec/test_app/public/404.html +67 -0
  58. data/spec/test_app/public/422.html +67 -0
  59. data/spec/test_app/public/500.html +66 -0
  60. data/spec/test_app/public/favicon.ico +0 -0
  61. data/spec/test_app/spec/controllers/addresses_demo_controller_spec.rb +10 -0
  62. data/spec/test_app/spec/features/select_boxes_spec.rb +59 -0
  63. data/spec/test_app/tmp/cache/assets/development/sprockets/0e86e92aa1a7fa502550f682d1eff538 +0 -0
  64. data/spec/test_app/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  65. data/spec/test_app/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  66. data/spec/test_app/tmp/cache/assets/development/sprockets/3262e90c302e3e34c98b57cb15a5b27d +0 -0
  67. data/spec/test_app/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  68. data/spec/test_app/tmp/cache/assets/development/sprockets/40f61c50b6d6c35efefea3238e00b207 +0 -0
  69. data/spec/test_app/tmp/cache/assets/development/sprockets/4fecaadc92042e3205c672f79acd3d53 +0 -0
  70. data/spec/test_app/tmp/cache/assets/development/sprockets/5342836c5888a5ebf28e2de221e5253f +0 -0
  71. data/spec/test_app/tmp/cache/assets/development/sprockets/670fbdb8a72ec9ac99a781d7d22b3f4d +0 -0
  72. data/spec/test_app/tmp/cache/assets/development/sprockets/80bc23cc99868eb749d85729de1d581c +0 -0
  73. data/spec/test_app/tmp/cache/assets/development/sprockets/85ceb80957448de1ad16090a43790597 +0 -0
  74. data/spec/test_app/tmp/cache/assets/development/sprockets/86ba36fa1967df4fe7a5fdd85d944f8b +0 -0
  75. data/spec/test_app/tmp/cache/assets/development/sprockets/a71eee989fdb18229089d8186762b57a +0 -0
  76. data/spec/test_app/tmp/cache/assets/development/sprockets/a91867dcc3218be71a70e7659d113e33 +0 -0
  77. data/spec/test_app/tmp/cache/assets/development/sprockets/aa8c7ed1b6c24feb5236df8f536b0376 +0 -0
  78. data/spec/test_app/tmp/cache/assets/development/sprockets/b50a9d45908f02319edc45b04faccf30 +0 -0
  79. data/spec/test_app/tmp/cache/assets/development/sprockets/b79233589329a96b0de414e6bef4e6e6 +0 -0
  80. data/spec/test_app/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  81. data/spec/test_app/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  82. data/spec/test_app/tmp/cache/assets/development/sprockets/e21efccbec07dbc2c25554b5a116ca7e +0 -0
  83. data/spec/test_app/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  84. data/spec/test_app/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  85. data/spec/test_app/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  86. data/spec/test_app/tmp/cache/assets/test/sprockets/3262e90c302e3e34c98b57cb15a5b27d +0 -0
  87. data/spec/test_app/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  88. data/spec/test_app/tmp/cache/assets/test/sprockets/40f61c50b6d6c35efefea3238e00b207 +0 -0
  89. data/spec/test_app/tmp/cache/assets/test/sprockets/670fbdb8a72ec9ac99a781d7d22b3f4d +0 -0
  90. data/spec/test_app/tmp/cache/assets/test/sprockets/80bc23cc99868eb749d85729de1d581c +0 -0
  91. data/spec/test_app/tmp/cache/assets/test/sprockets/a71eee989fdb18229089d8186762b57a +0 -0
  92. data/spec/test_app/tmp/cache/assets/test/sprockets/aa8c7ed1b6c24feb5236df8f536b0376 +0 -0
  93. data/spec/test_app/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  94. data/spec/test_app/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  95. data/spec/test_app/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  96. data/spec/test_app/tmp/capybara/capybara-201504291131209825278815.html +574 -0
  97. data/spec/test_app/tmp/capybara/capybara-201504291150401230302205.html +574 -0
  98. data/spec/test_app/tmp/capybara/capybara-201504291206543623839131.html +574 -0
  99. data/spec/test_app/tmp/capybara/capybara-20150429120937203197592.html +574 -0
  100. data/spec/test_app/tmp/capybara/capybara-201504291210383988435864.html +574 -0
  101. data/spec/test_app/tmp/capybara/capybara-20150429121627707334270.html +574 -0
  102. data/spec/test_app/tmp/capybara/capybara-201504291236506064013706.html +574 -0
  103. data/spec/test_app/tmp/capybara/capybara-201504291319426841751741.html +574 -0
  104. data/spec/test_app/tmp/capybara/capybara-201504291320577316381446.html +282 -0
  105. data/spec/test_app/tmp/capybara/capybara-201504291324064605129112.html +282 -0
  106. data/spec/test_app/tmp/capybara/capybara-201504291325214676808281.html +282 -0
  107. data/spec/test_app/tmp/capybara/capybara-201504291329305133892137.html +282 -0
  108. data/spec/test_app/tmp/capybara/capybara-201504291331505222229998.html +282 -0
  109. data/spec/test_app/tmp/capybara/capybara-201504291342298940226392.html +282 -0
  110. data/spec/test_app/tmp/capybara/capybara-201504291343237421868398.html +282 -0
  111. data/spec/test_app/tmp/capybara/capybara-201504291344199401915203.html +282 -0
  112. data/spec/test_app/tmp/pids/server.pid +1 -0
  113. metadata +366 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5a1349ca5beb57364c00b30deb474507f3028b52
4
+ data.tar.gz: 3d9a9f3a9c9563a82304e2da6027406804f0ff19
5
+ SHA512:
6
+ metadata.gz: 6c07ad1a726098873117fcea8d39f60528460c9b3dca69c6d5ba52ab37a0dfab4504bb1c70efa231be05441db81b744bcf1aa8aed333a02768f93507afce5d73
7
+ data.tar.gz: 32022822f36eccc0c00807cb26084847ac9351a74c103e494b71af8538b2152a589172072db39ae8c24135b7693c97d87b2567868ee0dc1a123cca9fd8fedac5
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Sean Collins
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ begin
2
+ require "bundler/setup"
3
+ rescue LoadError
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
+ end
6
+
7
+ require "rdoc/task"
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = "rdoc"
11
+ rdoc.title = "SubdivisionSelect"
12
+ rdoc.options << "--line-numbers"
13
+ rdoc.rdoc_files.include("README.rdoc")
14
+ rdoc.rdoc_files.include("lib/**/*.rb")
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/test_app/Rakefile", __FILE__)
18
+ load "rails/tasks/engine.rake"
19
+
20
+ load "rails/tasks/statistics.rake"
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ task default: "app:spec"
@@ -0,0 +1,68 @@
1
+ var SubdivisionSelect = (function() {
2
+ function SubdivisionSelect(element) {
3
+ this._countrySelect = element;
4
+ this._subdivisionSelect = $(element).
5
+ closest("form").
6
+ find(SubdivisionSelect.subdivisionSelector);
7
+ };
8
+
9
+ SubdivisionSelect.subdivisionSelector = "select.subdivision-selector";
10
+ SubdivisionSelect.countrySelector = "select[id$=country]";
11
+
12
+ SubdivisionSelect.init = function () {
13
+ var klass = this;
14
+
15
+ return $(klass.countrySelector).each(function() {
16
+ return new klass(this).init();
17
+ });
18
+ };
19
+
20
+ SubdivisionSelect.prototype.init = function() {
21
+ var self = this;
22
+
23
+ $(this._countrySelect).change(function() {
24
+ $.ajax( {
25
+ url: "/subdivisions",
26
+ data: { country_code: $(this).val() }
27
+ }).success(function(newSubdivisions) {
28
+ self._clearSubdivisionSelect();
29
+ self._updateSubdivisionSelect(newSubdivisions);
30
+ });
31
+ });
32
+ };
33
+
34
+ SubdivisionSelect.prototype._updateSubdivisionSelect = function(newSubdivisions) {
35
+ var self = this;
36
+ var isEmpty = $.isEmptyObject(newSubdivisions);
37
+
38
+ $.each(newSubdivisions, function(alpha2, name) {
39
+ self._subdivisionSelect.append($("<option></option>").attr("value", alpha2).text(name));
40
+ });
41
+
42
+ // Disable the select if there are no newSubdivisions (and un-do that once there are some)
43
+ self._subdivisionSelect.prop("disabled", isEmpty);
44
+
45
+ // If there are none, make it say "none"
46
+ if (isEmpty) {
47
+ self._subdivisionSelect.append($("<option></option>").text("none"));
48
+ }
49
+ };
50
+
51
+ // Not only empty the select, but:
52
+ // if the first element is blank, add a blank element before all others
53
+ SubdivisionSelect.prototype._clearSubdivisionSelect = function() {
54
+ var includeBlank = this._subdivisionSelect.children().first().text() === "";
55
+
56
+ this._subdivisionSelect.empty();
57
+
58
+ if (includeBlank) {
59
+ this._subdivisionSelect.append($("<option></option>"));
60
+ }
61
+ };
62
+
63
+ return SubdivisionSelect;
64
+ })();
65
+
66
+ $(function() {
67
+ SubdivisionSelect.init();
68
+ });
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,7 @@
1
+ module SubdivisionSelect
2
+ class SubdivisionsController < ApplicationController
3
+ def get
4
+ render json: SubdivisionsHelper::get_subdivisions(params[:country_code])
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ module SubdivisionSelect
2
+ module SubdivisionsHelper
3
+ def self.get_subdivisions(alpha2)
4
+ # The countries gem returns a hash, where:
5
+ # the keys are the ISO 3166-2 subdivision two letter codes
6
+ # and the value is a hash with two key/values:
7
+ # - "name" is the most popular/most correct name
8
+ # - "names" is an array of all the names
9
+ if Country[alpha2].nil?
10
+ {}
11
+ else
12
+ Country[alpha2].subdivisions.map { |k, v| [k, v["name"]] }.to_h
13
+ end
14
+ end
15
+
16
+ def self.get_subdivisions_for_select(alpha2)
17
+ get_subdivisions(alpha2).invert.to_a
18
+ end
19
+ end
20
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ SubdivisionSelect::Engine.routes.draw do
2
+ get "/", to: "subdivisions#get"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "subdivision_select/engine"
2
+
3
+ module SubdivisionSelect
4
+ end
@@ -0,0 +1,21 @@
1
+ require "subdivision_select/subdivision_select_helper"
2
+
3
+ module SubdivisionSelect
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace SubdivisionSelect
6
+
7
+ require "jquery-rails"
8
+ # "country_select" requires "countries", but it's separated here because:
9
+ # - `countries` is used directly
10
+ # - `country_select` is so users don't have to add country_select to their
11
+ # Gemfile, since it's required
12
+ # (so we could have just included the latter, but this is more clear)
13
+ require "countries"
14
+ require "country_select"
15
+
16
+ config.generators do |g|
17
+ g.test_framework :rspec
18
+ g.fixture_replacement :factory_girl, dir: "spec/factories"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ module ActionView
2
+ module Helpers
3
+ class FormBuilder
4
+ def subdivision_select(method, country_or_options = {}, options = {}, html_options = {})
5
+ # Shift args, if necessary
6
+ if Hash === country_or_options
7
+ html_options = options
8
+ options = country_or_options
9
+ else
10
+ country = country_or_options
11
+ end
12
+
13
+ # Add class (that JS uses)
14
+ if html_options["class"].present?
15
+ html_options["class"] += " subdivision-selector"
16
+ else
17
+ html_options["class"] = "subdivision-selector"
18
+ end
19
+
20
+ Tags::Select.new(
21
+ @object_name,
22
+ method,
23
+ self,
24
+ SubdivisionSelect::SubdivisionsHelper::get_subdivisions_for_select(country),
25
+ options,
26
+ html_options
27
+ ).render
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module SubdivisionSelect
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :subdivision_select do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,22 @@
1
+ require "rails_helper"
2
+
3
+ module SubdivisionSelect
4
+ RSpec.describe SubdivisionsController, type: :controller do
5
+ routes { SubdivisionSelect::Engine.routes }
6
+
7
+ describe "GET #get" do
8
+ it "returns http success in JSON, when correct param supplied" do
9
+ get :get, country_code: "IE"
10
+ expect(response).to have_http_status(:success)
11
+ expect(response.content_type).to eq("application/json")
12
+ end
13
+
14
+ it "returns http success in JSON, w/o correct param supplied" do
15
+ get :get
16
+ expect(response).to have_http_status(:success)
17
+ expect(response.content_type).to eq("application/json")
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ require "rails_helper"
2
+
3
+ # Specs in this file have access to a helper object that includes
4
+ # the SubdivisionsHelper. For example:
5
+ #
6
+ # describe SubdivisionsHelper do
7
+ # describe "string concat" do
8
+ # it "concats two strings with spaces" do
9
+ # expect(helper.concat_strings("this","that")).to eq("this that")
10
+ # end
11
+ # end
12
+ # end
13
+ module SubdivisionSelect
14
+ RSpec.describe SubdivisionsHelper, type: :helper do
15
+ it "gets subdivisions for Germany" do
16
+ expect(SubdivisionsHelper::get_subdivisions("DE")["BE"]).to eq("Berlin")
17
+ expect(SubdivisionsHelper::get_subdivisions("DE").count).to eq(16)
18
+ end
19
+
20
+ # TODO: actually check if a select would be correct
21
+ it "gets subdivisions_for_select for Germany" do
22
+ german_states = SubdivisionsHelper::get_subdivisions("DE")
23
+ for_select = SubdivisionsHelper::get_subdivisions_for_select("DE")
24
+ expect(for_select).to eq(german_states.invert.to_a)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,53 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= "test"
3
+ require "spec_helper"
4
+ require File.expand_path("../../spec/test_app/config/environment", __FILE__)
5
+ require "rspec/rails"
6
+ require "capybara/rails"
7
+ require "capybara/rspec"
8
+
9
+ # Add additional requires below this line. Rails is not loaded until this point!
10
+
11
+ # Requires supporting ruby files with custom matchers and macros, etc, in
12
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
13
+ # run as spec files by default. This means that files in spec/support that end
14
+ # in _spec.rb will both be required and run as specs, causing the specs to be
15
+ # run twice. It is recommended that you do not name files matching this glob to
16
+ # end with _spec.rb. You can configure this pattern with the --pattern
17
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
18
+ #
19
+ # The following line is provided for convenience purposes. It has the downside
20
+ # of increasing the boot-up time by auto-requiring all files in the support
21
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
22
+ # require only the support files necessary.
23
+ #
24
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
25
+
26
+ # Checks for pending migrations before tests are run.
27
+ # If you are not using ActiveRecord, you can remove this line.
28
+ ActiveRecord::Migration.maintain_test_schema!
29
+
30
+ RSpec.configure do |config|
31
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
32
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
33
+
34
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
35
+ # examples within a transaction, remove the following line or assign false
36
+ # instead of true.
37
+ config.use_transactional_fixtures = true
38
+
39
+ # RSpec Rails can automatically mix in different behaviours to your tests
40
+ # based on their file location, for example enabling you to call `get` and
41
+ # `post` in specs under `spec/controllers`.
42
+ #
43
+ # You can disable this behaviour by removing the line below, and instead
44
+ # explicitly tag your specs with their type, e.g.:
45
+ #
46
+ # RSpec.describe UsersController, :type => :controller do
47
+ # # ...
48
+ # end
49
+ #
50
+ # The different available types are documented in the features, such as in
51
+ # https://relishapp.com/rspec/rspec-rails/docs
52
+ config.infer_spec_type_from_file_location!
53
+ end
@@ -0,0 +1,84 @@
1
+ # This file was generated by the `rails generate rspec:install` command.
2
+ # Conventionally, all specs live under a `spec` directory, which RSpec adds to
3
+ # the `$LOAD_PATH`. The generated `.rspec` file contains `--require spec_helper`
4
+ # which will cause this file to always be loaded, without a need to explicitly
5
+ # require it in any 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
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ # # These two settings work together to allow you to limit a spec run
46
+ # # to individual examples or groups you care about by tagging them with
47
+ # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
48
+ # # get run.
49
+ # config.filter_run :focus
50
+ # config.run_all_when_everything_filtered = true
51
+ #
52
+ # # Limits the available syntax to the non-monkey patched syntax that is
53
+ # # recommended. For more details, see:
54
+ # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
55
+ # # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3
56
+ # config.disable_monkey_patching!
57
+ #
58
+ # # Many RSpec users commonly either run the entire suite or an individual
59
+ # # file, and it's useful to allow more verbose output when running an
60
+ # # individual spec file.
61
+ # if config.files_to_run.one?
62
+ # # Use the documentation formatter for detailed output,
63
+ # # unless a formatter has already been configured
64
+ # # (e.g. via a command-line flag).
65
+ # config.default_formatter = 'doc'
66
+ # end
67
+ #
68
+ # # Print the 10 slowest examples and example groups at the
69
+ # # end of the spec run, to help surface which specs are running
70
+ # # particularly slow.
71
+ # config.profile_examples = 10
72
+ #
73
+ # # Run specs in random order to surface order dependencies. If you find an
74
+ # # order dependency and want to debug it, you can fix the order by
75
+ # # providing the seed, which is printed after each run.
76
+ # # --seed 1234
77
+ # config.order = :random
78
+ #
79
+ # # Seed global randomization in this process using the `--seed` CLI option.
80
+ # # Setting this allows you to use `--seed` to deterministically reproduce
81
+ # # test failures related to randomization by passing the same `--seed`
82
+ # # value as the one that triggered the failure.
83
+ # Kernel.srand config.seed
84
+ end