I'm running rails 4.1 and when I run rspec inside of guard, it give me the following error at the end:
invalid option: -f
minitest options:
-h, --help Display this help.
-s, --seed SEED Sets random seed
-v, --verbose Verbose. Show progress processing files.
-n, --name PATTERN Filter run on /pattern/ or string.
Known extensions: pride
-p, --pride Pride. Show your testing pride!
This is a minitest error, but as far as I can find, I'm not running minitest anywhere. Any idea where this might come from?
require 'rubygems'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
require 'monban/test/helpers'
require 'rails/test_help'
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
Monban.test_mode!
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.include FactoryGirl::Syntax::Methods
config.include Monban::Test::Helpers, type: :feature
config.include Monban::Test::ControllerHelpers, type: :controller
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.before :each do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.after :each do
Monban.test_reset!
end
end
guard :rspec, cmd: 'spring rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
Turns out, I was running minitest because of this line in my spec_helper
:
require 'rails/test_help'
Removing that makes it not run minitest. However, I added that line to keep my test schema up to date with my development schema, a new feature in Rails 4.1. What I should have done is removed this line from my spec_helper
:
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
and replaced it with this:
ActiveRecord::Migration.maintain_test_schema!
This seems to be the rspec equivalent to the minitest line that I removed. I found this in the rspec generators here: https://github.com/rspec/rspec-rails/blob/aa5c5f76a9ae847648f48e0ea7802b8e83c11d0f/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt#L15-L23
Now my schema stays up to date and minitest doesn't run.