diff options
| author | mo khan <mo@mokhan.ca> | 2014-06-10 20:41:42 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-06-10 20:41:42 -0600 |
| commit | 00b43f5fedc45ef837e287dcf41cacfe3e643375 (patch) | |
| tree | 3fe147344ad7aa6c2a2f350eb88374564c2bf98c | |
| parent | aada9bb4a1cc63307a994337a134715478863df7 (diff) | |
upgrade to rspec rails 3.0
| -rw-r--r-- | .rspec | 4 | ||||
| -rw-r--r-- | Gemfile | 2 | ||||
| -rw-r--r-- | Gemfile.lock | 27 | ||||
| -rw-r--r-- | spec/rails_helper.rb | 42 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 110 |
5 files changed, 133 insertions, 52 deletions
@@ -1 +1,3 @@ ---colour
\ No newline at end of file +--color +--warnings +--require spec_helper @@ -48,7 +48,7 @@ end group :development, :test do gem 'sqlite3' - gem 'rspec-rails', '2.99.0' + gem 'rspec-rails' gem 'teaspoon' gem 'database_cleaner' gem 'factory_girl_rails' diff --git a/Gemfile.lock b/Gemfile.lock index 3c5c8b46..3b6240a7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -225,21 +225,22 @@ GEM rdoc (4.1.1) json (~> 1.4) rmagick (2.13.2) - rspec-collection_matchers (1.0.0) - rspec-expectations (>= 2.99.0.beta1) - rspec-core (2.99.0) - rspec-expectations (2.99.0) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.99.0) - rspec-rails (2.99.0) + rspec-core (3.0.0) + rspec-support (~> 3.0.0) + rspec-expectations (3.0.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.0.0) + rspec-mocks (3.0.1) + rspec-support (~> 3.0.0) + rspec-rails (3.0.1) actionpack (>= 3.0) - activemodel (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-collection_matchers - rspec-core (~> 2.99.0) - rspec-expectations (~> 2.99.0) - rspec-mocks (~> 2.99.0) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-support (~> 3.0.0) + rspec-support (3.0.0) rubyzip (1.1.3) sass (3.2.19) sass-rails (4.0.3) @@ -357,7 +358,7 @@ DEPENDENCIES poltergeist rails (~> 4.0.5) rmagick (~> 2.13.0) - rspec-rails (= 2.99.0) + rspec-rails sass-rails (~> 4.0) sdoc selenium-webdriver diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 00000000..b1087032 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,42 @@ +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'rspec/autorun' +require 'capybara/rails' +require 'capybara/rspec' +require 'capybara/poltergeist' +require 'ffaker' +require 'database_cleaner' + +Capybara.register_driver :poltergeist do |app| + Capybara::Poltergeist::Driver.new(app, {:timeout => 60}) +end +Capybara.javascript_driver = :poltergeist if ENV['HEADLESS'] + +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} +RSpec.configure do |config| + config.mock_with :rspec + config.use_transactional_fixtures = false + config.infer_base_class_for_anonymous_controllers = false + config.order = "random" + config.include DeviseHelper::Controllers, :type => :controller + config.include Devise::TestHelpers, :type => :controller + config.include FactoryGirl::Syntax::Methods + config.before(:suite) do + DatabaseCleaner.clean_with(:truncation) + end + config.before(:each) do + DatabaseCleaner.strategy = :transaction + end + config.before(:each, :js => true) do + DatabaseCleaner.strategy = :truncation + end + config.before(:each) do + DatabaseCleaner.start + end + config.after(:each) do + DatabaseCleaner.clean + end + config.infer_spec_type_from_file_location! + config.raise_errors_for_deprecations! +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 95ad8753..0783cd23 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,45 +5,81 @@ SimpleCov.start 'rails' do add_filter '/vendor/' end -ENV["RAILS_ENV"] ||= 'test' -require File.expand_path("../../config/environment", __FILE__) -require 'rspec/rails' -require 'rspec/autorun' -require 'capybara/rails' -require 'capybara/rspec' -require 'capybara/poltergeist' -require 'ffaker' -require 'database_cleaner' - -Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new(app, {:timeout => 60}) -end -Capybara.javascript_driver = :poltergeist if ENV['HEADLESS'] - -Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} +# 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. +# +# 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, make a +# separate helper file that requires this one and then use it only in the specs +# that actually need it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - config.mock_with :rspec - config.use_transactional_fixtures = false - config.infer_base_class_for_anonymous_controllers = false - config.order = "random" - config.include DeviseHelper::Controllers, :type => :controller - config.include Devise::TestHelpers, :type => :controller - config.include FactoryGirl::Syntax::Methods - config.before(:suite) do - DatabaseCleaner.clean_with(:truncation) - end - config.before(:each) do - DatabaseCleaner.strategy = :transaction - end - config.before(:each, :js => true) do - DatabaseCleaner.strategy = :truncation +# 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 + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # 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 + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' end - config.before(:each) do - DatabaseCleaner.start + + # Print the 10 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 + + # 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 + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed + + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # Enable only the newer, non-monkey-patching expect syntax. + # For more details, see: + # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax + expectations.syntax = :expect end - config.after(:each) do - DatabaseCleaner.clean + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Enable only the newer, non-monkey-patching expect syntax. + # For more details, see: + # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + mocks.syntax = :expect + + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended. + mocks.verify_partial_doubles = true end - config.infer_spec_type_from_file_location! - config.raise_errors_for_deprecations! +=end end |
