File tree 6 files changed +74
-1
lines changed
unit/basic/inspection_tree_builders
6 files changed +74
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
- Improve inspection of Module. [ #263 ] ( https://github.com/splitwise/super_diff/pull/263 ) by [ @phorsuedzie ] ( https://github.com/phorsuedzie )
8
8
- Fix multiline string diff with blank lines. [ #266 ] ( https://github.com/splitwise/super_diff/pull/263 )
9
+ - Improve inspection of Range objects. [ #267 ] ( https://github.com/splitwise/super_diff/pull/267 )
9
10
10
11
## 0.13.0 - 2024-09-22
11
12
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ module Basic
27
27
InspectionTreeBuilders ::TimeLike ,
28
28
InspectionTreeBuilders ::DateLike ,
29
29
InspectionTreeBuilders ::DataObject ,
30
+ InspectionTreeBuilders ::RangeObject ,
30
31
InspectionTreeBuilders ::DefaultObject
31
32
)
32
33
Original file line number Diff line number Diff line change @@ -10,15 +10,19 @@ module InspectionTreeBuilders
10
10
:DataObject ,
11
11
"super_diff/basic/inspection_tree_builders/data_object"
12
12
)
13
+ autoload :DateLike , "super_diff/basic/inspection_tree_builders/date_like"
13
14
autoload (
14
15
:DefaultObject ,
15
16
"super_diff/basic/inspection_tree_builders/default_object"
16
17
)
17
18
autoload :Hash , "super_diff/basic/inspection_tree_builders/hash"
18
19
autoload :Primitive , "super_diff/basic/inspection_tree_builders/primitive"
20
+ autoload (
21
+ :RangeObject ,
22
+ "super_diff/basic/inspection_tree_builders/range_object"
23
+ )
19
24
autoload :String , "super_diff/basic/inspection_tree_builders/string"
20
25
autoload :TimeLike , "super_diff/basic/inspection_tree_builders/time_like"
21
- autoload :DateLike , "super_diff/basic/inspection_tree_builders/date_like"
22
26
end
23
27
end
24
28
end
Original file line number Diff line number Diff line change
1
+ module SuperDiff
2
+ module Basic
3
+ module InspectionTreeBuilders
4
+ class RangeObject < Core ::AbstractInspectionTreeBuilder
5
+ def self . applies_to? ( value )
6
+ value . is_a? ( Range )
7
+ end
8
+
9
+ def call
10
+ Core ::InspectionTree . new do |t1 |
11
+ t1 . as_lines_when_rendering_to_lines { |t2 | t2 . add_text object . to_s }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
Original file line number Diff line number Diff line change 1056
1056
end
1057
1057
end
1058
1058
1059
+ context "when comparing ranges" do
1060
+ it "produces the correct failure message when used in the positive" do
1061
+ as_both_colored_and_uncolored do |color_enabled |
1062
+ snippet = "expect(1..5).to eq(5..6)"
1063
+ program = make_plain_test_program ( snippet , color_enabled : color_enabled )
1064
+
1065
+ expected_output =
1066
+ build_expected_output (
1067
+ color_enabled : color_enabled ,
1068
+ snippet : snippet ,
1069
+ newline_before_expectation : true ,
1070
+ expectation :
1071
+ proc do
1072
+ line do
1073
+ plain "Expected "
1074
+ actual "1..5"
1075
+ plain " to eq "
1076
+ expected "5..6"
1077
+ plain "."
1078
+ end
1079
+ end ,
1080
+ diff : nil
1081
+ )
1082
+
1083
+ expect ( program ) . to produce_output_when_run ( expected_output ) . in_color (
1084
+ color_enabled
1085
+ )
1086
+ end
1087
+ end
1088
+ end
1089
+
1059
1090
it_behaves_like "a matcher that supports elided diffs" do
1060
1091
let ( :matcher ) { :eq }
1061
1092
end
Original file line number Diff line number Diff line change
1
+ require "spec_helper"
2
+
3
+ RSpec . describe SuperDiff , type : :unit do
4
+ describe ".inspect_object" do
5
+ context "given as_lines: false" do
6
+ subject ( :output ) do
7
+ described_class . inspect_object ( object , as_lines : false )
8
+ end
9
+
10
+ context "given a simple range" do
11
+ let ( :object ) { 1 ..5 }
12
+
13
+ it "shows the data" do
14
+ expect ( output ) . to eq ( "1..5" )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
You can’t perform that action at this time.
0 commit comments