spec/custom_matchers.rb in bencodr-3.0.0 vs spec/custom_matchers.rb in bencodr-3.0.1
- old
+ new
@@ -1,26 +1,28 @@
RSpec::Matchers.define :bencode_to do |expected|
match do |actual|
- actual.bencode.should equal(expected)
+ @got = actual.bencode
+ @got.should equal(expected)
end
failure_message_for_should do |actual|
- "expected that #{actual} would bencode to #{expected}"
+ "expected that #{actual.inspect} would bencode to #{expected.inspect}, but got #{@got.inspect}}"
end
end
RSpec::Matchers.define :bencode do |actual|
chain :to do |_expected|
@_expected = _expected
end
match do |klass|
- klass.bencode(actual).should == @_expected
+ @got = klass.bencode(actual)
+ @got.should == @_expected
end
failure_message_for_should do |klass|
- "expected #{klass.name} to bencode #{actual} to #{@_expected}"
+ "expected #{klass.name} to bencode #{actual.inspect} to #{@_expected.inspect}, but got #{@got.inspect}"
end
end
RSpec::Matchers.define :parse do |actual|
chain :as do |type|
@@ -31,14 +33,15 @@
@_expected = _expected
end
match do |klass|
scanner = StringScanner.new(actual)
- klass.send(:"parse_#{@type}", scanner).should == @_expected
+ @got = klass.send(:"parse_#{@type}", scanner)
+ @got.should == @_expected
end
failure_message_for_should do |klass|
- "expected #{klass.name} to bdencode #{actual} as #{@type} to #{@_expected}"
+ "expected #{klass.name} to bdencode #{actual.inspect} as #{@type} to #{@_expected.inspect}, but got #{@got.inspect}"
end
end
RSpec::Matchers.define :generate_parse_error do |expected|
chain :for do |type|
\ No newline at end of file