From 05caf152baeffdd5cf03587cbeb3d7a4ca08264d Mon Sep 17 00:00:00 2001 From: Mauro George Date: Sun, 20 Jul 2014 11:26:37 -0300 Subject: [PATCH] Update RSpec to 3 --- CHANGELOG.md | 12 +++-- filepicker_rails.gemspec | 2 +- spec/features/rails_integration_spec.rb | 4 +- spec/helpers/application_helper_spec.rb | 4 +- spec/helpers/form_helper_spec.rb | 5 +-- spec/lib/configuration_spec.rb | 4 +- spec/rails_helper.rb | 20 +++++++++ spec/spec_helper.rb | 58 +++++++------------------ spec/support/rails_versions.rb | 2 + 9 files changed, 54 insertions(+), 57 deletions(-) create mode 100644 spec/rails_helper.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index d040916..83522ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,18 @@ ## 1.1.1 (Unreleased) -### bug fixes - -- Do not modify original url when using cdn - ### features - filepicker_image_tag now works with policies +### improvements + +- update to RSpec 3 + +### bug fixes + +- Do not modify original url when using cdn + ## 1.1.0 (March 30, 2014) ### features diff --git a/filepicker_rails.gemspec b/filepicker_rails.gemspec index 0bd8c5d..3379fe6 100644 --- a/filepicker_rails.gemspec +++ b/filepicker_rails.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'coveralls' s.add_development_dependency 'sqlite3' - s.add_development_dependency 'rspec-rails', '2.99' + s.add_development_dependency 'rspec-rails' s.add_development_dependency 'timecop' s.add_development_dependency 'appraisal' s.add_development_dependency 'capybara' diff --git a/spec/features/rails_integration_spec.rb b/spec/features/rails_integration_spec.rb index 9b05d91..a5d0848 100644 --- a/spec/features/rails_integration_spec.rb +++ b/spec/features/rails_integration_spec.rb @@ -1,6 +1,6 @@ -require 'spec_helper' +require 'rails_helper' -feature 'Rails integration' do +RSpec.feature 'Rails integration' do background do visit '/' diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 969c707..86b2e4b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,6 +1,6 @@ -require 'spec_helper' +require 'rails_helper' -describe FilepickerRails::ApplicationHelper do +RSpec.describe FilepickerRails::ApplicationHelper do describe "#filepicker_js_include_tag" do diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb index a5aff33..fa60208 100644 --- a/spec/helpers/form_helper_spec.rb +++ b/spec/helpers/form_helper_spec.rb @@ -1,7 +1,6 @@ -require 'spec_helper' -require 'timecop' +require 'rails_helper' -describe FilepickerRails::FormHelper do +RSpec.describe FilepickerRails::FormHelper do let!(:form) do if rails_4_1_x? diff --git a/spec/lib/configuration_spec.rb b/spec/lib/configuration_spec.rb index 476265e..98428d1 100644 --- a/spec/lib/configuration_spec.rb +++ b/spec/lib/configuration_spec.rb @@ -1,6 +1,6 @@ -require 'spec_helper' +require 'rails_helper' -describe FilepickerRails::Configuration do +RSpec.describe FilepickerRails::Configuration do let!(:configuration) do FilepickerRails::Configuration.new diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..f04e281 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,20 @@ +ENV["RAILS_ENV"] ||= 'test' +require 'spec_helper' +require File.expand_path("../dummy/config/environment", __FILE__) +require 'rspec/rails' +require 'capybara/rails' +require 'capybara/rspec' + +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f } + +if RailsVersions.rails_4_1_x? + ActiveRecord::Migration.maintain_test_schema! +end + +RSpec.configure do |config| + config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! + config.render_views +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c8a8b10..9c759b3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,51 +1,23 @@ require 'coveralls' Coveralls.wear! -# This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= 'test' -require File.expand_path("../dummy/config/environment", __FILE__) -require 'rspec/rails' -require 'rspec/autorun' -require 'capybara/rails' -require 'capybara/rspec' +require 'timecop' require 'pry' -# Requires supporting ruby files with custom matchers and macros, etc, -# in spec/support/ and its subdirectories. -Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } -Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each do |file| - require file -end - RSpec.configure do |config| - # ## Mock Framework - # - # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: - # - # config.mock_with :mocha - # config.mock_with :flexmock - # config.mock_with :rr - - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = true - - # If true, the base class of anonymous controllers will be inferred - # automatically. This will be the default behavior in future versions of - # rspec-rails. - config.infer_base_class_for_anonymous_controllers = false - - # 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" - - config.expect_with :rspec do |c| - c.syntax = :expect + config.disable_monkey_patching! + config.order = :random + Kernel.srand config.seed + config.filter_run focus: true + config.run_all_when_everything_filtered = true + config.expect_with :rspec do |expectations| + expectations.syntax = :expect + end + config.mock_with :rspec do |mocks| + mocks.syntax = :expect + mocks.verify_partial_doubles = true + end + if config.files_to_run.one? + config.default_formatter = 'doc' end end diff --git a/spec/support/rails_versions.rb b/spec/support/rails_versions.rb index 62cd5b3..9270f44 100644 --- a/spec/support/rails_versions.rb +++ b/spec/support/rails_versions.rb @@ -2,10 +2,12 @@ module RailsVersions def rails_version Gem::Version.new(Rails::VERSION::STRING) end + module_function :rails_version def rails_4_1_x? Gem::Requirement.new('~> 4.1').satisfied_by?(rails_version) end + module_function :rails_4_1_x? end RSpec.configure do |config|