Sha256: 2ffe2a15d08d03aea38b030e25948bca3dfd9c771cfe984b456a8e83dc62f7a9

Contents?: true

Size: 1.1 KB

Versions: 15

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'


describe Surrogate::RSpec::AbstractFailureMessage::ArgsInspector, 'argument inspection' do

  describe 'individual argument inspection inspection' do
    it 'inspects non RSpec matchers as their default inspection' do
      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
      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
      inspect_args([/a/]).should == "`/a/'"
    end

    it "joins arguments with commas" do
      inspect_args(['x', no_args]).should == "`\"x\", no args'"
    end

    it 'returns no_args when the array is empty' do
      inspect_args([]).should == "`no args'"
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
surrogate-0.8.1 spec/rspec/messages_spec.rb
surrogate-0.8.0 spec/rspec/messages_spec.rb
surrogate-0.7.0 spec/rspec/messages_spec.rb
surrogate-0.6.5 spec/rspec/messages_spec.rb
surrogate-0.6.4 spec/rspec/messages_spec.rb
surrogate-0.6.3 spec/rspec/messages_spec.rb
surrogate-0.6.2 spec/rspec/messages_spec.rb
surrogate-0.6.1 spec/rspec/messages_spec.rb
surrogate-0.6.0 spec/rspec/messages_spec.rb
surrogate-0.5.5 spec/rspec/messages_spec.rb
surrogate-0.5.4 spec/rspec/messages_spec.rb
surrogate-0.5.3 spec/rspec/messages_spec.rb
surrogate-0.5.2 spec/rspec/messages_spec.rb
surrogate-0.5.1 spec/rspec/messages_spec.rb
surrogate-0.5.0 spec/rspec/messages_spec.rb