2021-07-11 04:44:43 +00:00
|
|
|
require "../spec_helper"
|
|
|
|
|
|
|
|
Spectator.describe "GitHub Issue #32" do
|
|
|
|
module TestFoo
|
|
|
|
class TestClass
|
|
|
|
def initialize
|
|
|
|
end
|
|
|
|
|
|
|
|
# the method we are testing
|
|
|
|
def self.test
|
|
|
|
new().test
|
|
|
|
end
|
|
|
|
|
|
|
|
# the method we want to ensure gets called
|
|
|
|
def test
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
let(test_class) { TestFoo::TestClass }
|
|
|
|
let(test_instance) { test_class.new }
|
|
|
|
|
|
|
|
describe "something else" do
|
2022-07-13 04:30:04 +00:00
|
|
|
inject_mock TestFoo::TestClass
|
2021-07-11 04:44:43 +00:00
|
|
|
|
2022-07-13 04:30:04 +00:00
|
|
|
it "must test when new is called" do
|
2021-07-11 04:44:43 +00:00
|
|
|
expect(test_class).to receive(:new).with(no_args).and_return(test_instance)
|
|
|
|
expect(test_instance).to receive(:test)
|
|
|
|
expect(test_class.new).to be(test_instance)
|
|
|
|
|
|
|
|
test_class.test
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|