super_diff 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +65 -26
 - data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
 - data/lib/super_diff/active_record/differs.rb +1 -1
 - data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +5 -13
 - data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +1 -3
 - data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
 - data/lib/super_diff/active_record/object_inspection.rb +1 -1
 - data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
 - data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
 - data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
 - data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
 - data/lib/super_diff/active_record/operation_trees.rb +1 -1
 - data/lib/super_diff/active_record.rb +7 -15
 - data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
 - data/lib/super_diff/active_support/differs.rb +1 -1
 - data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +3 -9
 - data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +1 -1
 - data/lib/super_diff/active_support/object_inspection.rb +1 -1
 - data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
 - data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
 - data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
 - data/lib/super_diff/active_support/operation_trees.rb +1 -1
 - data/lib/super_diff/active_support.rb +6 -11
 - data/lib/super_diff/colorized_document_extensions.rb +2 -4
 - data/lib/super_diff/configuration.rb +14 -8
 - data/lib/super_diff/csi/color.rb +4 -4
 - data/lib/super_diff/csi/colorized_document.rb +12 -16
 - data/lib/super_diff/csi/document.rb +8 -19
 - data/lib/super_diff/csi/eight_bit_color.rb +19 -19
 - data/lib/super_diff/csi/four_bit_color.rb +82 -31
 - data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
 - data/lib/super_diff/csi/uncolorized_document.rb +2 -6
 - data/lib/super_diff/csi.rb +10 -14
 - data/lib/super_diff/diff_formatters/collection.rb +35 -41
 - data/lib/super_diff/differs/default_object.rb +1 -1
 - data/lib/super_diff/differs/defaults.rb +1 -1
 - data/lib/super_diff/differs/main.rb +2 -13
 - data/lib/super_diff/equality_matchers/array.rb +10 -12
 - data/lib/super_diff/equality_matchers/base.rb +1 -1
 - data/lib/super_diff/equality_matchers/default.rb +2 -4
 - data/lib/super_diff/equality_matchers/defaults.rb +1 -1
 - data/lib/super_diff/equality_matchers/hash.rb +10 -12
 - data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
 - data/lib/super_diff/equality_matchers/primitive.rb +10 -12
 - data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
 - data/lib/super_diff/equality_matchers.rb +1 -1
 - data/lib/super_diff/errors.rb +3 -3
 - data/lib/super_diff/gem_version.rb +3 -3
 - data/lib/super_diff/helpers.rb +10 -10
 - data/lib/super_diff/implementation_checks.rb +2 -2
 - data/lib/super_diff/line.rb +3 -3
 - data/lib/super_diff/object_inspection/inspection_tree.rb +46 -60
 - data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +2 -6
 - data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +3 -9
 - data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +5 -14
 - data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -1
 - data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +4 -12
 - data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +6 -23
 - data/lib/super_diff/object_inspection/inspection_tree_builders.rb +9 -9
 - data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +8 -20
 - data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
 - data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
 - data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
 - data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
 - data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
 - data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
 - data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
 - data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
 - data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
 - data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
 - data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
 - data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
 - data/lib/super_diff/object_inspection/nodes.rb +7 -7
 - data/lib/super_diff/object_inspection.rb +3 -3
 - data/lib/super_diff/operation_tree_builders/array.rb +12 -11
 - data/lib/super_diff/operation_tree_builders/base.rb +17 -15
 - data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
 - data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
 - data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
 - data/lib/super_diff/operation_tree_builders/main.rb +4 -11
 - data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
 - data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
 - data/lib/super_diff/operation_tree_builders.rb +1 -1
 - data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
 - data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
 - data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
 - data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
 - data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
 - data/lib/super_diff/operation_tree_flatteners.rb +3 -3
 - data/lib/super_diff/operation_trees/base.rb +3 -5
 - data/lib/super_diff/operation_trees/default_object.rb +1 -3
 - data/lib/super_diff/operations/binary_operation.rb +2 -2
 - data/lib/super_diff/operations/unary_operation.rb +1 -1
 - data/lib/super_diff/rails.rb +2 -1
 - data/lib/super_diff/recursion_guard.rb +5 -4
 - data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
 - data/lib/super_diff/rspec/differ.rb +6 -13
 - data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
 - data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
 - data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
 - data/lib/super_diff/rspec/differs.rb +3 -3
 - data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
 - data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
 - data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
 - data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -5
 - data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
 - data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
 - data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
 - data/lib/super_diff/rspec/monkey_patches.rb +122 -116
 - data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +8 -6
 - data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +11 -16
 - data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +2 -1
 - data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +8 -6
 - data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +8 -6
 - data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +9 -9
 - data/lib/super_diff/rspec/object_inspection.rb +1 -1
 - data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
 - data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
 - data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
 - data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
 - data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
 - data/lib/super_diff/rspec.rb +11 -13
 - data/lib/super_diff/tiered_lines_elider.rb +87 -115
 - data/lib/super_diff/tiered_lines_formatter.rb +5 -9
 - data/lib/super_diff/version.rb +1 -1
 - data/lib/super_diff.rb +4 -9
 - data/spec/examples.txt +493 -485
 - data/spec/integration/rails/active_record_spec.rb +3 -1
 - data/spec/integration/rails/engines_spec.rb +20 -0
 - data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
 - data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
 - data/spec/integration/rspec/be_matcher_spec.rb +360 -320
 - data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
 - data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
 - data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
 - data/spec/integration/rspec/contain_exactly_matcher_spec.rb +242 -239
 - data/spec/integration/rspec/eq_matcher_spec.rb +595 -557
 - data/spec/integration/rspec/have_attributes_matcher_spec.rb +294 -286
 - data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
 - data/spec/integration/rspec/include_matcher_spec.rb +317 -215
 - data/spec/integration/rspec/match_array_matcher_spec.rb +276 -273
 - data/spec/integration/rspec/match_matcher_spec.rb +847 -834
 - data/spec/integration/rspec/raise_error_matcher_spec.rb +468 -453
 - data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
 - data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
 - data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
 - data/spec/spec_helper.rb +17 -20
 - data/spec/support/command_runner.rb +34 -57
 - data/spec/support/integration/helpers.rb +35 -28
 - data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
 - data/spec/support/integration/test_programs/base.rb +12 -17
 - data/spec/support/integration/test_programs/plain.rb +6 -0
 - data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
 - data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
 - data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
 - data/spec/support/integration/test_programs/rspec_rails_engine.rb +30 -0
 - data/spec/support/models/active_record/person.rb +6 -4
 - data/spec/support/models/active_record/shipping_address.rb +9 -10
 - data/spec/support/models/customer.rb +2 -4
 - data/spec/support/models/player.rb +3 -6
 - data/spec/support/models/shipping_address.rb +4 -13
 - data/spec/support/shared_examples/active_record.rb +232 -214
 - data/spec/support/shared_examples/active_support.rb +53 -51
 - data/spec/support/shared_examples/elided_diffs.rb +405 -381
 - data/spec/support/shared_examples/hash_with_indifferent_access.rb +424 -388
 - data/spec/support/shared_examples/key.rb +123 -0
 - data/spec/support/unit/helpers.rb +1 -3
 - data/spec/support/unit/matchers/match_output.rb +12 -13
 - data/spec/unit/active_record/object_inspection_spec.rb +222 -206
 - data/spec/unit/equality_matchers/main_spec.rb +1049 -984
 - data/spec/unit/helpers_spec.rb +14 -21
 - data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
 - data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
 - data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
 - data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
 - data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
 - data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
 - data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
 - data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
 - data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
 - data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
 - data/spec/unit/rspec/matchers/include_spec.rb +2 -2
 - data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
 - data/spec/unit/rspec/matchers/raise_error_spec.rb +5 -5
 - data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
 - data/spec/unit/rspec/object_inspection_spec.rb +349 -324
 - data/spec/unit/super_diff_spec.rb +1542 -1449
 - data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
 - data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
 - data/super_diff.gemspec +13 -12
 - metadata +73 -73
 - data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
 
| 
         @@ -1,46 +1,48 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "spec_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            RSpec.describe "Integration with RSpec's #have_attributes matcher", 
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            RSpec.describe "Integration with RSpec's #have_attributes matcher",
         
     | 
| 
      
 4 
     | 
    
         
            +
                           type: :integration do
         
     | 
| 
      
 5 
     | 
    
         
            +
              context "when the actual value is an object" do
         
     | 
| 
       5 
6 
     | 
    
         
             
                context "with a small set of attributes" do
         
     | 
| 
       6 
     | 
    
         
            -
                  context "when all of the names are methods on the actual 
     | 
| 
      
 7 
     | 
    
         
            +
                  context "when all of the names are methods on the actual object" do
         
     | 
| 
       7 
8 
     | 
    
         
             
                    it "produces the correct output when used in the positive" do
         
     | 
| 
       8 
9 
     | 
    
         
             
                      as_both_colored_and_uncolored do |color_enabled|
         
     | 
| 
       9 
10 
     | 
    
         
             
                        snippet = <<~TEST.strip
         
     | 
| 
       10 
11 
     | 
    
         
             
                          expected = { name: "b" }
         
     | 
| 
       11 
     | 
    
         
            -
                          actual 
     | 
| 
      
 12 
     | 
    
         
            +
                          actual = SuperDiff::Test::Person.new(name: "a", age: 9)
         
     | 
| 
       12 
13 
     | 
    
         
             
                          expect(actual).to have_attributes(expected)
         
     | 
| 
       13 
14 
     | 
    
         
             
                        TEST
         
     | 
| 
       14 
     | 
    
         
            -
                        program = 
     | 
| 
       15 
     | 
    
         
            -
                          snippet,
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                        program =
         
     | 
| 
      
 16 
     | 
    
         
            +
                          make_plain_test_program(snippet, color_enabled: color_enabled)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                        expected_output =
         
     | 
| 
      
 19 
     | 
    
         
            +
                          build_expected_output(
         
     | 
| 
      
 20 
     | 
    
         
            +
                            color_enabled: color_enabled,
         
     | 
| 
      
 21 
     | 
    
         
            +
                            snippet: "expect(actual).to have_attributes(expected)",
         
     | 
| 
      
 22 
     | 
    
         
            +
                            expectation:
         
     | 
| 
      
 23 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 24 
     | 
    
         
            +
                                line do
         
     | 
| 
      
 25 
     | 
    
         
            +
                                  plain "Expected "
         
     | 
| 
      
 26 
     | 
    
         
            +
                                  actual %|#<SuperDiff::Test::Person name: "a", age: 9>|
         
     | 
| 
      
 27 
     | 
    
         
            +
                                  plain " to have attributes "
         
     | 
| 
      
 28 
     | 
    
         
            +
                                  expected %|(name: "b")|
         
     | 
| 
      
 29 
     | 
    
         
            +
                                  plain "."
         
     | 
| 
      
 30 
     | 
    
         
            +
                                end
         
     | 
| 
      
 31 
     | 
    
         
            +
                              end,
         
     | 
| 
      
 32 
     | 
    
         
            +
                            diff:
         
     | 
| 
      
 33 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 34 
     | 
    
         
            +
                                plain_line "  #<SuperDiff::Test::Person {"
         
     | 
| 
      
 35 
     | 
    
         
            +
                                # expected_line %|-   name: "b",|  # FIXME
         
     | 
| 
      
 36 
     | 
    
         
            +
                                expected_line %|-   name: "b"|
         
     | 
| 
      
 37 
     | 
    
         
            +
                                actual_line %|+   name: "a",|
         
     | 
| 
      
 38 
     | 
    
         
            +
                                plain_line "    age: 9"
         
     | 
| 
      
 39 
     | 
    
         
            +
                                plain_line "  }>"
         
     | 
| 
      
 40 
     | 
    
         
            +
                              end
         
     | 
| 
      
 41 
     | 
    
         
            +
                          )
         
     | 
| 
       40 
42 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                        expect(program).
         
     | 
| 
       42 
     | 
    
         
            -
                           
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
                        expect(program).to produce_output_when_run(
         
     | 
| 
      
 44 
     | 
    
         
            +
                          expected_output
         
     | 
| 
      
 45 
     | 
    
         
            +
                        ).in_color(color_enabled)
         
     | 
| 
       44 
46 
     | 
    
         
             
                      end
         
     | 
| 
       45 
47 
     | 
    
         
             
                    end
         
     | 
| 
       46 
48 
     | 
    
         | 
| 
         @@ -48,83 +50,84 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ 
     | 
|
| 
       48 
50 
     | 
    
         
             
                      as_both_colored_and_uncolored do |color_enabled|
         
     | 
| 
       49 
51 
     | 
    
         
             
                        snippet = <<~TEST.strip
         
     | 
| 
       50 
52 
     | 
    
         
             
                          expected = { name: "a" }
         
     | 
| 
       51 
     | 
    
         
            -
                          actual 
     | 
| 
      
 53 
     | 
    
         
            +
                          actual = SuperDiff::Test::Person.new(name: "a", age: 9)
         
     | 
| 
       52 
54 
     | 
    
         
             
                          expect(actual).not_to have_attributes(expected)
         
     | 
| 
       53 
55 
     | 
    
         
             
                        TEST
         
     | 
| 
       54 
     | 
    
         
            -
                        program = 
     | 
| 
       55 
     | 
    
         
            -
                          snippet,
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
      
 56 
     | 
    
         
            +
                        program =
         
     | 
| 
      
 57 
     | 
    
         
            +
                          make_plain_test_program(snippet, color_enabled: color_enabled)
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                        expected_output =
         
     | 
| 
      
 60 
     | 
    
         
            +
                          build_expected_output(
         
     | 
| 
      
 61 
     | 
    
         
            +
                            color_enabled: color_enabled,
         
     | 
| 
      
 62 
     | 
    
         
            +
                            snippet: "expect(actual).not_to have_attributes(expected)",
         
     | 
| 
      
 63 
     | 
    
         
            +
                            expectation:
         
     | 
| 
      
 64 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 65 
     | 
    
         
            +
                                line do
         
     | 
| 
      
 66 
     | 
    
         
            +
                                  plain "Expected "
         
     | 
| 
      
 67 
     | 
    
         
            +
                                  actual %|#<SuperDiff::Test::Person name: "a", age: 9>|
         
     | 
| 
      
 68 
     | 
    
         
            +
                                  plain " not to have attributes "
         
     | 
| 
      
 69 
     | 
    
         
            +
                                  expected %|(name: "a")|
         
     | 
| 
      
 70 
     | 
    
         
            +
                                  plain "."
         
     | 
| 
      
 71 
     | 
    
         
            +
                                end
         
     | 
| 
      
 72 
     | 
    
         
            +
                              end
         
     | 
| 
      
 73 
     | 
    
         
            +
                          )
         
     | 
| 
       72 
74 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
                        expect(program).
         
     | 
| 
       74 
     | 
    
         
            -
                           
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
      
 75 
     | 
    
         
            +
                        expect(program).to produce_output_when_run(
         
     | 
| 
      
 76 
     | 
    
         
            +
                          expected_output
         
     | 
| 
      
 77 
     | 
    
         
            +
                        ).in_color(color_enabled)
         
     | 
| 
       76 
78 
     | 
    
         
             
                      end
         
     | 
| 
       77 
79 
     | 
    
         
             
                    end
         
     | 
| 
       78 
80 
     | 
    
         
             
                  end
         
     | 
| 
       79 
81 
     | 
    
         | 
| 
       80 
     | 
    
         
            -
                  context "when some of the names are not methods on the actual 
     | 
| 
      
 82 
     | 
    
         
            +
                  context "when some of the names are not methods on the actual object" do
         
     | 
| 
       81 
83 
     | 
    
         
             
                    it "produces the correct output" do
         
     | 
| 
       82 
84 
     | 
    
         
             
                      as_both_colored_and_uncolored do |color_enabled|
         
     | 
| 
       83 
85 
     | 
    
         
             
                        snippet = <<~TEST.strip
         
     | 
| 
       84 
86 
     | 
    
         
             
                          expected = { name: "b", foo: "bar" }
         
     | 
| 
       85 
     | 
    
         
            -
                          actual 
     | 
| 
      
 87 
     | 
    
         
            +
                          actual = SuperDiff::Test::Person.new(name: "a", age: 9)
         
     | 
| 
       86 
88 
     | 
    
         
             
                          expect(actual).to have_attributes(expected)
         
     | 
| 
       87 
89 
     | 
    
         
             
                        TEST
         
     | 
| 
       88 
     | 
    
         
            -
                        program = 
     | 
| 
       89 
     | 
    
         
            -
                          snippet,
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
      
 90 
     | 
    
         
            +
                        program =
         
     | 
| 
      
 91 
     | 
    
         
            +
                          make_plain_test_program(snippet, color_enabled: color_enabled)
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                        expected_output =
         
     | 
| 
      
 94 
     | 
    
         
            +
                          build_expected_output(
         
     | 
| 
      
 95 
     | 
    
         
            +
                            color_enabled: color_enabled,
         
     | 
| 
      
 96 
     | 
    
         
            +
                            snippet: "expect(actual).to have_attributes(expected)",
         
     | 
| 
      
 97 
     | 
    
         
            +
                            expectation:
         
     | 
| 
      
 98 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 99 
     | 
    
         
            +
                                line do
         
     | 
| 
      
 100 
     | 
    
         
            +
                                  plain "Expected "
         
     | 
| 
      
 101 
     | 
    
         
            +
                                  actual %|#<SuperDiff::Test::Person name: "a", age: 9>|
         
     | 
| 
      
 102 
     | 
    
         
            +
                                  plain " to respond to "
         
     | 
| 
      
 103 
     | 
    
         
            +
                                  expected ":foo"
         
     | 
| 
      
 104 
     | 
    
         
            +
                                  plain " with "
         
     | 
| 
      
 105 
     | 
    
         
            +
                                  expected "0"
         
     | 
| 
      
 106 
     | 
    
         
            +
                                  plain " arguments."
         
     | 
| 
      
 107 
     | 
    
         
            +
                                end
         
     | 
| 
      
 108 
     | 
    
         
            +
                              end,
         
     | 
| 
      
 109 
     | 
    
         
            +
                            diff:
         
     | 
| 
      
 110 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 111 
     | 
    
         
            +
                                plain_line "  #<SuperDiff::Test::Person {"
         
     | 
| 
      
 112 
     | 
    
         
            +
                                plain_line %|    name: "a",|
         
     | 
| 
      
 113 
     | 
    
         
            +
                                # plain_line    %|    age: 9,|  # FIXME
         
     | 
| 
      
 114 
     | 
    
         
            +
                                plain_line "    age: 9"
         
     | 
| 
      
 115 
     | 
    
         
            +
                                # expected_line %|-   foo: "bar"|  # FIXME
         
     | 
| 
      
 116 
     | 
    
         
            +
                                expected_line %|-   foo: "bar",|
         
     | 
| 
      
 117 
     | 
    
         
            +
                                plain_line "  }>"
         
     | 
| 
      
 118 
     | 
    
         
            +
                              end
         
     | 
| 
      
 119 
     | 
    
         
            +
                          )
         
     | 
| 
       117 
120 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
                        expect(program).
         
     | 
| 
       119 
     | 
    
         
            -
                           
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
      
 121 
     | 
    
         
            +
                        expect(program).to produce_output_when_run(
         
     | 
| 
      
 122 
     | 
    
         
            +
                          expected_output
         
     | 
| 
      
 123 
     | 
    
         
            +
                        ).in_color(color_enabled)
         
     | 
| 
       121 
124 
     | 
    
         
             
                      end
         
     | 
| 
       122 
125 
     | 
    
         
             
                    end
         
     | 
| 
       123 
126 
     | 
    
         
             
                  end
         
     | 
| 
       124 
127 
     | 
    
         
             
                end
         
     | 
| 
       125 
128 
     | 
    
         | 
| 
       126 
129 
     | 
    
         
             
                context "with a large set of attributes" do
         
     | 
| 
       127 
     | 
    
         
            -
                  context "when all of the names are methods on the actual 
     | 
| 
      
 130 
     | 
    
         
            +
                  context "when all of the names are methods on the actual object" do
         
     | 
| 
       128 
131 
     | 
    
         
             
                    it "produces the correct output when used in the positive" do
         
     | 
| 
       129 
132 
     | 
    
         
             
                      as_both_colored_and_uncolored do |color_enabled|
         
     | 
| 
       130 
133 
     | 
    
         
             
                        snippet = <<~TEST.strip
         
     | 
| 
         @@ -134,7 +137,7 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ 
     | 
|
| 
       134 
137 
     | 
    
         
             
                            state: "CA",
         
     | 
| 
       135 
138 
     | 
    
         
             
                            zip: "91234"
         
     | 
| 
       136 
139 
     | 
    
         
             
                          }
         
     | 
| 
       137 
     | 
    
         
            -
                          actual 
     | 
| 
      
 140 
     | 
    
         
            +
                          actual = SuperDiff::Test::ShippingAddress.new(
         
     | 
| 
       138 
141 
     | 
    
         
             
                            line_1: "456 Ponderosa Ct.",
         
     | 
| 
       139 
142 
     | 
    
         
             
                            line_2: nil,
         
     | 
| 
       140 
143 
     | 
    
         
             
                            city: "Hill Valley",
         
     | 
| 
         @@ -143,42 +146,43 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ 
     | 
|
| 
       143 
146 
     | 
    
         
             
                          )
         
     | 
| 
       144 
147 
     | 
    
         
             
                          expect(actual).to have_attributes(expected)
         
     | 
| 
       145 
148 
     | 
    
         
             
                        TEST
         
     | 
| 
       146 
     | 
    
         
            -
                        program = 
     | 
| 
       147 
     | 
    
         
            -
                          snippet,
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
                         
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
             
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
      
 149 
     | 
    
         
            +
                        program =
         
     | 
| 
      
 150 
     | 
    
         
            +
                          make_plain_test_program(snippet, color_enabled: color_enabled)
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                        expected_output =
         
     | 
| 
      
 153 
     | 
    
         
            +
                          build_expected_output(
         
     | 
| 
      
 154 
     | 
    
         
            +
                            color_enabled: color_enabled,
         
     | 
| 
      
 155 
     | 
    
         
            +
                            snippet: "expect(actual).to have_attributes(expected)",
         
     | 
| 
      
 156 
     | 
    
         
            +
                            expectation:
         
     | 
| 
      
 157 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 158 
     | 
    
         
            +
                                line do
         
     | 
| 
      
 159 
     | 
    
         
            +
                                  plain "          Expected "
         
     | 
| 
      
 160 
     | 
    
         
            +
                                  actual %|#<SuperDiff::Test::ShippingAddress line_1: "456 Ponderosa Ct.", line_2: nil, city: "Hill Valley", state: "CA", zip: "90382">|
         
     | 
| 
      
 161 
     | 
    
         
            +
                                end
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                                line do
         
     | 
| 
      
 164 
     | 
    
         
            +
                                  plain "to have attributes "
         
     | 
| 
      
 165 
     | 
    
         
            +
                                  expected %|(line_1: "123 Main St.", city: "Oakland", state: "CA", zip: "91234")|
         
     | 
| 
      
 166 
     | 
    
         
            +
                                end
         
     | 
| 
      
 167 
     | 
    
         
            +
                              end,
         
     | 
| 
      
 168 
     | 
    
         
            +
                            diff:
         
     | 
| 
      
 169 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 170 
     | 
    
         
            +
                                plain_line "  #<SuperDiff::Test::ShippingAddress {"
         
     | 
| 
      
 171 
     | 
    
         
            +
                                expected_line %|-   line_1: "123 Main St.",|
         
     | 
| 
      
 172 
     | 
    
         
            +
                                actual_line %|+   line_1: "456 Ponderosa Ct.",|
         
     | 
| 
      
 173 
     | 
    
         
            +
                                plain_line "    line_2: nil,"
         
     | 
| 
      
 174 
     | 
    
         
            +
                                expected_line %|-   city: "Oakland",|
         
     | 
| 
      
 175 
     | 
    
         
            +
                                actual_line %|+   city: "Hill Valley",|
         
     | 
| 
      
 176 
     | 
    
         
            +
                                plain_line %|    state: "CA",|
         
     | 
| 
      
 177 
     | 
    
         
            +
                                expected_line %|-   zip: "91234",| # FIXME
         
     | 
| 
      
 178 
     | 
    
         
            +
                                actual_line %|+   zip: "90382"|
         
     | 
| 
      
 179 
     | 
    
         
            +
                                plain_line "  }>"
         
     | 
| 
      
 180 
     | 
    
         
            +
                              end
         
     | 
| 
      
 181 
     | 
    
         
            +
                          )
         
     | 
| 
       178 
182 
     | 
    
         | 
| 
       179 
     | 
    
         
            -
                        expect(program).
         
     | 
| 
       180 
     | 
    
         
            -
                           
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
      
 183 
     | 
    
         
            +
                        expect(program).to produce_output_when_run(
         
     | 
| 
      
 184 
     | 
    
         
            +
                          expected_output
         
     | 
| 
      
 185 
     | 
    
         
            +
                        ).in_color(color_enabled)
         
     | 
| 
       182 
186 
     | 
    
         
             
                      end
         
     | 
| 
       183 
187 
     | 
    
         
             
                    end
         
     | 
| 
       184 
188 
     | 
    
         | 
| 
         @@ -191,7 +195,7 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ 
     | 
|
| 
       191 
195 
     | 
    
         
             
                            state: "CA",
         
     | 
| 
       192 
196 
     | 
    
         
             
                            zip: "91234"
         
     | 
| 
       193 
197 
     | 
    
         
             
                          }
         
     | 
| 
       194 
     | 
    
         
            -
                          actual 
     | 
| 
      
 198 
     | 
    
         
            +
                          actual = SuperDiff::Test::ShippingAddress.new(
         
     | 
| 
       195 
199 
     | 
    
         
             
                            line_1: "123 Main St.",
         
     | 
| 
       196 
200 
     | 
    
         
             
                            line_2: nil,
         
     | 
| 
       197 
201 
     | 
    
         
             
                            city: "Oakland",
         
     | 
| 
         @@ -200,36 +204,36 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ 
     | 
|
| 
       200 
204 
     | 
    
         
             
                          )
         
     | 
| 
       201 
205 
     | 
    
         
             
                          expect(actual).not_to have_attributes(expected)
         
     | 
| 
       202 
206 
     | 
    
         
             
                        TEST
         
     | 
| 
       203 
     | 
    
         
            -
                        program = 
     | 
| 
       204 
     | 
    
         
            -
                          snippet,
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
                         
     | 
| 
       207 
     | 
    
         
            -
             
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
       209 
     | 
    
         
            -
             
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
     | 
    
         
            -
             
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
             
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
             
     | 
| 
       221 
     | 
    
         
            -
             
     | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
      
 207 
     | 
    
         
            +
                        program =
         
     | 
| 
      
 208 
     | 
    
         
            +
                          make_plain_test_program(snippet, color_enabled: color_enabled)
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
                        expected_output =
         
     | 
| 
      
 211 
     | 
    
         
            +
                          build_expected_output(
         
     | 
| 
      
 212 
     | 
    
         
            +
                            color_enabled: color_enabled,
         
     | 
| 
      
 213 
     | 
    
         
            +
                            snippet: "expect(actual).not_to have_attributes(expected)",
         
     | 
| 
      
 214 
     | 
    
         
            +
                            newline_before_expectation: true,
         
     | 
| 
      
 215 
     | 
    
         
            +
                            expectation:
         
     | 
| 
      
 216 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 217 
     | 
    
         
            +
                                line do
         
     | 
| 
      
 218 
     | 
    
         
            +
                                  plain "              Expected "
         
     | 
| 
      
 219 
     | 
    
         
            +
                                  actual %|#<SuperDiff::Test::ShippingAddress line_1: "123 Main St.", line_2: nil, city: "Oakland", state: "CA", zip: "91234">|
         
     | 
| 
      
 220 
     | 
    
         
            +
                                end
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
                                line do
         
     | 
| 
      
 223 
     | 
    
         
            +
                                  plain "not to have attributes "
         
     | 
| 
      
 224 
     | 
    
         
            +
                                  expected %|(line_1: "123 Main St.", city: "Oakland", state: "CA", zip: "91234")|
         
     | 
| 
      
 225 
     | 
    
         
            +
                                end
         
     | 
| 
      
 226 
     | 
    
         
            +
                              end
         
     | 
| 
      
 227 
     | 
    
         
            +
                          )
         
     | 
| 
       224 
228 
     | 
    
         | 
| 
       225 
     | 
    
         
            -
                        expect(program).
         
     | 
| 
       226 
     | 
    
         
            -
                           
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
      
 229 
     | 
    
         
            +
                        expect(program).to produce_output_when_run(
         
     | 
| 
      
 230 
     | 
    
         
            +
                          expected_output
         
     | 
| 
      
 231 
     | 
    
         
            +
                        ).in_color(color_enabled)
         
     | 
| 
       228 
232 
     | 
    
         
             
                      end
         
     | 
| 
       229 
233 
     | 
    
         
             
                    end
         
     | 
| 
       230 
234 
     | 
    
         
             
                  end
         
     | 
| 
       231 
235 
     | 
    
         | 
| 
       232 
     | 
    
         
            -
                  context "when some of the names are not methods on the actual 
     | 
| 
      
 236 
     | 
    
         
            +
                  context "when some of the names are not methods on the actual object" do
         
     | 
| 
       233 
237 
     | 
    
         
             
                    it "produces the correct output" do
         
     | 
| 
       234 
238 
     | 
    
         
             
                      as_both_colored_and_uncolored do |color_enabled|
         
     | 
| 
       235 
239 
     | 
    
         
             
                        snippet = <<~TEST.strip
         
     | 
| 
         @@ -241,7 +245,7 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ 
     | 
|
| 
       241 
245 
     | 
    
         
             
                            foo: "bar",
         
     | 
| 
       242 
246 
     | 
    
         
             
                            baz: "qux"
         
     | 
| 
       243 
247 
     | 
    
         
             
                          }
         
     | 
| 
       244 
     | 
    
         
            -
                          actual 
     | 
| 
      
 248 
     | 
    
         
            +
                          actual = SuperDiff::Test::ShippingAddress.new(
         
     | 
| 
       245 
249 
     | 
    
         
             
                            line_1: "456 Ponderosa Ct.",
         
     | 
| 
       246 
250 
     | 
    
         
             
                            line_2: nil,
         
     | 
| 
       247 
251 
     | 
    
         
             
                            city: "Hill Valley",
         
     | 
| 
         @@ -250,92 +254,96 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ 
     | 
|
| 
       250 
254 
     | 
    
         
             
                          )
         
     | 
| 
       251 
255 
     | 
    
         
             
                          expect(actual).to have_attributes(expected)
         
     | 
| 
       252 
256 
     | 
    
         
             
                        TEST
         
     | 
| 
       253 
     | 
    
         
            -
                        program = 
     | 
| 
       254 
     | 
    
         
            -
                          snippet,
         
     | 
| 
       255 
     | 
    
         
            -
             
     | 
| 
       256 
     | 
    
         
            -
                         
     | 
| 
       257 
     | 
    
         
            -
             
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
       262 
     | 
    
         
            -
             
     | 
| 
       263 
     | 
    
         
            -
             
     | 
| 
       264 
     | 
    
         
            -
             
     | 
| 
       265 
     | 
    
         
            -
             
     | 
| 
       266 
     | 
    
         
            -
             
     | 
| 
       267 
     | 
    
         
            -
             
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
             
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
       273 
     | 
    
         
            -
             
     | 
| 
       274 
     | 
    
         
            -
             
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
       278 
     | 
    
         
            -
             
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
       280 
     | 
    
         
            -
             
     | 
| 
       281 
     | 
    
         
            -
             
     | 
| 
       282 
     | 
    
         
            -
             
     | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
       284 
     | 
    
         
            -
             
     | 
| 
       285 
     | 
    
         
            -
             
     | 
| 
       286 
     | 
    
         
            -
             
     | 
| 
       287 
     | 
    
         
            -
             
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
             
     | 
| 
       290 
     | 
    
         
            -
             
     | 
| 
      
 257 
     | 
    
         
            +
                        program =
         
     | 
| 
      
 258 
     | 
    
         
            +
                          make_plain_test_program(snippet, color_enabled: color_enabled)
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
                        expected_output =
         
     | 
| 
      
 261 
     | 
    
         
            +
                          build_expected_output(
         
     | 
| 
      
 262 
     | 
    
         
            +
                            color_enabled: color_enabled,
         
     | 
| 
      
 263 
     | 
    
         
            +
                            snippet: "expect(actual).to have_attributes(expected)",
         
     | 
| 
      
 264 
     | 
    
         
            +
                            expectation:
         
     | 
| 
      
 265 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 266 
     | 
    
         
            +
                                line do
         
     | 
| 
      
 267 
     | 
    
         
            +
                                  plain "     Expected "
         
     | 
| 
      
 268 
     | 
    
         
            +
                                  actual %|#<SuperDiff::Test::ShippingAddress line_1: "456 Ponderosa Ct.", line_2: nil, city: "Hill Valley", state: "CA", zip: "90382">|
         
     | 
| 
      
 269 
     | 
    
         
            +
                                end
         
     | 
| 
      
 270 
     | 
    
         
            +
             
     | 
| 
      
 271 
     | 
    
         
            +
                                line do
         
     | 
| 
      
 272 
     | 
    
         
            +
                                  plain "to respond to "
         
     | 
| 
      
 273 
     | 
    
         
            +
                                  expected ":foo"
         
     | 
| 
      
 274 
     | 
    
         
            +
                                  plain " and "
         
     | 
| 
      
 275 
     | 
    
         
            +
                                  expected ":baz"
         
     | 
| 
      
 276 
     | 
    
         
            +
                                  plain " with "
         
     | 
| 
      
 277 
     | 
    
         
            +
                                  expected "0"
         
     | 
| 
      
 278 
     | 
    
         
            +
                                  plain " arguments"
         
     | 
| 
      
 279 
     | 
    
         
            +
                                end
         
     | 
| 
      
 280 
     | 
    
         
            +
                              end,
         
     | 
| 
      
 281 
     | 
    
         
            +
                            diff:
         
     | 
| 
      
 282 
     | 
    
         
            +
                              proc do
         
     | 
| 
      
 283 
     | 
    
         
            +
                                plain_line "  #<SuperDiff::Test::ShippingAddress {"
         
     | 
| 
      
 284 
     | 
    
         
            +
                                plain_line %|    line_1: "456 Ponderosa Ct.",|
         
     | 
| 
      
 285 
     | 
    
         
            +
                                plain_line "    line_2: nil,"
         
     | 
| 
      
 286 
     | 
    
         
            +
                                plain_line %|    city: "Hill Valley",|
         
     | 
| 
      
 287 
     | 
    
         
            +
                                plain_line %|    state: "CA",|
         
     | 
| 
      
 288 
     | 
    
         
            +
                                # plain_line    %|    zip: "90382",|  # FIXME
         
     | 
| 
      
 289 
     | 
    
         
            +
                                plain_line %|    zip: "90382"|
         
     | 
| 
      
 290 
     | 
    
         
            +
                                expected_line %|-   foo: "bar",|
         
     | 
| 
      
 291 
     | 
    
         
            +
                                # expected_line %|-   baz: "qux"|  # TODO
         
     | 
| 
      
 292 
     | 
    
         
            +
                                expected_line %|-   baz: "qux",|
         
     | 
| 
      
 293 
     | 
    
         
            +
                                plain_line "  }>"
         
     | 
| 
      
 294 
     | 
    
         
            +
                              end
         
     | 
| 
      
 295 
     | 
    
         
            +
                          )
         
     | 
| 
       291 
296 
     | 
    
         | 
| 
       292 
     | 
    
         
            -
                        expect(program).
         
     | 
| 
       293 
     | 
    
         
            -
                           
     | 
| 
       294 
     | 
    
         
            -
             
     | 
| 
      
 297 
     | 
    
         
            +
                        expect(program).to produce_output_when_run(
         
     | 
| 
      
 298 
     | 
    
         
            +
                          expected_output
         
     | 
| 
      
 299 
     | 
    
         
            +
                        ).in_color(color_enabled)
         
     | 
| 
       295 
300 
     | 
    
         
             
                      end
         
     | 
| 
       296 
301 
     | 
    
         
             
                    end
         
     | 
| 
       297 
302 
     | 
    
         
             
                  end
         
     | 
| 
       298 
303 
     | 
    
         
             
                end
         
     | 
| 
       299 
304 
     | 
    
         
             
              end
         
     | 
| 
       300 
305 
     | 
    
         | 
| 
       301 
     | 
    
         
            -
              context "when the actual 
     | 
| 
      
 306 
     | 
    
         
            +
              context "when the actual value is actually a hash instead of an object" do
         
     | 
| 
       302 
307 
     | 
    
         
             
                it "displays the diff as if we were comparing hashes" do
         
     | 
| 
       303 
308 
     | 
    
         
             
                  as_both_colored_and_uncolored do |color_enabled|
         
     | 
| 
       304 
309 
     | 
    
         
             
                    snippet = <<~TEST.strip
         
     | 
| 
       305 
310 
     | 
    
         
             
                      expected = { name: "Elliot", age: 32 }
         
     | 
| 
       306 
     | 
    
         
            -
                      actual 
     | 
| 
      
 311 
     | 
    
         
            +
                      actual = {}
         
     | 
| 
       307 
312 
     | 
    
         
             
                      expect(actual).to have_attributes(expected)
         
     | 
| 
       308 
313 
     | 
    
         
             
                    TEST
         
     | 
| 
       309 
314 
     | 
    
         | 
| 
       310 
315 
     | 
    
         
             
                    program = make_plain_test_program(snippet, color_enabled: color_enabled)
         
     | 
| 
       311 
316 
     | 
    
         | 
| 
       312 
     | 
    
         
            -
                    expected_output = 
     | 
| 
       313 
     | 
    
         
            -
                       
     | 
| 
       314 
     | 
    
         
            -
             
     | 
| 
       315 
     | 
    
         
            -
             
     | 
| 
       316 
     | 
    
         
            -
                         
     | 
| 
       317 
     | 
    
         
            -
                           
     | 
| 
       318 
     | 
    
         
            -
             
     | 
| 
       319 
     | 
    
         
            -
             
     | 
| 
       320 
     | 
    
         
            -
             
     | 
| 
       321 
     | 
    
         
            -
             
     | 
| 
       322 
     | 
    
         
            -
             
     | 
| 
       323 
     | 
    
         
            -
             
     | 
| 
       324 
     | 
    
         
            -
             
     | 
| 
       325 
     | 
    
         
            -
             
     | 
| 
       326 
     | 
    
         
            -
             
     | 
| 
       327 
     | 
    
         
            -
             
     | 
| 
       328 
     | 
    
         
            -
             
     | 
| 
       329 
     | 
    
         
            -
             
     | 
| 
       330 
     | 
    
         
            -
                         
     | 
| 
       331 
     | 
    
         
            -
             
     | 
| 
       332 
     | 
    
         
            -
             
     | 
| 
       333 
     | 
    
         
            -
             
     | 
| 
       334 
     | 
    
         
            -
             
     | 
| 
      
 317 
     | 
    
         
            +
                    expected_output =
         
     | 
| 
      
 318 
     | 
    
         
            +
                      build_expected_output(
         
     | 
| 
      
 319 
     | 
    
         
            +
                        color_enabled: color_enabled,
         
     | 
| 
      
 320 
     | 
    
         
            +
                        snippet: "expect(actual).to have_attributes(expected)",
         
     | 
| 
      
 321 
     | 
    
         
            +
                        expectation:
         
     | 
| 
      
 322 
     | 
    
         
            +
                          proc do
         
     | 
| 
      
 323 
     | 
    
         
            +
                            line do
         
     | 
| 
      
 324 
     | 
    
         
            +
                              plain "Expected "
         
     | 
| 
      
 325 
     | 
    
         
            +
                              actual "{}"
         
     | 
| 
      
 326 
     | 
    
         
            +
                              plain " to respond to "
         
     | 
| 
      
 327 
     | 
    
         
            +
                              expected ":name"
         
     | 
| 
      
 328 
     | 
    
         
            +
                              plain " and "
         
     | 
| 
      
 329 
     | 
    
         
            +
                              expected ":age"
         
     | 
| 
      
 330 
     | 
    
         
            +
                              plain " with "
         
     | 
| 
      
 331 
     | 
    
         
            +
                              expected "0"
         
     | 
| 
      
 332 
     | 
    
         
            +
                              plain " arguments."
         
     | 
| 
      
 333 
     | 
    
         
            +
                            end
         
     | 
| 
      
 334 
     | 
    
         
            +
                          end,
         
     | 
| 
      
 335 
     | 
    
         
            +
                        diff:
         
     | 
| 
      
 336 
     | 
    
         
            +
                          proc do
         
     | 
| 
      
 337 
     | 
    
         
            +
                            plain_line "  {"
         
     | 
| 
      
 338 
     | 
    
         
            +
                            expected_line %|-   name: "Elliot",|
         
     | 
| 
      
 339 
     | 
    
         
            +
                            expected_line "-   age: 32"
         
     | 
| 
      
 340 
     | 
    
         
            +
                            plain_line "  }"
         
     | 
| 
      
 341 
     | 
    
         
            +
                          end
         
     | 
| 
      
 342 
     | 
    
         
            +
                      )
         
     | 
| 
       335 
343 
     | 
    
         | 
| 
       336 
     | 
    
         
            -
                    expect(program).
         
     | 
| 
       337 
     | 
    
         
            -
                       
     | 
| 
       338 
     | 
    
         
            -
             
     | 
| 
      
 344 
     | 
    
         
            +
                    expect(program).to produce_output_when_run(expected_output).in_color(
         
     | 
| 
      
 345 
     | 
    
         
            +
                      color_enabled
         
     | 
| 
      
 346 
     | 
    
         
            +
                    )
         
     | 
| 
       339 
347 
     | 
    
         
             
                  end
         
     | 
| 
       340 
348 
     | 
    
         
             
                end
         
     | 
| 
       341 
349 
     | 
    
         | 
| 
         @@ -357,77 +365,77 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ 
     | 
|
| 
       357 
365 
     | 
    
         
             
                          data: a_hash_including(active: true),
         
     | 
| 
       358 
366 
     | 
    
         
             
                          created_at: a_value_within(1).of(Time.utc(2020, 4, 9))
         
     | 
| 
       359 
367 
     | 
    
         
             
                        }
         
     | 
| 
       360 
     | 
    
         
            -
             
     | 
| 
       361 
     | 
    
         
            -
                        actual   = {}
         
     | 
| 
      
 368 
     | 
    
         
            +
                        actual = {}
         
     | 
| 
       362 
369 
     | 
    
         | 
| 
       363 
370 
     | 
    
         
             
                        expect(actual).to have_attributes(expected)
         
     | 
| 
       364 
371 
     | 
    
         
             
                      TEST
         
     | 
| 
       365 
372 
     | 
    
         | 
| 
       366 
     | 
    
         
            -
                      program = 
     | 
| 
       367 
     | 
    
         
            -
                        snippet,
         
     | 
| 
       368 
     | 
    
         
            -
                        color_enabled: color_enabled,
         
     | 
| 
       369 
     | 
    
         
            -
                      )
         
     | 
| 
      
 373 
     | 
    
         
            +
                      program =
         
     | 
| 
      
 374 
     | 
    
         
            +
                        make_plain_test_program(snippet, color_enabled: color_enabled)
         
     | 
| 
       370 
375 
     | 
    
         | 
| 
       371 
     | 
    
         
            -
                      expected_output = 
     | 
| 
       372 
     | 
    
         
            -
                         
     | 
| 
       373 
     | 
    
         
            -
             
     | 
| 
       374 
     | 
    
         
            -
             
     | 
| 
       375 
     | 
    
         
            -
                           
     | 
| 
       376 
     | 
    
         
            -
                             
     | 
| 
       377 
     | 
    
         
            -
             
     | 
| 
       378 
     | 
    
         
            -
             
     | 
| 
      
 376 
     | 
    
         
            +
                      expected_output =
         
     | 
| 
      
 377 
     | 
    
         
            +
                        build_expected_output(
         
     | 
| 
      
 378 
     | 
    
         
            +
                          color_enabled: color_enabled,
         
     | 
| 
      
 379 
     | 
    
         
            +
                          snippet: "expect(actual).to have_attributes(expected)",
         
     | 
| 
      
 380 
     | 
    
         
            +
                          expectation:
         
     | 
| 
      
 381 
     | 
    
         
            +
                            proc do
         
     | 
| 
      
 382 
     | 
    
         
            +
                              line do
         
     | 
| 
      
 383 
     | 
    
         
            +
                                plain "     Expected "
         
     | 
| 
      
 384 
     | 
    
         
            +
                                actual "{}"
         
     | 
| 
      
 385 
     | 
    
         
            +
                              end
         
     | 
| 
      
 386 
     | 
    
         
            +
             
     | 
| 
      
 387 
     | 
    
         
            +
                              line do
         
     | 
| 
      
 388 
     | 
    
         
            +
                                plain "to respond to "
         
     | 
| 
      
 389 
     | 
    
         
            +
                                expected ":name"
         
     | 
| 
      
 390 
     | 
    
         
            +
                                plain ", "
         
     | 
| 
      
 391 
     | 
    
         
            +
                                expected ":shipping_address"
         
     | 
| 
      
 392 
     | 
    
         
            +
                                plain ", "
         
     | 
| 
      
 393 
     | 
    
         
            +
                                expected ":order_ids"
         
     | 
| 
      
 394 
     | 
    
         
            +
                                plain ", "
         
     | 
| 
      
 395 
     | 
    
         
            +
                                expected ":data"
         
     | 
| 
      
 396 
     | 
    
         
            +
                                plain " and "
         
     | 
| 
      
 397 
     | 
    
         
            +
                                expected ":created_at"
         
     | 
| 
      
 398 
     | 
    
         
            +
                                plain " with "
         
     | 
| 
      
 399 
     | 
    
         
            +
                                expected "0"
         
     | 
| 
      
 400 
     | 
    
         
            +
                                plain " arguments"
         
     | 
| 
      
 401 
     | 
    
         
            +
                              end
         
     | 
| 
      
 402 
     | 
    
         
            +
                            end,
         
     | 
| 
      
 403 
     | 
    
         
            +
                          diff:
         
     | 
| 
      
 404 
     | 
    
         
            +
                            proc do
         
     | 
| 
      
 405 
     | 
    
         
            +
                              plain_line "  {"
         
     | 
| 
      
 406 
     | 
    
         
            +
                              expected_line %|-   name: "Elliot",|
         
     | 
| 
      
 407 
     | 
    
         
            +
                              expected_line "-   shipping_address: #<an object having attributes ("
         
     | 
| 
      
 408 
     | 
    
         
            +
                              expected_line "-     line_1: #<a kind of String>,"
         
     | 
| 
      
 409 
     | 
    
         
            +
                              expected_line "-     line_2: nil,"
         
     | 
| 
      
 410 
     | 
    
         
            +
                              expected_line "-     city: #<an instance of String>,"
         
     | 
| 
      
 411 
     | 
    
         
            +
                              expected_line %|-     state: "CA",|
         
     | 
| 
      
 412 
     | 
    
         
            +
                              expected_line %|-     zip: "91234"|
         
     | 
| 
      
 413 
     | 
    
         
            +
                              expected_line "-   )>,"
         
     | 
| 
      
 414 
     | 
    
         
            +
                              expected_line "-   order_ids: #<a collection including ("
         
     | 
| 
      
 415 
     | 
    
         
            +
                              expected_line "-     1,"
         
     | 
| 
      
 416 
     | 
    
         
            +
                              expected_line "-     2"
         
     | 
| 
      
 417 
     | 
    
         
            +
                              expected_line "-   )>,"
         
     | 
| 
      
 418 
     | 
    
         
            +
                              expected_line "-   data: #<a hash including ("
         
     | 
| 
      
 419 
     | 
    
         
            +
                              expected_line "-     active: true"
         
     | 
| 
      
 420 
     | 
    
         
            +
                              expected_line "-   )>,"
         
     | 
| 
      
 421 
     | 
    
         
            +
                              expected_line "-   created_at: #<a value within 1 of #<Time {"
         
     | 
| 
      
 422 
     | 
    
         
            +
                              expected_line "-     year: 2020,"
         
     | 
| 
      
 423 
     | 
    
         
            +
                              expected_line "-     month: 4,"
         
     | 
| 
      
 424 
     | 
    
         
            +
                              expected_line "-     day: 9,"
         
     | 
| 
      
 425 
     | 
    
         
            +
                              expected_line "-     hour: 0,"
         
     | 
| 
      
 426 
     | 
    
         
            +
                              expected_line "-     min: 0,"
         
     | 
| 
      
 427 
     | 
    
         
            +
                              expected_line "-     sec: 0,"
         
     | 
| 
      
 428 
     | 
    
         
            +
                              expected_line "-     subsec: 0,"
         
     | 
| 
      
 429 
     | 
    
         
            +
                              expected_line %|-     zone: "UTC",|
         
     | 
| 
      
 430 
     | 
    
         
            +
                              expected_line "-     utc_offset: 0"
         
     | 
| 
      
 431 
     | 
    
         
            +
                              expected_line "-   }>>"
         
     | 
| 
      
 432 
     | 
    
         
            +
                              plain_line "  }"
         
     | 
| 
      
 433 
     | 
    
         
            +
                            end
         
     | 
| 
      
 434 
     | 
    
         
            +
                        )
         
     | 
| 
       379 
435 
     | 
    
         | 
| 
       380 
     | 
    
         
            -
             
     | 
| 
       381 
     | 
    
         
            -
             
     | 
| 
       382 
     | 
    
         
            -
                            expected %|:name|
         
     | 
| 
       383 
     | 
    
         
            -
                            plain    %|, |
         
     | 
| 
       384 
     | 
    
         
            -
                            expected %|:shipping_address|
         
     | 
| 
       385 
     | 
    
         
            -
                            plain    %|, |
         
     | 
| 
       386 
     | 
    
         
            -
                            expected %|:order_ids|
         
     | 
| 
       387 
     | 
    
         
            -
                            plain    %|, |
         
     | 
| 
       388 
     | 
    
         
            -
                            expected %|:data|
         
     | 
| 
       389 
     | 
    
         
            -
                            plain    %| and |
         
     | 
| 
       390 
     | 
    
         
            -
                            expected %|:created_at|
         
     | 
| 
       391 
     | 
    
         
            -
                            plain    %| with |
         
     | 
| 
       392 
     | 
    
         
            -
                            expected %|0|
         
     | 
| 
       393 
     | 
    
         
            -
                            plain    %| arguments|
         
     | 
| 
       394 
     | 
    
         
            -
                          end
         
     | 
| 
       395 
     | 
    
         
            -
                        },
         
     | 
| 
       396 
     | 
    
         
            -
                        diff: proc {
         
     | 
| 
       397 
     | 
    
         
            -
                          plain_line    %|  {|
         
     | 
| 
       398 
     | 
    
         
            -
                          expected_line %|-   name: "Elliot",|
         
     | 
| 
       399 
     | 
    
         
            -
                          expected_line %|-   shipping_address: #<an object having attributes (|
         
     | 
| 
       400 
     | 
    
         
            -
                          expected_line %|-     line_1: #<a kind of String>,|
         
     | 
| 
       401 
     | 
    
         
            -
                          expected_line %|-     line_2: nil,|
         
     | 
| 
       402 
     | 
    
         
            -
                          expected_line %|-     city: #<an instance of String>,|
         
     | 
| 
       403 
     | 
    
         
            -
                          expected_line %|-     state: "CA",|
         
     | 
| 
       404 
     | 
    
         
            -
                          expected_line %|-     zip: "91234"|
         
     | 
| 
       405 
     | 
    
         
            -
                          expected_line %|-   )>,|
         
     | 
| 
       406 
     | 
    
         
            -
                          expected_line %|-   order_ids: #<a collection including (|
         
     | 
| 
       407 
     | 
    
         
            -
                          expected_line %|-     1,|
         
     | 
| 
       408 
     | 
    
         
            -
                          expected_line %|-     2|
         
     | 
| 
       409 
     | 
    
         
            -
                          expected_line %|-   )>,|
         
     | 
| 
       410 
     | 
    
         
            -
                          expected_line %|-   data: #<a hash including (|
         
     | 
| 
       411 
     | 
    
         
            -
                          expected_line %|-     active: true|
         
     | 
| 
       412 
     | 
    
         
            -
                          expected_line %|-   )>,|
         
     | 
| 
       413 
     | 
    
         
            -
                          expected_line %|-   created_at: #<a value within 1 of #<Time {|
         
     | 
| 
       414 
     | 
    
         
            -
                          expected_line %|-     year: 2020,|
         
     | 
| 
       415 
     | 
    
         
            -
                          expected_line %|-     month: 4,|
         
     | 
| 
       416 
     | 
    
         
            -
                          expected_line %|-     day: 9,|
         
     | 
| 
       417 
     | 
    
         
            -
                          expected_line %|-     hour: 0,|
         
     | 
| 
       418 
     | 
    
         
            -
                          expected_line %|-     min: 0,|
         
     | 
| 
       419 
     | 
    
         
            -
                          expected_line %|-     sec: 0,|
         
     | 
| 
       420 
     | 
    
         
            -
                          expected_line %|-     subsec: 0,|
         
     | 
| 
       421 
     | 
    
         
            -
                          expected_line %|-     zone: "UTC",|
         
     | 
| 
       422 
     | 
    
         
            -
                          expected_line %|-     utc_offset: 0|
         
     | 
| 
       423 
     | 
    
         
            -
                          expected_line %|-   }>>|
         
     | 
| 
       424 
     | 
    
         
            -
                          plain_line    %|  }|
         
     | 
| 
       425 
     | 
    
         
            -
                        },
         
     | 
| 
      
 436 
     | 
    
         
            +
                      expect(program).to produce_output_when_run(expected_output).in_color(
         
     | 
| 
      
 437 
     | 
    
         
            +
                        color_enabled
         
     | 
| 
       426 
438 
     | 
    
         
             
                      )
         
     | 
| 
       427 
     | 
    
         
            -
             
     | 
| 
       428 
     | 
    
         
            -
                      expect(program).
         
     | 
| 
       429 
     | 
    
         
            -
                        to produce_output_when_run(expected_output).
         
     | 
| 
       430 
     | 
    
         
            -
                        in_color(color_enabled)
         
     | 
| 
       431 
439 
     | 
    
         
             
                    end
         
     | 
| 
       432 
440 
     | 
    
         
             
                  end
         
     | 
| 
       433 
441 
     | 
    
         
             
                end
         
     |