I have the following RSpec (1.3.0) task defined in my Rakefile
:
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
spec.spec_files = FileList['spec/**/*_spec.rb']
end
I have the following in spec/spec_helper.rb
:
require 'rubygems'
require 'spec'
require 'spec/autorun'
require 'rack/test'
require 'webmock/rspec'
include Rack::Test::Methods
include WebMock
require 'omniauth/core'
I have a single spec declared in spec/foo/foo_spec.rb
:
require File.dirname(__FILE__) + '/../spec_helper'
describe Foo do
describe '#bar' do
it 'be bar-like' do
Foo.new.bar.should == 'bar'
end
end
end
When I run rake spec
, the single example runs twice. I can check it by making the example fail, giving me two red "F"s.
One thing I thought was that adding spec
to the SpecTask
's libs
was causing them to be double-defined, but removing that doesn't seem to have any effect.
A controller spec is an RSpec wrapper for a Rails functional test. (ActionController::TestCase::Behavior). It allows you to simulate a single http request in each example, and then. specify expected outcomes such as: rendered templates.
I use the database_cleaner gem to scrub my test database before each test runs, ensuring a clean slate and stable baseline every time. By default, RSpec will actually do this for you, running every test with a database transaction and then rolling back that transaction after it finishes.
How to stop running tests on the first failed test (fail fast tests in RSpec)? You may add a parameter to tell RSpec to stop running the test suite after N failed tests, for example: --fail-fast=3 . There is a downside to it.
I had this problem using zeus, and removing require 'rails/autorun'
from my spec_helper.rb
stopped it for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With