Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
6 lib/lookout/difference/array.rb
@@ -13,4 +13,10 @@ def diff
new(Lookout::Diff::Algorithms::Difflib.
new(actual, expected))))
end
+
+ private
+
+ # @return [::String, super] The symbol ‘≉’ if {#actual} is an Array of the
+ # same #size as {#expected}, {super} otherwise
+ def symbol; Array === actual && expected.size == actual.size ? '' : super end
end
View
4 lib/lookout/difference/hash.rb
@@ -17,6 +17,10 @@ def diff
private
+ # @return [::String, super] The symbol ‘≉’ if {#actual} is a Hash of the same
+ # #size as {#expected}, {super} otherwise
+ def symbol; Hash === actual && expected.size == actual.size ? '' : super end
+
def array(hash)
hash.to_a.sort_by{ |key, _| key }.map{ |key, value|
[Lookout::Inspect.new(key, 'key'),
View
4 lib/lookout/difference/range.rb
@@ -6,7 +6,7 @@
class Lookout::Difference::Range < Lookout::Difference::Object
private
- # @return [::String, super] The symbol ‘∉’ unless {#actual} is a Range, {super}
- # otherwise
+ # @return [::String, super] The symbol ‘∉’ unless {#actual} is a Range,
+ # {super} otherwise
def symbol; Range === actual ? super : '' end
end
View
12 test/unit/lookout/difference/array.rb
@@ -1,6 +1,18 @@
# -*- coding: utf-8 -*-
Expectations do
+ expect '1≠[1]' do
+ [1].to_lookout_expected.difference(1).message
+ end
+
+ expect '[1]≠[1, 2]' do
+ [1, 2].to_lookout_expected.difference([1]).message
+ end
+
+ expect '[1, 3]≉[1, 2]' do
+ [1, 2].to_lookout_expected.difference([1, 3]).message
+ end
+
expect [] do
%w[abc].to_lookout_expected.difference(%w[def]).diff
end
View
12 test/unit/lookout/difference/hash.rb
@@ -1,6 +1,18 @@
# -*- coding: utf-8 -*-
Expectations do
+ expect %r'' do
+ {'a' => 1}.to_lookout_expected.difference('b').message
+ end
+
+ expect %r'' do
+ {'a' => 1, 'b' => 2}.to_lookout_expected.difference({'a' => 1}).message
+ end
+
+ expect %r'' do
+ {'a' => 1, 'b' => 2}.to_lookout_expected.difference({'a' => 1, 'b' => 3}).message
+ end
+
expect [] do
{'a' => Integer}.to_lookout_expected.difference({'b' => 1}).diff
end

No commit comments for this range

Something went wrong with that request. Please try again.