spec/rspec/messages_spec.rb in surrogate-0.4.3 vs spec/rspec/messages_spec.rb in surrogate-0.5.0

- old
+ new

@@ -1,34 +1,37 @@ require 'spec_helper' -messages_for = Surrogate::RSpec::MessagesFor -describe messages_for, 'argument inspection' do +describe Surrogate::RSpec::AbstractFailureMessage::ArgsInspector, 'argument inspection' do describe 'individual argument inspection inspection' do it 'inspects non RSpec matchers as their default inspection' do - messages_for.inspect_argument("1").should == '"1"' - messages_for.inspect_argument(1).should == "1" - messages_for.inspect_argument([/a/]).should == "[/a/]" + described_class.inspect_argument("1").should == '"1"' + described_class.inspect_argument(1).should == "1" + described_class.inspect_argument([/a/]).should == "[/a/]" end it 'inspects rspec matchers' do - messages_for.inspect_argument(no_args).should == 'no args' - messages_for.inspect_argument(hash_including abc: 123).should == 'hash_including(:abc=>123)' + described_class.inspect_argument(no_args).should == 'no args' + described_class.inspect_argument(hash_including abc: 123).should == 'hash_including(:abc=>123)' end end describe 'multiple argument inspection' do + def inspect_args(args) + described_class.inspect Surrogate::Invocation.new(args) + end + it "wraps individual arguments in `'" do - messages_for.inspect_arguments([/a/]).should == "`/a/'" + inspect_args([/a/]).should == "`/a/'" end it "joins arguments with commas" do - messages_for.inspect_arguments(['x', no_args]).should == "`\"x\", no args'" + inspect_args(['x', no_args]).should == "`\"x\", no args'" end it 'returns no_args when the array is empty' do - messages_for.inspect_arguments([]).should == "`no args'" + inspect_args([]).should == "`no args'" end end end