mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Use new mock DSL
This commit is contained in:
parent
678f85eac1
commit
2bb9fe8dcd
10 changed files with 19 additions and 19 deletions
|
@ -7,10 +7,10 @@ Spectator.describe "GitHub Issue #28" do
|
|||
end
|
||||
end
|
||||
|
||||
mock Test
|
||||
mock MockTest < Test
|
||||
|
||||
it "matches method stubs with no_args" do
|
||||
test = mock(Test)
|
||||
test = MockTest.new
|
||||
expect(test).to receive(:foo).with(no_args).and_return(42)
|
||||
test.foo
|
||||
end
|
||||
|
|
|
@ -10,10 +10,10 @@ Spectator.describe "GitHub Issue #33" do
|
|||
end
|
||||
end
|
||||
|
||||
mock Test
|
||||
mock MockTest < Test
|
||||
|
||||
describe Test do
|
||||
subject { mock(Test) }
|
||||
subject { MockTest.new }
|
||||
|
||||
describe "#method1" do
|
||||
it do
|
||||
|
|
|
@ -25,11 +25,11 @@ class Sdk < SdkInterface
|
|||
end
|
||||
|
||||
Spectator.describe Example do
|
||||
mock Sdk
|
||||
mock MockSdk < Sdk
|
||||
|
||||
describe "#configure" do
|
||||
it "registers a block on configure" do
|
||||
sdk = mock(Sdk)
|
||||
sdk = MockSdk.new
|
||||
example_class = Example.new(sdk)
|
||||
allow(sdk).to receive(register_hook())
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@ class Dog
|
|||
end
|
||||
|
||||
Spectator.describe Person do
|
||||
mock Dog
|
||||
mock MockDog < Dog
|
||||
|
||||
describe "#pet" do
|
||||
it "pets the persons dog" do
|
||||
dog = mock(Dog)
|
||||
dog = MockDog.new
|
||||
person = Person.new(dog)
|
||||
allow(dog).to receive(pet()).and_return("woof")
|
||||
|
||||
|
@ -39,7 +39,7 @@ Spectator.describe Person do
|
|||
|
||||
describe "#pet_more" do
|
||||
it "pets the persons dog alot" do
|
||||
dog = mock(Dog)
|
||||
dog = MockDog.new
|
||||
person = Person.new(dog)
|
||||
allow(dog).to receive(pet()).and_return("woof")
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require "../spec_helper"
|
||||
|
||||
Spectator.describe "GitHub Issue #44" do
|
||||
inject_mock Process do
|
||||
mock! Process do
|
||||
# Instance variable that can be nil, provide a default.
|
||||
@process_info = Crystal::System::Process.new(0)
|
||||
end
|
||||
|
|
|
@ -7,9 +7,9 @@ Spectator.describe "GitHub Issue #47" do
|
|||
end
|
||||
end
|
||||
|
||||
mock Original
|
||||
mock TestMock < Original
|
||||
|
||||
let(fake) { mock(Original) }
|
||||
let(fake) { TestMock.new }
|
||||
|
||||
specify do
|
||||
expect(fake).to receive(:foo).with("arg1", arg2: "arg2")
|
||||
|
|
|
@ -44,9 +44,9 @@ Spectator.describe "GitHub Issue #48" do
|
|||
end
|
||||
end
|
||||
|
||||
mock Test, make_nilable: nil
|
||||
mock MockTest < Test, make_nilable: nil
|
||||
|
||||
let(fake) { mock(Test) }
|
||||
let(fake) { MockTest.new }
|
||||
|
||||
it "handles free variables" do
|
||||
allow(fake).to receive(:return_this).and_return("different")
|
||||
|
|
|
@ -24,9 +24,9 @@ Spectator.describe "GitHub Issue #55" do
|
|||
end
|
||||
end
|
||||
|
||||
double(:brain_talker, send: nil)
|
||||
double BrainTalker, send: nil
|
||||
|
||||
let(brain_talker) { double(:brain_talker) }
|
||||
let(brain_talker) { BrainTalker.new }
|
||||
let(analytics) { Analytics.new(brain_talker) }
|
||||
|
||||
it "tracks the time it takes to run the block" do
|
||||
|
|
|
@ -25,9 +25,9 @@ module GitLabIssue51
|
|||
end
|
||||
|
||||
Spectator.describe GitLabIssue51::Bar do
|
||||
mock GitLabIssue51::Foo, call: "", alt1_call: "", alt2_call: ""
|
||||
mock TestMock < GitLabIssue51::Foo, call: "", alt1_call: "", alt2_call: ""
|
||||
|
||||
let(:foo) { mock(GitLabIssue51::Foo) }
|
||||
let(:foo) { TestMock.new }
|
||||
subject(:call) { described_class.new.call(foo) }
|
||||
|
||||
describe "#call" do
|
||||
|
|
|
@ -22,7 +22,7 @@ Spectator.describe "test1" do
|
|||
end
|
||||
|
||||
Spectator.describe "test2" do
|
||||
mock Item do
|
||||
mock MockItem < Item do
|
||||
end
|
||||
|
||||
it "without mock" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue