From 2bb9fe8dcdbf3654acb57a0dfd89433aeac10def Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 16 May 2024 21:02:14 -0600 Subject: [PATCH] Use new mock DSL --- spec/issues/github_issue_28_spec.cr | 4 ++-- spec/issues/github_issue_33_spec.cr | 4 ++-- spec/issues/github_issue_42_spec.cr | 4 ++-- spec/issues/github_issue_43_spec.cr | 6 +++--- spec/issues/github_issue_44_spec.cr | 2 +- spec/issues/github_issue_47_spec.cr | 4 ++-- spec/issues/github_issue_48_spec.cr | 4 ++-- spec/issues/github_issue_55_spec.cr | 4 ++-- spec/issues/gitlab_issue_51_spec.cr | 4 ++-- spec/issues/gitlab_issue_80_spec.cr | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spec/issues/github_issue_28_spec.cr b/spec/issues/github_issue_28_spec.cr index e6b6924..badc75a 100644 --- a/spec/issues/github_issue_28_spec.cr +++ b/spec/issues/github_issue_28_spec.cr @@ -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 diff --git a/spec/issues/github_issue_33_spec.cr b/spec/issues/github_issue_33_spec.cr index 656a273..895025a 100644 --- a/spec/issues/github_issue_33_spec.cr +++ b/spec/issues/github_issue_33_spec.cr @@ -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 diff --git a/spec/issues/github_issue_42_spec.cr b/spec/issues/github_issue_42_spec.cr index 58ff2b2..73fb85a 100644 --- a/spec/issues/github_issue_42_spec.cr +++ b/spec/issues/github_issue_42_spec.cr @@ -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()) diff --git a/spec/issues/github_issue_43_spec.cr b/spec/issues/github_issue_43_spec.cr index 45e2eb0..d996b6f 100644 --- a/spec/issues/github_issue_43_spec.cr +++ b/spec/issues/github_issue_43_spec.cr @@ -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") diff --git a/spec/issues/github_issue_44_spec.cr b/spec/issues/github_issue_44_spec.cr index da6cbf3..8fd4d07 100644 --- a/spec/issues/github_issue_44_spec.cr +++ b/spec/issues/github_issue_44_spec.cr @@ -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 diff --git a/spec/issues/github_issue_47_spec.cr b/spec/issues/github_issue_47_spec.cr index 3576a2d..5d7cf42 100644 --- a/spec/issues/github_issue_47_spec.cr +++ b/spec/issues/github_issue_47_spec.cr @@ -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") diff --git a/spec/issues/github_issue_48_spec.cr b/spec/issues/github_issue_48_spec.cr index b958c1b..faeb868 100644 --- a/spec/issues/github_issue_48_spec.cr +++ b/spec/issues/github_issue_48_spec.cr @@ -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") diff --git a/spec/issues/github_issue_55_spec.cr b/spec/issues/github_issue_55_spec.cr index 92c2b42..1872dc3 100644 --- a/spec/issues/github_issue_55_spec.cr +++ b/spec/issues/github_issue_55_spec.cr @@ -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 diff --git a/spec/issues/gitlab_issue_51_spec.cr b/spec/issues/gitlab_issue_51_spec.cr index 996af80..449a975 100644 --- a/spec/issues/gitlab_issue_51_spec.cr +++ b/spec/issues/gitlab_issue_51_spec.cr @@ -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 diff --git a/spec/issues/gitlab_issue_80_spec.cr b/spec/issues/gitlab_issue_80_spec.cr index 9090130..1de24af 100644 --- a/spec/issues/gitlab_issue_80_spec.cr +++ b/spec/issues/gitlab_issue_80_spec.cr @@ -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