From cfd4ad0b3a6d27fea186a5860514bf1a92c9bfce Mon Sep 17 00:00:00 2001 From: danny pham Date: Tue, 8 Mar 2016 20:39:18 -0800 Subject: [PATCH] upgrade rspec --- Gemfile | 2 +- Gemfile.lock | 6 +++--- spec/rails_helper.rb | 20 ++++++++++++++++---- spec/spec_helper.rb | 39 +++++++++++++++++++++++---------------- 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/Gemfile b/Gemfile index d7a3690ef..0798d9109 100755 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ end group :development, :test do gem 'pry' - gem 'rspec-rails', '3.4.1' + gem 'rspec-rails', '3.4.2' gem 'rspec-mocks', '3.4.1' gem 'test-unit', '~> 3.0' gem "dotenv-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 5854e61f8..24fd9f7e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,7 +52,7 @@ GEM arbre (1.0.3) activesupport (>= 3.0.0) arel (6.0.3) - bcrypt (3.1.10) + bcrypt (3.1.11) bourbon (4.2.6) sass (~> 3.4) thor (~> 0.19) @@ -179,7 +179,7 @@ GEM rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) - rspec-rails (3.4.1) + rspec-rails (3.4.2) actionpack (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3) railties (>= 3.0, < 4.3) @@ -235,7 +235,7 @@ DEPENDENCIES rails_12factor rails_serve_static_assets rspec-mocks (= 3.4.1) - rspec-rails (= 3.4.1) + rspec-rails (= 3.4.2) sass-rails (~> 5.0.1) test-unit (~> 3.0) uglifier diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5660ec5c4..03bfb8bb3 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,7 +1,9 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= 'test' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? require 'spec_helper' -require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! @@ -18,7 +20,12 @@ # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } + +# Checks for pending migration and applies them before tests are run. +# If you are not using ActiveRecord, you can remove this line. + +ActiveRecord::Migration.maintain_test_schema! RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures @@ -42,5 +49,10 @@ # # The different available types are documented in the features, such as in # https://relishapp.com/rspec/rspec-rails/docs - config.infer_spec_type_from_file_location! + # config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 275ba496f..58c59366a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,16 @@ # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause this -# file to always be loaded, without a need to explicitly require it in any files. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. # # Given that it is always loaded, you are encouraged to keep this file as # light-weight as possible. Requiring heavyweight dependencies from this file # will add to the boot time of your test suite on EVERY test run, even for an # individual file that may not need all of that loaded. Instead, consider making # a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need it. +# the additional setup, and require it from the spec files that actually need +# it. # # The `.rspec` file also contains a few flags that are not defaults but that # users commonly want. @@ -22,10 +24,10 @@ # This option will default to `true` in RSpec 4. It makes the `description` # and `failure_message` of custom matchers include text for helper methods # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" # ...rather than: - # # => "be bigger than 2" + # # => "be bigger than 2" expectations.include_chain_clauses_in_custom_matcher_descriptions = true end @@ -40,7 +42,7 @@ # The settings below are suggested to provide a good initial experience # with RSpec, but feel free to customize to your heart's content. -=begin + # These two settings work together to allow you to limit a spec run # to individual examples or groups you care about by tagging them with # `:focus` metadata. When nothing is tagged with `:focus`, all examples @@ -48,12 +50,17 @@ config.filter_run :focus config.run_all_when_everything_filtered = true - # Limits the available syntax to the non-monkey patched syntax that is recommended. - # For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + # config.disable_monkey_patching! # Many RSpec users commonly either run the entire suite or an individual # file, and it's useful to allow more verbose output when running an @@ -65,10 +72,10 @@ config.default_formatter = 'doc' end - # Print the 10 slowest examples and example groups at the + # Print the 3 slowest examples and example groups at the # end of the spec run, to help surface which specs are running # particularly slow. - config.profile_examples = 10 + config.profile_examples = 3 # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing @@ -81,5 +88,5 @@ # test failures related to randomization by passing the same `--seed` value # as the one that triggered the failure. Kernel.srand config.seed -=end + end