-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d030fb
commit dba2075
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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 | ||
mock TestFoo::TestClass do | ||
stub self.new | ||
stub test | ||
end | ||
|
||
it "must test when new is called" do | ||
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 |