How to test config method in this module with Rspec 3 mocks?
module TestModule
class << self
attr_accessor :config
end
def self.config
@config ||= Config.new
end
class Config
attr_accessor :money_url
def initialize
@money_url = "https://example1.come"
end
endend
I tried something like this:
describe "TestModule config" do
it "should have config instance" do
config = class_double("TestModule::Config")
obj = instance_double("TestModule")
allow(obj).to receive(:config).and_return(config)
obj.config
expect(obj.config).to eq(config)
endend
It looks, that it doesn't works, why ?
Failures:
1) TestModule config should have config instance Failure/Error:
allow(obj).to receive(:config).and_return(config) TestModule does not
implement: config # ./spec/config_spec.rb:41:in `block (2 levels) in '
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/9f42bc2d-cdce-4f44-b8d9-9ba777bdb38c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.