Lets suppose i have a class like this:
class Splitter
def split args
end
end
And another class like this one:
class Text
def initialize
Splitter.new.split([["first","234nnmer"],nil])
Splitter.new.split([["second","ewfr32$"],nil])
end
end
How would you test that when Text.new is called:
Splitter is called twice,one time with the argument "first" and another time with the argument "twice" in the argument array
I tried:
it "calls Splitter with arguments 'first' and 'second'" do
expect_any_instance_of(Splitter).to receive(
:split).with(array_including("first"))
expect_any_instance_of(Splitter).to receive(
:split).with(array_including("second"))
Text.new
end
This test doesn't work for me because I get errors like:
-["array_including(first)"]
+[["first","234nnmer"],nil]
Link: https://github.com/rspec/rspec-mocks#argument-matchers