9. #!/usr/bin/env/rake
# …
if Rails.env.test? || Rails.env.development?
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new :spec
task :default do
sh "cp Gemfile.lock.rails3 Gemfile.lock"
sh "bundle install --quiet"
sh "rspec"
sh "cp Gemfile.lock.rails4 Gemfile.lock"
sh "RAILS4=y bundle install --quiet"
sh "RAILS4=t rspec"
sh "cp Gemfile.lock.rails3 Gemfile.lock"
sh "bundle install --quiet"
end
end
10. # spec/spec_helper.rb
require 'rspec/rails'
RSpec.configure do |config|
config.include Devise::TestHelpers, type: :config
config.include FactoryGirl::Syntax::Methods
config.around(:each, :rails3_only) do |example|
pending if ENV["RAILS4"]
example.run
end
end
# spec/models/person_spec.rb
it "requires an email address", :rails3_only do
# ...
end