Skip to content

Commit d16aa2a

Browse files
committed
silence warnings in specs
1 parent d4e2e3f commit d16aa2a

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

spec/integration/each_integration_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
before do
55
files = Dir.glob("./spec/fixtures/integration_app/app/interactors/each/**/*.rb")
66
files.each do |file|
7-
require file
7+
silence_warnings do
8+
load file
9+
end
810
end
911
end
1012

spec/lib/interactify.expect_spec.rb

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe Interactify do
44
describe ".expect" do
5-
class DummyInteractorClass
5+
self::DummyInteractorClass = Class.new do
66
include Interactify
77
expect :thing
88
expect :this, filled: false
@@ -18,10 +18,12 @@ def call; end
1818
end
1919
NOISY_CONTEXT = noisy_context
2020

21-
class AnotherDummyInteractorOrganizerClass
21+
this = self
22+
23+
self::AnotherDummyInteractorOrganizerClass = Class.new do
2224
include Interactify
2325

24-
organize DummyInteractorClass
26+
organize this::DummyInteractorClass
2527

2628
def call
2729
NOISY_CONTEXT.each do |k, v|
@@ -45,7 +47,7 @@ def call
4547
end
4648

4749
context "when using call" do
48-
let(:result) { AnotherDummyInteractorOrganizerClass.call }
50+
let(:result) { this::AnotherDummyInteractorOrganizerClass.call }
4951

5052
it "does not raise" do
5153
expect { result }.not_to raise_error
@@ -69,8 +71,8 @@ def self.log_error(exception); end
6971
end
7072

7173
it "raises a useful error", :aggregate_failures do
72-
expect { AnotherDummyInteractorOrganizerClass.call! }.to raise_error do |e|
73-
expect(e.class).to eq DummyInteractorClass::InteractorContractFailure
74+
expect { this::AnotherDummyInteractorOrganizerClass.call! }.to raise_error do |e|
75+
expect(e.class).to eq this::DummyInteractorClass::InteractorContractFailure
7476

7577
outputted_failures = JSON.parse(e.message)
7678

@@ -79,7 +81,7 @@ def self.log_error(exception); end
7981

8082
expect(@some_context).to eq NOISY_CONTEXT.symbolize_keys
8183
expect(@contract_failures).to eq contract_failures.symbolize_keys
82-
expect(@logged_exception).to be_a DummyInteractorClass::InteractorContractFailure
84+
expect(@logged_exception).to be_a this::DummyInteractorClass::InteractorContractFailure
8385
end
8486
end
8587
end

spec/lib/interactify/contracts/helpers.expect_spec.rb

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
# frozen_string_literal: true
22

33
RSpec.describe Interactify do
4-
describe ".expect" do
5-
class DummyInteractorClass
6-
include Interactify
7-
expect :thing
8-
expect :this, filled: false
4+
self::DummyInteractorClass = Class.new do
5+
include Interactify
6+
expect :thing
7+
expect :this, filled: false
98

10-
promise :another
9+
promise :another
1110

12-
def call
13-
context.another = thing
14-
end
11+
def call
12+
context.another = thing
1513
end
14+
end
1615

17-
class DummyOrganizerClass
18-
include Interactify
19-
expect :thing
20-
promise :another
16+
this = self
2117

22-
organize \
23-
DummyInteractorClass,
24-
DummyInteractorClass
25-
end
18+
self::DummyOrganizerClass = Class.new do
19+
include Interactify
20+
expect :thing
21+
promise :another
2622

23+
organize \
24+
this::DummyInteractorClass,
25+
this::DummyInteractorClass
26+
end
27+
28+
describe ".expect" do
2729
it "is simplified syntax for an expects block" do
28-
expect { DummyOrganizerClass.call! }.to raise_error DummyOrganizerClass::InteractorContractFailure
29-
result = DummyOrganizerClass.call!(thing: "thing", this: nil)
30+
expect { this::DummyOrganizerClass.call! }.to raise_error this::DummyOrganizerClass::InteractorContractFailure
31+
result = this::DummyOrganizerClass.call!(thing: "thing", this: nil)
3032
expect(result.another).to eq "thing"
3133
end
3234
end

0 commit comments

Comments
 (0)