At startup:
rake spec:models
everything works fine but when i do
rspec spec/models/spot_spec.rb
which has Spot.stub! :test1 Spot.stub! :test1 , I get:
undefined method `stub!' for Spot:Class
The error only happens when I turn on this stub! line.
Any ideas how to avoid this? I want to run specifications only for a specific model.
Update:
Using Ruby 1.9.2 and RSpec 2.4.0, here is the spot_spec.rb code:
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Spot do before(:all) do Spot.stub! :test1 @spot = Spot.new end subject {@spot} describe "validations" do it { should validate_presence_of(:user) } end end
And spec_helper.rb:
ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} RSpec.configure do |config| config.mock_with :rspec end
source share