mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Merge remote-tracking branch 'origin/master' into release/0.10
This commit is contained in:
commit
6c55301d0b
11 changed files with 140 additions and 12 deletions
|
@ -17,4 +17,24 @@ Spectator.describe "GitHub Issue #29" do
|
|||
subject.goodbye
|
||||
end
|
||||
end
|
||||
|
||||
describe "class method" do
|
||||
class Foo
|
||||
def self.test
|
||||
exit 0
|
||||
end
|
||||
end
|
||||
|
||||
mock Foo do
|
||||
stub self.exit(code)
|
||||
end
|
||||
|
||||
subject { Foo }
|
||||
|
||||
it "must capture exit" do
|
||||
expect(subject).to receive(:exit).with(0)
|
||||
|
||||
subject.test
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
37
spec/issues/github_issue_32_spec.cr
Normal file
37
spec/issues/github_issue_32_spec.cr
Normal file
|
@ -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
|
26
spec/issues/github_issue_33_spec.cr
Normal file
26
spec/issues/github_issue_33_spec.cr
Normal file
|
@ -0,0 +1,26 @@
|
|||
require "../spec_helper"
|
||||
|
||||
Spectator.describe "GitHub Issue #33" do
|
||||
class Test
|
||||
def method2
|
||||
end
|
||||
|
||||
def method1
|
||||
method2
|
||||
end
|
||||
end
|
||||
|
||||
mock Test do
|
||||
stub method2
|
||||
end
|
||||
|
||||
describe Test do
|
||||
describe "#method1" do
|
||||
it do
|
||||
expect(subject).to receive(:method2)
|
||||
|
||||
subject.method1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue