Is this just me or is the global behavior of RSpec when I call the scope of my rails model :public, initializes an object from this model and drowns out this rspec object
class DocumentName < ActiveRecord::Base
scope :public, lambda{where( public: true) }
end
nothing special, the Rails application is running
DocumentName.public # => [ #DN, #DN, #DN... ]
# SELECT `document_names`.* FROM `document_names` WHERE `document_names`.`public` = 1
however RSpec does not work
describe DocumentName do
let(:resource){DocumentName.new}
it do
resource.stub(:name).and_return('foo')
resource.save.should be true
end
end
Failure/Error: resource.stub(:name).and_return('foo')
ArgumentError:
wrong number of arguments (1 for 0)
... and the funny thing is, I am not doing anything with this area in this scenario.
However, if I call this area something else than :publicfor example :are_public::
class DocumentName < ActiveRecord::Base
scope :are_public, lambda{where( public: true) }
end
... everything goes O_O
Rails 3.2.11 (but same thing on any 3.2.x)
Ruby ruby-2.0.0-rc1 ( but same for any ruby-1.9.3)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
rspec-mocks (2.12.1)
rspec-rails (2.12.2)
source
share