super_diff 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/super_diff/active_record/differs/active_record_relation.rb +2 -0
- data/lib/super_diff/active_record/differs.rb +3 -1
- data/lib/super_diff/active_record/inspection_tree_builders/active_record_model.rb +7 -5
- data/lib/super_diff/active_record/inspection_tree_builders/active_record_relation.rb +12 -10
- data/lib/super_diff/active_record/inspection_tree_builders.rb +4 -2
- data/lib/super_diff/active_record/monkey_patches.rb +4 -2
- data/lib/super_diff/active_record/object_inspection.rb +6 -4
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +3 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +3 -1
- data/lib/super_diff/active_record/operation_tree_builders.rb +4 -2
- data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +4 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +3 -1
- data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +2 -0
- data/lib/super_diff/active_record/operation_trees.rb +3 -1
- data/lib/super_diff/active_record.rb +10 -8
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +2 -0
- data/lib/super_diff/active_support/differs.rb +3 -1
- data/lib/super_diff/active_support/inspection_tree_builders/hash_with_indifferent_access.rb +16 -14
- data/lib/super_diff/active_support/inspection_tree_builders/ordered_options.rb +16 -14
- data/lib/super_diff/active_support/inspection_tree_builders.rb +4 -2
- data/lib/super_diff/active_support/object_inspection.rb +6 -4
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +6 -4
- data/lib/super_diff/active_support/operation_tree_builders.rb +3 -1
- data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +4 -2
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +3 -1
- data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +2 -0
- data/lib/super_diff/active_support/operation_trees.rb +3 -1
- data/lib/super_diff/active_support.rb +8 -6
- data/lib/super_diff/basic/diff_formatters/collection.rb +18 -18
- data/lib/super_diff/basic/diff_formatters/multiline_string.rb +2 -0
- data/lib/super_diff/basic/diff_formatters.rb +4 -2
- data/lib/super_diff/basic/differs/array.rb +2 -0
- data/lib/super_diff/basic/differs/custom_object.rb +3 -1
- data/lib/super_diff/basic/differs/date_like.rb +2 -0
- data/lib/super_diff/basic/differs/default_object.rb +3 -1
- data/lib/super_diff/basic/differs/hash.rb +2 -0
- data/lib/super_diff/basic/differs/multiline_string.rb +2 -0
- data/lib/super_diff/basic/differs/time_like.rb +2 -0
- data/lib/super_diff/basic/differs.rb +11 -9
- data/lib/super_diff/basic/inspection_tree_builders/array.rb +5 -3
- data/lib/super_diff/basic/inspection_tree_builders/custom_object.rb +5 -3
- data/lib/super_diff/basic/inspection_tree_builders/data_object.rb +6 -4
- data/lib/super_diff/basic/inspection_tree_builders/date_like.rb +7 -5
- data/lib/super_diff/basic/inspection_tree_builders/default_object.rb +7 -5
- data/lib/super_diff/basic/inspection_tree_builders/hash.rb +7 -5
- data/lib/super_diff/basic/inspection_tree_builders/primitive.rb +2 -0
- data/lib/super_diff/basic/inspection_tree_builders/range_object.rb +19 -0
- data/lib/super_diff/basic/inspection_tree_builders/time_like.rb +8 -8
- data/lib/super_diff/basic/inspection_tree_builders.rb +15 -9
- data/lib/super_diff/basic/operation_tree_builders/array.rb +6 -4
- data/lib/super_diff/basic/operation_tree_builders/custom_object.rb +3 -1
- data/lib/super_diff/basic/operation_tree_builders/data_object.rb +4 -2
- data/lib/super_diff/basic/operation_tree_builders/date_like.rb +2 -0
- data/lib/super_diff/basic/operation_tree_builders/default_object.rb +32 -31
- data/lib/super_diff/basic/operation_tree_builders/hash.rb +49 -46
- data/lib/super_diff/basic/operation_tree_builders/multiline_string.rb +5 -3
- data/lib/super_diff/basic/operation_tree_builders/time_like.rb +5 -3
- data/lib/super_diff/basic/operation_tree_builders.rb +12 -10
- data/lib/super_diff/basic/operation_tree_flatteners/array.rb +4 -2
- data/lib/super_diff/basic/operation_tree_flatteners/collection.rb +11 -11
- data/lib/super_diff/basic/operation_tree_flatteners/custom_object.rb +5 -3
- data/lib/super_diff/basic/operation_tree_flatteners/default_object.rb +6 -5
- data/lib/super_diff/basic/operation_tree_flatteners/hash.rb +5 -3
- data/lib/super_diff/basic/operation_tree_flatteners/multiline_string.rb +3 -1
- data/lib/super_diff/basic/operation_tree_flatteners.rb +8 -6
- data/lib/super_diff/basic/operation_trees/array.rb +2 -0
- data/lib/super_diff/basic/operation_trees/custom_object.rb +2 -0
- data/lib/super_diff/basic/operation_trees/default_object.rb +6 -4
- data/lib/super_diff/basic/operation_trees/hash.rb +2 -0
- data/lib/super_diff/basic/operation_trees/multiline_string.rb +3 -1
- data/lib/super_diff/basic/operation_trees.rb +9 -7
- data/lib/super_diff/basic.rb +9 -6
- data/lib/super_diff/core/abstract_differ.rb +2 -0
- data/lib/super_diff/core/abstract_inspection_tree_builder.rb +2 -0
- data/lib/super_diff/core/abstract_operation_tree.rb +4 -2
- data/lib/super_diff/core/abstract_operation_tree_builder.rb +15 -18
- data/lib/super_diff/core/abstract_operation_tree_flattener.rb +5 -3
- data/lib/super_diff/core/binary_operation.rb +3 -1
- data/lib/super_diff/core/colorized_document_extensions.rb +2 -0
- data/lib/super_diff/core/configuration.rb +14 -38
- data/lib/super_diff/core/differ_dispatcher.rb +4 -2
- data/lib/super_diff/core/gem_version.rb +2 -0
- data/lib/super_diff/core/helpers.rb +13 -11
- data/lib/super_diff/core/implementation_checks.rb +6 -2
- data/lib/super_diff/core/inspection_tree.rb +38 -38
- data/lib/super_diff/core/inspection_tree_builder_dispatcher.rb +5 -5
- data/lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/as_prefix_when_rendering_to_lines.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/as_prelude_when_rendering_to_lines.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/as_single_line.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/base.rb +9 -9
- data/lib/super_diff/core/inspection_tree_nodes/inspection.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/nesting.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/only_when.rb +5 -1
- data/lib/super_diff/core/inspection_tree_nodes/text.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/when_empty.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/when_non_empty.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_lines.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_string.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes.rb +16 -14
- data/lib/super_diff/core/line.rb +9 -7
- data/lib/super_diff/core/no_differ_available_error.rb +7 -5
- data/lib/super_diff/core/no_inspection_tree_builder_available_error.rb +5 -3
- data/lib/super_diff/core/no_operation_tree_available_error.rb +4 -2
- data/lib/super_diff/core/no_operation_tree_builder_available_error.rb +7 -5
- data/lib/super_diff/core/operation_tree_builder_dispatcher.rb +3 -3
- data/lib/super_diff/core/operation_tree_finder.rb +8 -8
- data/lib/super_diff/core/prefix_for_next_inspection_tree_node.rb +2 -0
- data/lib/super_diff/core/prelude_for_next_inspection_tree_node.rb +2 -0
- data/lib/super_diff/core/recursion_guard.rb +6 -4
- data/lib/super_diff/core/tiered_lines.rb +2 -0
- data/lib/super_diff/core/tiered_lines_elider.rb +53 -54
- data/lib/super_diff/core/tiered_lines_formatter.rb +6 -4
- data/lib/super_diff/core/unary_operation.rb +2 -0
- data/lib/super_diff/core.rb +31 -29
- data/lib/super_diff/csi/bold_sequence.rb +2 -0
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/color_sequence_block.rb +3 -1
- data/lib/super_diff/csi/colorized_document.rb +7 -9
- data/lib/super_diff/csi/document.rb +15 -18
- data/lib/super_diff/csi/eight_bit_color.rb +32 -37
- data/lib/super_diff/csi/four_bit_color.rb +12 -9
- data/lib/super_diff/csi/reset_sequence.rb +2 -0
- data/lib/super_diff/csi/twenty_four_bit_color.rb +22 -21
- data/lib/super_diff/csi/uncolorized_document.rb +2 -0
- data/lib/super_diff/csi.rb +12 -10
- data/lib/super_diff/differs.rb +6 -4
- data/lib/super_diff/equality_matchers/array.rb +18 -16
- data/lib/super_diff/equality_matchers/base.rb +6 -4
- data/lib/super_diff/equality_matchers/default.rb +5 -3
- data/lib/super_diff/equality_matchers/defaults.rb +2 -0
- data/lib/super_diff/equality_matchers/hash.rb +18 -16
- data/lib/super_diff/equality_matchers/main.rb +3 -1
- data/lib/super_diff/equality_matchers/multiline_string.rb +18 -16
- data/lib/super_diff/equality_matchers/primitive.rb +15 -13
- data/lib/super_diff/equality_matchers/singleline_string.rb +16 -14
- data/lib/super_diff/equality_matchers.rb +11 -9
- data/lib/super_diff/errors.rb +4 -2
- data/lib/super_diff/object_inspection.rb +17 -15
- data/lib/super_diff/operation_tree_builders.rb +6 -4
- data/lib/super_diff/operation_tree_flatteners.rb +6 -4
- data/lib/super_diff/operation_trees.rb +6 -4
- data/lib/super_diff/operations.rb +4 -2
- data/lib/super_diff/rails.rb +4 -2
- data/lib/super_diff/rspec/augmented_matcher.rb +3 -1
- data/lib/super_diff/rspec/differ.rb +16 -7
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -0
- data/lib/super_diff/rspec/differs/collection_including.rb +2 -0
- data/lib/super_diff/rspec/differs/hash_including.rb +2 -0
- data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -0
- data/lib/super_diff/rspec/differs.rb +6 -4
- data/lib/super_diff/rspec/inspection_tree_builders/collection_containing_exactly.rb +12 -10
- data/lib/super_diff/rspec/inspection_tree_builders/collection_including.rb +10 -8
- data/lib/super_diff/rspec/inspection_tree_builders/double.rb +20 -18
- data/lib/super_diff/rspec/inspection_tree_builders/generic_describable_matcher.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/hash_including.rb +10 -8
- data/lib/super_diff/rspec/inspection_tree_builders/instance_of.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/kind_of.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/object_having_attributes.rb +12 -10
- data/lib/super_diff/rspec/inspection_tree_builders/primitive.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/value_within.rb +6 -4
- data/lib/super_diff/rspec/inspection_tree_builders.rb +12 -10
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +12 -12
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +19 -17
- data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +3 -1
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +7 -5
- data/lib/super_diff/rspec/matcher_text_builders/match.rb +6 -4
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +5 -3
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +20 -18
- data/lib/super_diff/rspec/matcher_text_builders.rb +9 -7
- data/lib/super_diff/rspec/matcher_text_template.rb +34 -39
- data/lib/super_diff/rspec/object_inspection.rb +7 -5
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +4 -4
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +2 -0
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +2 -0
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +2 -0
- data/lib/super_diff/rspec/operation_tree_builders.rb +6 -4
- data/lib/super_diff/rspec-rails.rb +4 -2
- data/lib/super_diff/rspec.rb +15 -13
- data/lib/super_diff/version.rb +3 -1
- data/lib/super_diff.rb +24 -26
- data/super_diff.gemspec +20 -19
- metadata +6 -185
- data/spec/examples.txt +0 -450
- data/spec/integration/rails/active_record_spec.rb +0 -21
- data/spec/integration/rails/active_support_spec.rb +0 -19
- data/spec/integration/rails/engines_spec.rb +0 -25
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +0 -21
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +0 -58
- data/spec/integration/rspec/be_matcher_spec.rb +0 -605
- data/spec/integration/rspec/be_nil_matcher_spec.rb +0 -57
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +0 -615
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +0 -62
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +0 -377
- data/spec/integration/rspec/eq_matcher_spec.rb +0 -1066
- data/spec/integration/rspec/generic_describable_matchers_spec.rb +0 -177
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +0 -443
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +0 -478
- data/spec/integration/rspec/include_matcher_spec.rb +0 -452
- data/spec/integration/rspec/magic_metadata_spec.rb +0 -51
- data/spec/integration/rspec/match_array_matcher_spec.rb +0 -424
- data/spec/integration/rspec/match_matcher_spec.rb +0 -1359
- data/spec/integration/rspec/raise_error_matcher_spec.rb +0 -1488
- data/spec/integration/rspec/respond_to_matcher_spec.rb +0 -999
- data/spec/integration/rspec/third_party_matcher_spec.rb +0 -245
- data/spec/integration/rspec/unhandled_errors_spec.rb +0 -150
- data/spec/spec_helper.rb +0 -91
- data/spec/support/colorizer.rb +0 -9
- data/spec/support/command_runner.rb +0 -253
- data/spec/support/helpers.rb +0 -21
- data/spec/support/integration/helpers.rb +0 -124
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +0 -104
- data/spec/support/integration/matchers.rb +0 -177
- data/spec/support/integration/test_programs/base.rb +0 -143
- data/spec/support/integration/test_programs/plain.rb +0 -19
- data/spec/support/integration/test_programs/rspec_active_record.rb +0 -20
- data/spec/support/integration/test_programs/rspec_active_support.rb +0 -20
- data/spec/support/integration/test_programs/rspec_rails.rb +0 -20
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +0 -20
- data/spec/support/models/a.rb +0 -11
- data/spec/support/models/active_record/person.rb +0 -28
- data/spec/support/models/active_record/query.rb +0 -15
- data/spec/support/models/active_record/shipping_address.rb +0 -24
- data/spec/support/models/customer.rb +0 -22
- data/spec/support/models/empty_class.rb +0 -6
- data/spec/support/models/item.rb +0 -10
- data/spec/support/models/order.rb +0 -9
- data/spec/support/models/person.rb +0 -20
- data/spec/support/models/player.rb +0 -30
- data/spec/support/models/point.rb +0 -7
- data/spec/support/models/shipping_address.rb +0 -25
- data/spec/support/shared_examples/active_record.rb +0 -428
- data/spec/support/shared_examples/active_support.rb +0 -188
- data/spec/support/shared_examples/elided_diffs.rb +0 -938
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +0 -749
- data/spec/support/shared_examples/key.rb +0 -123
- data/spec/support/unit/helpers.rb +0 -24
- data/spec/support/unit/matchers/be_deprecated_in_favor_of.rb +0 -39
- data/spec/support/unit/matchers/match_output.rb +0 -40
- data/spec/unit/active_record/object_inspection_spec.rb +0 -289
- data/spec/unit/active_support/object_inspection_spec.rb +0 -170
- data/spec/unit/basic/inspection_tree_builders/data_object_spec.rb +0 -146
- data/spec/unit/basic/operation_tree_builders/data_object_spec.rb +0 -82
- data/spec/unit/basic/operation_tree_flatteners/array_spec.rb +0 -637
- data/spec/unit/basic/operation_tree_flatteners/custom_object_spec.rb +0 -685
- data/spec/unit/basic/operation_tree_flatteners/default_object_spec.rb +0 -685
- data/spec/unit/basic/operation_tree_flatteners/hash_spec.rb +0 -671
- data/spec/unit/basic/operation_tree_flatteners/multiline_string_spec.rb +0 -131
- data/spec/unit/core/configuration_no_rspec_spec.rb +0 -58
- data/spec/unit/core/configuration_spec.rb +0 -176
- data/spec/unit/core/helpers_spec.rb +0 -68
- data/spec/unit/core/tiered_lines_elider_spec.rb +0 -6328
- data/spec/unit/core/tiered_lines_formatter_spec.rb +0 -131
- data/spec/unit/deprecations_spec.rb +0 -176
- data/spec/unit/equality_matchers/main_spec.rb +0 -1842
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +0 -23
- data/spec/unit/rspec/matchers/be_falsey_spec.rb +0 -9
- data/spec/unit/rspec/matchers/be_nil_spec.rb +0 -9
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +0 -31
- data/spec/unit/rspec/matchers/be_spec.rb +0 -17
- data/spec/unit/rspec/matchers/be_truthy_spec.rb +0 -9
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +0 -11
- data/spec/unit/rspec/matchers/eq_spec.rb +0 -9
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +0 -11
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +0 -21
- data/spec/unit/rspec/matchers/include_spec.rb +0 -21
- data/spec/unit/rspec/matchers/match_array_spec.rb +0 -11
- data/spec/unit/rspec/matchers/match_spec.rb +0 -9
- data/spec/unit/rspec/matchers/raise_error_spec.rb +0 -77
- data/spec/unit/rspec/matchers/respond_to_spec.rb +0 -85
- data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +0 -91
- data/spec/unit/rspec/object_inspection_spec.rb +0 -471
- data/spec/unit/super_diff_spec.rb +0 -2115
@@ -1,1488 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "Integration with RSpec's #raise_error matcher",
|
4
|
-
type: :integration do
|
5
|
-
context "given only an exception class" do
|
6
|
-
context "when used in the positive" do
|
7
|
-
context "when the block raises a different error than what is given" do
|
8
|
-
context "when the actual message is short" do
|
9
|
-
it "produces the correct failure message" do
|
10
|
-
as_both_colored_and_uncolored do |color_enabled|
|
11
|
-
snippet = <<~TEST.strip
|
12
|
-
expect { raise StandardError.new('boo') }.to raise_error(RuntimeError)
|
13
|
-
TEST
|
14
|
-
program =
|
15
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
16
|
-
|
17
|
-
expected_output =
|
18
|
-
build_expected_output(
|
19
|
-
color_enabled: color_enabled,
|
20
|
-
snippet:
|
21
|
-
"expect { raise StandardError.new('boo') }.to raise_error(RuntimeError)",
|
22
|
-
expectation:
|
23
|
-
proc do
|
24
|
-
line do
|
25
|
-
plain "Expected raised exception "
|
26
|
-
actual %|#<StandardError "boo">|
|
27
|
-
plain " to match "
|
28
|
-
expected "a kind of RuntimeError"
|
29
|
-
plain "."
|
30
|
-
end
|
31
|
-
end
|
32
|
-
)
|
33
|
-
|
34
|
-
expect(program).to produce_output_when_run(
|
35
|
-
expected_output
|
36
|
-
).in_color(color_enabled)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when the actual message is long" do
|
42
|
-
it "produces the correct failure message" do
|
43
|
-
as_both_colored_and_uncolored do |color_enabled|
|
44
|
-
snippet = <<~TEST.strip
|
45
|
-
expect { raise StandardError.new('this is a super super super long message') }.to raise_error(RuntimeError)
|
46
|
-
TEST
|
47
|
-
program =
|
48
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
49
|
-
|
50
|
-
expected_output =
|
51
|
-
build_expected_output(
|
52
|
-
color_enabled: color_enabled,
|
53
|
-
snippet:
|
54
|
-
"expect { raise StandardError.new('this is a super super super long message') }.to raise_error(RuntimeError)",
|
55
|
-
newline_before_expectation: true,
|
56
|
-
expectation:
|
57
|
-
proc do
|
58
|
-
line do
|
59
|
-
plain "Expected raised exception "
|
60
|
-
actual %|#<StandardError "this is a super super super long message">|
|
61
|
-
end
|
62
|
-
|
63
|
-
line do
|
64
|
-
plain " to match "
|
65
|
-
expected "a kind of RuntimeError"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
)
|
69
|
-
|
70
|
-
expect(program).to produce_output_when_run(
|
71
|
-
expected_output
|
72
|
-
).in_color(color_enabled)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context "when the block raises no error" do
|
79
|
-
it "produces the correct failure message" do
|
80
|
-
as_both_colored_and_uncolored do |color_enabled|
|
81
|
-
snippet = <<~TEST.strip
|
82
|
-
expect { }.to raise_error(RuntimeError)
|
83
|
-
TEST
|
84
|
-
program =
|
85
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
86
|
-
|
87
|
-
expected_output =
|
88
|
-
build_expected_output(
|
89
|
-
color_enabled: color_enabled,
|
90
|
-
snippet: "expect { }.to raise_error(RuntimeError)",
|
91
|
-
expectation:
|
92
|
-
proc do
|
93
|
-
line do
|
94
|
-
plain "Expected "
|
95
|
-
actual "exception-free block"
|
96
|
-
plain " to raise "
|
97
|
-
expected "a kind of RuntimeError"
|
98
|
-
plain "."
|
99
|
-
end
|
100
|
-
end
|
101
|
-
)
|
102
|
-
|
103
|
-
expect(program).to produce_output_when_run(
|
104
|
-
expected_output
|
105
|
-
).in_color(color_enabled)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
context "when used in the negative" do
|
112
|
-
context "when the actual message is short" do
|
113
|
-
it "produces the correct failure message" do
|
114
|
-
as_both_colored_and_uncolored do |color_enabled|
|
115
|
-
snippet = <<~TEST.strip
|
116
|
-
expect { raise StandardError.new('boo') }.not_to raise_error(StandardError)
|
117
|
-
TEST
|
118
|
-
program =
|
119
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
120
|
-
|
121
|
-
expected_output =
|
122
|
-
build_expected_output(
|
123
|
-
color_enabled: color_enabled,
|
124
|
-
snippet:
|
125
|
-
"expect { raise StandardError.new('boo') }.not_to raise_error(StandardError)",
|
126
|
-
expectation:
|
127
|
-
proc do
|
128
|
-
line do
|
129
|
-
plain "Expected raised exception "
|
130
|
-
actual %|#<StandardError "boo">|
|
131
|
-
plain " not to match "
|
132
|
-
expected "a kind of StandardError"
|
133
|
-
plain "."
|
134
|
-
end
|
135
|
-
end
|
136
|
-
)
|
137
|
-
|
138
|
-
expect(program).to produce_output_when_run(
|
139
|
-
expected_output
|
140
|
-
).in_color(color_enabled)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "when the actual message is long" do
|
146
|
-
it "produces the correct failure message" do
|
147
|
-
as_both_colored_and_uncolored do |color_enabled|
|
148
|
-
snippet = <<~TEST.strip
|
149
|
-
expect { raise StandardError.new('this is a super super long message') }.not_to raise_error(StandardError)
|
150
|
-
TEST
|
151
|
-
program =
|
152
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
153
|
-
|
154
|
-
expected_output =
|
155
|
-
build_expected_output(
|
156
|
-
color_enabled: color_enabled,
|
157
|
-
snippet:
|
158
|
-
"expect { raise StandardError.new('this is a super super long message') }.not_to raise_error(StandardError)",
|
159
|
-
newline_before_expectation: true,
|
160
|
-
expectation:
|
161
|
-
proc do
|
162
|
-
line do
|
163
|
-
plain "Expected raised exception "
|
164
|
-
actual %|#<StandardError "this is a super super long message">|
|
165
|
-
end
|
166
|
-
|
167
|
-
line do
|
168
|
-
plain " not to match "
|
169
|
-
expected "a kind of StandardError"
|
170
|
-
end
|
171
|
-
end
|
172
|
-
)
|
173
|
-
|
174
|
-
expect(program).to produce_output_when_run(
|
175
|
-
expected_output
|
176
|
-
).in_color(color_enabled)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
context "given only a string message" do
|
184
|
-
context "when used in the positive" do
|
185
|
-
context "when the block raises a different error than what is given" do
|
186
|
-
context "when the expected and/or actual message is short" do
|
187
|
-
it "produces the correct failure message" do
|
188
|
-
as_both_colored_and_uncolored do |color_enabled|
|
189
|
-
snippet = <<~TEST.strip
|
190
|
-
expect { raise 'boo' }.to raise_error('hell')
|
191
|
-
TEST
|
192
|
-
program =
|
193
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
194
|
-
|
195
|
-
expected_output =
|
196
|
-
build_expected_output(
|
197
|
-
color_enabled: color_enabled,
|
198
|
-
snippet: "expect { raise 'boo' }.to raise_error('hell')",
|
199
|
-
expectation:
|
200
|
-
proc do
|
201
|
-
line do
|
202
|
-
plain "Expected raised exception "
|
203
|
-
actual %|#<RuntimeError "boo">|
|
204
|
-
plain " to match "
|
205
|
-
expected %|a kind of Exception with message "hell"|
|
206
|
-
plain "."
|
207
|
-
end
|
208
|
-
end
|
209
|
-
)
|
210
|
-
|
211
|
-
expect(program).to produce_output_when_run(
|
212
|
-
expected_output
|
213
|
-
).in_color(color_enabled)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
context "when the expected and/or actual message is long" do
|
219
|
-
context "but contains no line breaks" do
|
220
|
-
it "produces the correct failure message when used in the positive" do
|
221
|
-
as_both_colored_and_uncolored do |color_enabled|
|
222
|
-
snippet = <<~TEST.strip
|
223
|
-
actual_message = "some really really really long message"
|
224
|
-
expected_message = "whatever"
|
225
|
-
expect { raise(actual_message) }.to raise_error(expected_message)
|
226
|
-
TEST
|
227
|
-
program =
|
228
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
229
|
-
|
230
|
-
expected_output =
|
231
|
-
build_expected_output(
|
232
|
-
color_enabled: color_enabled,
|
233
|
-
snippet:
|
234
|
-
"expect { raise(actual_message) }.to raise_error(expected_message)",
|
235
|
-
newline_before_expectation: true,
|
236
|
-
expectation:
|
237
|
-
proc do
|
238
|
-
line do
|
239
|
-
plain "Expected raised exception "
|
240
|
-
actual %|#<RuntimeError "some really really really long message">|
|
241
|
-
end
|
242
|
-
|
243
|
-
line do
|
244
|
-
plain " to match "
|
245
|
-
expected %|a kind of Exception with message "whatever"|
|
246
|
-
end
|
247
|
-
end
|
248
|
-
)
|
249
|
-
|
250
|
-
expect(program).to produce_output_when_run(
|
251
|
-
expected_output
|
252
|
-
).in_color(color_enabled)
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
context "but contains line breaks" do
|
258
|
-
it "produces the correct failure message when used in the positive" do
|
259
|
-
as_both_colored_and_uncolored do |color_enabled|
|
260
|
-
snippet = <<~TEST.strip
|
261
|
-
actual_message = <<\~MESSAGE.rstrip
|
262
|
-
This is fun
|
263
|
-
So is this
|
264
|
-
MESSAGE
|
265
|
-
expected_message = <<\~MESSAGE.rstrip
|
266
|
-
This is fun
|
267
|
-
And so is this
|
268
|
-
MESSAGE
|
269
|
-
expect { raise(actual_message) }.to raise_error(expected_message)
|
270
|
-
TEST
|
271
|
-
program =
|
272
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
273
|
-
|
274
|
-
expected_output =
|
275
|
-
build_expected_output(
|
276
|
-
color_enabled: color_enabled,
|
277
|
-
snippet:
|
278
|
-
"expect { raise(actual_message) }.to raise_error(expected_message)",
|
279
|
-
expectation:
|
280
|
-
proc do
|
281
|
-
line do
|
282
|
-
plain "Expected raised exception "
|
283
|
-
actual %|#<RuntimeError "This is fun\\nSo is this">|
|
284
|
-
end
|
285
|
-
|
286
|
-
line do
|
287
|
-
plain " to match "
|
288
|
-
expected %|a kind of Exception with message "This is fun\\nAnd so is this"|
|
289
|
-
end
|
290
|
-
end,
|
291
|
-
diff:
|
292
|
-
proc do
|
293
|
-
plain_line %| This is fun\\n|
|
294
|
-
expected_line "- And so is this"
|
295
|
-
actual_line "+ So is this"
|
296
|
-
end
|
297
|
-
)
|
298
|
-
|
299
|
-
expect(program).to produce_output_when_run(
|
300
|
-
expected_output
|
301
|
-
).in_color(color_enabled)
|
302
|
-
end
|
303
|
-
end
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
context "when the block raises no error" do
|
309
|
-
context "when the expected message is short" do
|
310
|
-
it "produces the correct failure message" do
|
311
|
-
as_both_colored_and_uncolored do |color_enabled|
|
312
|
-
snippet = <<~TEST.strip
|
313
|
-
expect { }.to raise_error('hell')
|
314
|
-
TEST
|
315
|
-
program =
|
316
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
317
|
-
|
318
|
-
expected_output =
|
319
|
-
build_expected_output(
|
320
|
-
color_enabled: color_enabled,
|
321
|
-
snippet: "expect { }.to raise_error('hell')",
|
322
|
-
expectation:
|
323
|
-
proc do
|
324
|
-
line do
|
325
|
-
plain "Expected "
|
326
|
-
actual "exception-free block"
|
327
|
-
plain " to raise "
|
328
|
-
expected %|a kind of Exception with message "hell"|
|
329
|
-
plain "."
|
330
|
-
end
|
331
|
-
end
|
332
|
-
)
|
333
|
-
|
334
|
-
expect(program).to produce_output_when_run(
|
335
|
-
expected_output
|
336
|
-
).in_color(color_enabled)
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
context "when the expected message is long" do
|
342
|
-
context "but contains no line breaks" do
|
343
|
-
it "produces the correct failure message" do
|
344
|
-
as_both_colored_and_uncolored do |color_enabled|
|
345
|
-
snippet = <<~TEST.strip
|
346
|
-
expect { }.to raise_error("this is a super super super super super super long message")
|
347
|
-
TEST
|
348
|
-
program =
|
349
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
350
|
-
|
351
|
-
expected_output =
|
352
|
-
build_expected_output(
|
353
|
-
color_enabled: color_enabled,
|
354
|
-
snippet:
|
355
|
-
%|expect { }.to raise_error("this is a super super super super super super long message")|,
|
356
|
-
newline_before_expectation: true,
|
357
|
-
expectation:
|
358
|
-
proc do
|
359
|
-
# stree-ignore
|
360
|
-
line do
|
361
|
-
plain "Expected "
|
362
|
-
actual "exception-free block"
|
363
|
-
end
|
364
|
-
|
365
|
-
line do
|
366
|
-
plain "to raise "
|
367
|
-
expected %|a kind of Exception with message "this is a super super super super super super long message"|
|
368
|
-
end
|
369
|
-
end
|
370
|
-
)
|
371
|
-
|
372
|
-
expect(program).to produce_output_when_run(
|
373
|
-
expected_output
|
374
|
-
).in_color(color_enabled)
|
375
|
-
end
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
context "but contains line breaks" do
|
380
|
-
it "produces the correct failure message" do
|
381
|
-
as_both_colored_and_uncolored do |color_enabled|
|
382
|
-
snippet = <<~TEST.strip
|
383
|
-
expected_message = <<\~MESSAGE.rstrip
|
384
|
-
this is a super super
|
385
|
-
super super super
|
386
|
-
super long message
|
387
|
-
MESSAGE
|
388
|
-
expect { }.to raise_error(expected_message)
|
389
|
-
TEST
|
390
|
-
program =
|
391
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
392
|
-
|
393
|
-
expected_output =
|
394
|
-
build_expected_output(
|
395
|
-
color_enabled: color_enabled,
|
396
|
-
snippet: "expect { }.to raise_error(expected_message)",
|
397
|
-
newline_before_expectation: true,
|
398
|
-
expectation:
|
399
|
-
proc do
|
400
|
-
# stree-ignore
|
401
|
-
line do
|
402
|
-
plain "Expected "
|
403
|
-
actual "exception-free block"
|
404
|
-
end
|
405
|
-
|
406
|
-
line do
|
407
|
-
plain "to raise "
|
408
|
-
expected %|a kind of Exception with message "this is a super super\\nsuper super super\\nsuper long message"|
|
409
|
-
end
|
410
|
-
end
|
411
|
-
)
|
412
|
-
|
413
|
-
expect(program).to produce_output_when_run(
|
414
|
-
expected_output
|
415
|
-
).in_color(color_enabled)
|
416
|
-
end
|
417
|
-
end
|
418
|
-
end
|
419
|
-
end
|
420
|
-
end
|
421
|
-
end
|
422
|
-
|
423
|
-
context "when used in the negative" do
|
424
|
-
context "when the expected and/or actual message is short" do
|
425
|
-
it "produces the correct failure message" do
|
426
|
-
as_both_colored_and_uncolored do |color_enabled|
|
427
|
-
snippet = <<~TEST.strip
|
428
|
-
expect { raise 'boo' }.not_to raise_error('boo')
|
429
|
-
TEST
|
430
|
-
program =
|
431
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
432
|
-
|
433
|
-
expected_output =
|
434
|
-
build_expected_output(
|
435
|
-
color_enabled: color_enabled,
|
436
|
-
snippet: "expect { raise 'boo' }.not_to raise_error('boo')",
|
437
|
-
expectation:
|
438
|
-
proc do
|
439
|
-
line do
|
440
|
-
plain "Expected raised exception "
|
441
|
-
actual %|#<RuntimeError "boo">|
|
442
|
-
plain " not to match "
|
443
|
-
expected %|a kind of Exception with message "boo"|
|
444
|
-
plain "."
|
445
|
-
end
|
446
|
-
end
|
447
|
-
)
|
448
|
-
|
449
|
-
expect(program).to produce_output_when_run(
|
450
|
-
expected_output
|
451
|
-
).in_color(color_enabled)
|
452
|
-
end
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
context "when the expected and/or actual message is long" do
|
457
|
-
context "but contains no line breaks" do
|
458
|
-
it "produces the correct failure message" do
|
459
|
-
as_both_colored_and_uncolored do |color_enabled|
|
460
|
-
snippet = <<~TEST.strip
|
461
|
-
message = "some really long message"
|
462
|
-
expect { raise(message) }.not_to raise_error(message)
|
463
|
-
TEST
|
464
|
-
program =
|
465
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
466
|
-
|
467
|
-
expected_output =
|
468
|
-
build_expected_output(
|
469
|
-
color_enabled: color_enabled,
|
470
|
-
snippet:
|
471
|
-
"expect { raise(message) }.not_to raise_error(message)",
|
472
|
-
newline_before_expectation: true,
|
473
|
-
expectation:
|
474
|
-
proc do
|
475
|
-
line do
|
476
|
-
plain "Expected raised exception "
|
477
|
-
actual %|#<RuntimeError "some really long message">|
|
478
|
-
end
|
479
|
-
|
480
|
-
line do
|
481
|
-
plain " not to match "
|
482
|
-
expected %|a kind of Exception with message "some really long message"|
|
483
|
-
end
|
484
|
-
end
|
485
|
-
)
|
486
|
-
|
487
|
-
expect(program).to produce_output_when_run(
|
488
|
-
expected_output
|
489
|
-
).in_color(color_enabled)
|
490
|
-
end
|
491
|
-
end
|
492
|
-
end
|
493
|
-
|
494
|
-
context "but contains line breaks" do
|
495
|
-
it "produces the correct failure message" do
|
496
|
-
as_both_colored_and_uncolored do |color_enabled|
|
497
|
-
snippet = <<~TEST.strip
|
498
|
-
message = <<\~MESSAGE.rstrip
|
499
|
-
this is a super super
|
500
|
-
super super super
|
501
|
-
super long message
|
502
|
-
MESSAGE
|
503
|
-
expect { raise(message) }.not_to raise_error(message)
|
504
|
-
TEST
|
505
|
-
program =
|
506
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
507
|
-
|
508
|
-
expected_output =
|
509
|
-
build_expected_output(
|
510
|
-
color_enabled: color_enabled,
|
511
|
-
snippet:
|
512
|
-
"expect { raise(message) }.not_to raise_error(message)",
|
513
|
-
newline_before_expectation: true,
|
514
|
-
expectation:
|
515
|
-
proc do
|
516
|
-
line do
|
517
|
-
plain "Expected raised exception "
|
518
|
-
actual %|#<RuntimeError "this is a super super\\nsuper super super\\nsuper long message">|
|
519
|
-
end
|
520
|
-
|
521
|
-
line do
|
522
|
-
plain " not to match "
|
523
|
-
expected %|a kind of Exception with message "this is a super super\\nsuper super super\\nsuper long message"|
|
524
|
-
end
|
525
|
-
end
|
526
|
-
)
|
527
|
-
|
528
|
-
expect(program).to produce_output_when_run(
|
529
|
-
expected_output
|
530
|
-
).in_color(color_enabled)
|
531
|
-
end
|
532
|
-
end
|
533
|
-
end
|
534
|
-
end
|
535
|
-
end
|
536
|
-
end
|
537
|
-
|
538
|
-
context "given only a regexp message" do
|
539
|
-
context "when used in the positive" do
|
540
|
-
context "when the block raises a different error than what is given" do
|
541
|
-
it "produces the correct failure message" do
|
542
|
-
as_both_colored_and_uncolored do |color_enabled|
|
543
|
-
snippet = <<~TEST.strip
|
544
|
-
expect { raise 'boo' }.to raise_error(/hell/i)
|
545
|
-
TEST
|
546
|
-
program =
|
547
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
548
|
-
|
549
|
-
expected_output =
|
550
|
-
build_expected_output(
|
551
|
-
color_enabled: color_enabled,
|
552
|
-
snippet: "expect { raise 'boo' }.to raise_error(/hell/i)",
|
553
|
-
newline_before_expectation: true,
|
554
|
-
expectation:
|
555
|
-
proc do
|
556
|
-
line do
|
557
|
-
plain "Expected raised exception "
|
558
|
-
actual %|#<RuntimeError "boo">|
|
559
|
-
end
|
560
|
-
|
561
|
-
line do
|
562
|
-
plain " to match "
|
563
|
-
expected "a kind of Exception with message matching /hell/i"
|
564
|
-
end
|
565
|
-
end
|
566
|
-
)
|
567
|
-
|
568
|
-
expect(program).to produce_output_when_run(
|
569
|
-
expected_output
|
570
|
-
).in_color(color_enabled)
|
571
|
-
end
|
572
|
-
end
|
573
|
-
end
|
574
|
-
|
575
|
-
context "when the block raises no error" do
|
576
|
-
context "when the expected message is short" do
|
577
|
-
it "produces the correct failure message" do
|
578
|
-
as_both_colored_and_uncolored do |color_enabled|
|
579
|
-
snippet = <<~TEST.strip
|
580
|
-
expect { }.to raise_error(/hell/i)
|
581
|
-
TEST
|
582
|
-
program =
|
583
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
584
|
-
|
585
|
-
expected_output =
|
586
|
-
build_expected_output(
|
587
|
-
color_enabled: color_enabled,
|
588
|
-
snippet: "expect { }.to raise_error(/hell/i)",
|
589
|
-
expectation:
|
590
|
-
proc do
|
591
|
-
line do
|
592
|
-
plain "Expected "
|
593
|
-
actual "exception-free block"
|
594
|
-
plain " to raise "
|
595
|
-
expected "a kind of Exception with message matching /hell/i"
|
596
|
-
plain "."
|
597
|
-
end
|
598
|
-
end
|
599
|
-
)
|
600
|
-
|
601
|
-
expect(program).to produce_output_when_run(
|
602
|
-
expected_output
|
603
|
-
).in_color(color_enabled)
|
604
|
-
end
|
605
|
-
end
|
606
|
-
end
|
607
|
-
|
608
|
-
context "when the expected message is long" do
|
609
|
-
it "produces the correct failure message" do
|
610
|
-
as_both_colored_and_uncolored do |color_enabled|
|
611
|
-
snippet = <<~TEST.strip
|
612
|
-
expect { }.to raise_error(/this is a super super super super super super long message/i)
|
613
|
-
TEST
|
614
|
-
program =
|
615
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
616
|
-
|
617
|
-
expected_output =
|
618
|
-
build_expected_output(
|
619
|
-
color_enabled: color_enabled,
|
620
|
-
snippet:
|
621
|
-
"expect { }.to raise_error(/this is a super super super super super super long message/i)",
|
622
|
-
newline_before_expectation: true,
|
623
|
-
expectation:
|
624
|
-
proc do
|
625
|
-
line do
|
626
|
-
plain "Expected "
|
627
|
-
actual "exception-free block"
|
628
|
-
end
|
629
|
-
|
630
|
-
line do
|
631
|
-
plain "to raise "
|
632
|
-
expected "a kind of Exception with message matching /this is a super super super super super super long message/i"
|
633
|
-
end
|
634
|
-
end
|
635
|
-
)
|
636
|
-
|
637
|
-
expect(program).to produce_output_when_run(
|
638
|
-
expected_output
|
639
|
-
).in_color(color_enabled)
|
640
|
-
end
|
641
|
-
end
|
642
|
-
end
|
643
|
-
end
|
644
|
-
end
|
645
|
-
|
646
|
-
context "when used in the negative" do
|
647
|
-
it "produces the correct failure message" do
|
648
|
-
as_both_colored_and_uncolored do |color_enabled|
|
649
|
-
snippet = <<~TEST.strip
|
650
|
-
expect { raise 'boo' }.not_to raise_error(/boo/i)
|
651
|
-
TEST
|
652
|
-
program =
|
653
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
654
|
-
|
655
|
-
expected_output =
|
656
|
-
build_expected_output(
|
657
|
-
color_enabled: color_enabled,
|
658
|
-
snippet: "expect { raise 'boo' }.not_to raise_error(/boo/i)",
|
659
|
-
newline_before_expectation: true,
|
660
|
-
expectation:
|
661
|
-
proc do
|
662
|
-
line do
|
663
|
-
plain "Expected raised exception "
|
664
|
-
actual %|#<RuntimeError "boo">|
|
665
|
-
end
|
666
|
-
|
667
|
-
line do
|
668
|
-
plain " not to match "
|
669
|
-
expected "a kind of Exception with message matching /boo/i"
|
670
|
-
end
|
671
|
-
end
|
672
|
-
)
|
673
|
-
|
674
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
675
|
-
color_enabled
|
676
|
-
)
|
677
|
-
end
|
678
|
-
end
|
679
|
-
end
|
680
|
-
end
|
681
|
-
|
682
|
-
context "given both an exception class and string message" do
|
683
|
-
context "when used in the positive" do
|
684
|
-
context "when the block raises a different error than what is given" do
|
685
|
-
context "when the expected and/or actual message is short" do
|
686
|
-
it "produces the correct failure message" do
|
687
|
-
as_both_colored_and_uncolored do |color_enabled|
|
688
|
-
snippet = <<~TEST.strip
|
689
|
-
block = -> { raise StandardError.new('a') }
|
690
|
-
expect(&block).to raise_error(RuntimeError, 'b')
|
691
|
-
TEST
|
692
|
-
program =
|
693
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
694
|
-
|
695
|
-
expected_output =
|
696
|
-
build_expected_output(
|
697
|
-
color_enabled: color_enabled,
|
698
|
-
snippet: "expect(&block).to raise_error(RuntimeError, 'b')",
|
699
|
-
expectation:
|
700
|
-
proc do
|
701
|
-
line do
|
702
|
-
plain "Expected raised exception "
|
703
|
-
actual %|#<StandardError "a">|
|
704
|
-
plain " to match "
|
705
|
-
expected %|a kind of RuntimeError with message "b"|
|
706
|
-
plain "."
|
707
|
-
end
|
708
|
-
end
|
709
|
-
)
|
710
|
-
|
711
|
-
expect(program).to produce_output_when_run(
|
712
|
-
expected_output
|
713
|
-
).in_color(color_enabled)
|
714
|
-
end
|
715
|
-
end
|
716
|
-
end
|
717
|
-
|
718
|
-
context "when the expected and/or actual message is long" do
|
719
|
-
it "produces the correct failure message" do
|
720
|
-
as_both_colored_and_uncolored do |color_enabled|
|
721
|
-
snippet = <<~TEST.strip
|
722
|
-
block = -> { raise StandardError.new('this is a long message') }
|
723
|
-
expect(&block).to raise_error(RuntimeError, 'this is another long message')
|
724
|
-
TEST
|
725
|
-
program =
|
726
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
727
|
-
|
728
|
-
expected_output =
|
729
|
-
build_expected_output(
|
730
|
-
color_enabled: color_enabled,
|
731
|
-
snippet:
|
732
|
-
"expect(&block).to raise_error(RuntimeError, 'this is another long message')",
|
733
|
-
newline_before_expectation: true,
|
734
|
-
expectation:
|
735
|
-
proc do
|
736
|
-
line do
|
737
|
-
plain "Expected raised exception "
|
738
|
-
actual %|#<StandardError "this is a long message">|
|
739
|
-
end
|
740
|
-
|
741
|
-
line do
|
742
|
-
plain " to match "
|
743
|
-
expected %|a kind of RuntimeError with message "this is another long message"|
|
744
|
-
end
|
745
|
-
end
|
746
|
-
)
|
747
|
-
|
748
|
-
expect(program).to produce_output_when_run(
|
749
|
-
expected_output
|
750
|
-
).in_color(color_enabled)
|
751
|
-
end
|
752
|
-
end
|
753
|
-
end
|
754
|
-
end
|
755
|
-
|
756
|
-
context "when the block raises no error" do
|
757
|
-
context "when the expected message is short" do
|
758
|
-
it "produces the correct failure message" do
|
759
|
-
as_both_colored_and_uncolored do |color_enabled|
|
760
|
-
snippet = <<~TEST.strip
|
761
|
-
expect { }.to raise_error(RuntimeError, 'b')
|
762
|
-
TEST
|
763
|
-
program =
|
764
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
765
|
-
|
766
|
-
expected_output =
|
767
|
-
build_expected_output(
|
768
|
-
color_enabled: color_enabled,
|
769
|
-
snippet: "expect { }.to raise_error(RuntimeError, 'b')",
|
770
|
-
expectation:
|
771
|
-
proc do
|
772
|
-
line do
|
773
|
-
plain "Expected "
|
774
|
-
actual "exception-free block"
|
775
|
-
plain " to raise "
|
776
|
-
expected %|a kind of RuntimeError with message "b"|
|
777
|
-
plain "."
|
778
|
-
end
|
779
|
-
end
|
780
|
-
)
|
781
|
-
|
782
|
-
expect(program).to produce_output_when_run(
|
783
|
-
expected_output
|
784
|
-
).in_color(color_enabled)
|
785
|
-
end
|
786
|
-
end
|
787
|
-
end
|
788
|
-
|
789
|
-
context "when the expected message is long" do
|
790
|
-
it "produces the correct failure message" do
|
791
|
-
as_both_colored_and_uncolored do |color_enabled|
|
792
|
-
snippet = <<~TEST.strip
|
793
|
-
expect { }.to raise_error(RuntimeError, 'this is a super super super super super super long message')
|
794
|
-
TEST
|
795
|
-
program =
|
796
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
797
|
-
|
798
|
-
expected_output =
|
799
|
-
build_expected_output(
|
800
|
-
color_enabled: color_enabled,
|
801
|
-
snippet:
|
802
|
-
"expect { }.to raise_error(RuntimeError, 'this is a super super super super super super long message')",
|
803
|
-
newline_before_expectation: true,
|
804
|
-
expectation:
|
805
|
-
proc do
|
806
|
-
line do
|
807
|
-
plain "Expected "
|
808
|
-
actual "exception-free block"
|
809
|
-
end
|
810
|
-
|
811
|
-
line do
|
812
|
-
plain "to raise "
|
813
|
-
expected %|a kind of RuntimeError with message "this is a super super super super super super long message"|
|
814
|
-
end
|
815
|
-
end
|
816
|
-
)
|
817
|
-
|
818
|
-
expect(program).to produce_output_when_run(
|
819
|
-
expected_output
|
820
|
-
).in_color(color_enabled)
|
821
|
-
end
|
822
|
-
end
|
823
|
-
end
|
824
|
-
end
|
825
|
-
end
|
826
|
-
|
827
|
-
context "when used in the negative" do
|
828
|
-
it "produces the correct failure message" do
|
829
|
-
as_both_colored_and_uncolored do |color_enabled|
|
830
|
-
snippet = <<~TEST.strip
|
831
|
-
block = -> { raise StandardError.new('a') }
|
832
|
-
expect(&block).not_to raise_error(StandardError, 'a')
|
833
|
-
TEST
|
834
|
-
program =
|
835
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
836
|
-
|
837
|
-
expected_output =
|
838
|
-
build_expected_output(
|
839
|
-
color_enabled: color_enabled,
|
840
|
-
snippet: "expect(&block).not_to raise_error(StandardError, 'a')",
|
841
|
-
newline_before_expectation: true,
|
842
|
-
expectation:
|
843
|
-
proc do
|
844
|
-
line do
|
845
|
-
plain "Expected raised exception "
|
846
|
-
actual %|#<StandardError "a">|
|
847
|
-
end
|
848
|
-
|
849
|
-
line do
|
850
|
-
plain " not to match "
|
851
|
-
expected %|a kind of StandardError with message "a"|
|
852
|
-
end
|
853
|
-
end
|
854
|
-
)
|
855
|
-
|
856
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
857
|
-
color_enabled
|
858
|
-
)
|
859
|
-
end
|
860
|
-
end
|
861
|
-
end
|
862
|
-
end
|
863
|
-
|
864
|
-
context "given both an exception class and regexp message" do
|
865
|
-
context "when used in the positive" do
|
866
|
-
context "when the block raises a different error than what is given" do
|
867
|
-
it "produces the correct failure message" do
|
868
|
-
as_both_colored_and_uncolored do |color_enabled|
|
869
|
-
snippet = <<~TEST.strip
|
870
|
-
block = -> { raise StandardError.new('a') }
|
871
|
-
expect(&block).to raise_error(RuntimeError, /b/i)
|
872
|
-
TEST
|
873
|
-
program =
|
874
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
875
|
-
|
876
|
-
expected_output =
|
877
|
-
build_expected_output(
|
878
|
-
color_enabled: color_enabled,
|
879
|
-
snippet: "expect(&block).to raise_error(RuntimeError, /b/i)",
|
880
|
-
newline_before_expectation: true,
|
881
|
-
expectation:
|
882
|
-
proc do
|
883
|
-
line do
|
884
|
-
plain "Expected raised exception "
|
885
|
-
actual %|#<StandardError "a">|
|
886
|
-
end
|
887
|
-
|
888
|
-
line do
|
889
|
-
plain " to match "
|
890
|
-
expected "a kind of RuntimeError with message matching /b/i"
|
891
|
-
end
|
892
|
-
end
|
893
|
-
)
|
894
|
-
|
895
|
-
expect(program).to produce_output_when_run(
|
896
|
-
expected_output
|
897
|
-
).in_color(color_enabled)
|
898
|
-
end
|
899
|
-
end
|
900
|
-
end
|
901
|
-
|
902
|
-
context "when the block raises no error" do
|
903
|
-
context "when the expected message is short" do
|
904
|
-
it "produces the correct failure message" do
|
905
|
-
as_both_colored_and_uncolored do |color_enabled|
|
906
|
-
snippet = <<~TEST.strip
|
907
|
-
expect { }.to raise_error(RuntimeError, /b/i)
|
908
|
-
TEST
|
909
|
-
program =
|
910
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
911
|
-
|
912
|
-
expected_output =
|
913
|
-
build_expected_output(
|
914
|
-
color_enabled: color_enabled,
|
915
|
-
snippet: "expect { }.to raise_error(RuntimeError, /b/i)",
|
916
|
-
expectation:
|
917
|
-
proc do
|
918
|
-
line do
|
919
|
-
plain "Expected "
|
920
|
-
actual "exception-free block"
|
921
|
-
plain " to raise "
|
922
|
-
expected "a kind of RuntimeError with message matching /b/i"
|
923
|
-
end
|
924
|
-
end
|
925
|
-
)
|
926
|
-
|
927
|
-
expect(program).to produce_output_when_run(
|
928
|
-
expected_output
|
929
|
-
).in_color(color_enabled)
|
930
|
-
end
|
931
|
-
end
|
932
|
-
end
|
933
|
-
|
934
|
-
context "when the expected message is long" do
|
935
|
-
it "produces the correct failure message" do
|
936
|
-
as_both_colored_and_uncolored do |color_enabled|
|
937
|
-
snippet = <<~TEST.strip
|
938
|
-
expect { }.to raise_error(RuntimeError, /this is a super super super super super super long message/i)
|
939
|
-
TEST
|
940
|
-
program =
|
941
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
942
|
-
|
943
|
-
expected_output =
|
944
|
-
build_expected_output(
|
945
|
-
color_enabled: color_enabled,
|
946
|
-
snippet:
|
947
|
-
"expect { }.to raise_error(RuntimeError, /this is a super super super super super super long message/i)",
|
948
|
-
newline_before_expectation: true,
|
949
|
-
expectation:
|
950
|
-
proc do
|
951
|
-
line do
|
952
|
-
plain "Expected "
|
953
|
-
actual "exception-free block"
|
954
|
-
end
|
955
|
-
|
956
|
-
line do
|
957
|
-
plain "to raise "
|
958
|
-
expected "a kind of RuntimeError with message matching /this is a super super super super super super long message/i"
|
959
|
-
end
|
960
|
-
end
|
961
|
-
)
|
962
|
-
|
963
|
-
expect(program).to produce_output_when_run(
|
964
|
-
expected_output
|
965
|
-
).in_color(color_enabled)
|
966
|
-
end
|
967
|
-
end
|
968
|
-
end
|
969
|
-
end
|
970
|
-
end
|
971
|
-
|
972
|
-
context "when used in the negative" do
|
973
|
-
it "produces the correct failure message" do
|
974
|
-
as_both_colored_and_uncolored do |color_enabled|
|
975
|
-
snippet = <<~TEST.strip
|
976
|
-
block = -> { raise StandardError.new('a') }
|
977
|
-
expect(&block).not_to raise_error(StandardError, /a/i)
|
978
|
-
TEST
|
979
|
-
program =
|
980
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
981
|
-
|
982
|
-
expected_output =
|
983
|
-
build_expected_output(
|
984
|
-
color_enabled: color_enabled,
|
985
|
-
snippet: "expect(&block).not_to raise_error(StandardError, /a/i)",
|
986
|
-
newline_before_expectation: true,
|
987
|
-
expectation:
|
988
|
-
proc do
|
989
|
-
line do
|
990
|
-
plain "Expected raised exception "
|
991
|
-
actual %|#<StandardError "a">|
|
992
|
-
end
|
993
|
-
|
994
|
-
line do
|
995
|
-
plain " not to match "
|
996
|
-
expected "a kind of StandardError with message matching /a/i"
|
997
|
-
end
|
998
|
-
end
|
999
|
-
)
|
1000
|
-
|
1001
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
1002
|
-
color_enabled
|
1003
|
-
)
|
1004
|
-
end
|
1005
|
-
end
|
1006
|
-
end
|
1007
|
-
end
|
1008
|
-
|
1009
|
-
context "given a simple RSpec matcher" do
|
1010
|
-
context "when used in the positive" do
|
1011
|
-
context "when the block raises a different error than what is given" do
|
1012
|
-
context "when the expected error and/or actual message is short" do
|
1013
|
-
it "produces the correct failure message" do
|
1014
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1015
|
-
snippet = <<~TEST.strip
|
1016
|
-
expect { raise StandardError.new('boo') }.to raise_error(a_kind_of(Array))
|
1017
|
-
TEST
|
1018
|
-
program =
|
1019
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1020
|
-
|
1021
|
-
expected_output =
|
1022
|
-
build_expected_output(
|
1023
|
-
color_enabled: color_enabled,
|
1024
|
-
snippet:
|
1025
|
-
"expect { raise StandardError.new('boo') }.to raise_error(a_kind_of(Array))",
|
1026
|
-
expectation:
|
1027
|
-
proc do
|
1028
|
-
line do
|
1029
|
-
plain "Expected raised exception "
|
1030
|
-
actual %|#<StandardError "boo">|
|
1031
|
-
plain " to match "
|
1032
|
-
expected "#<a kind of Array>"
|
1033
|
-
plain "."
|
1034
|
-
end
|
1035
|
-
end
|
1036
|
-
)
|
1037
|
-
|
1038
|
-
expect(program).to produce_output_when_run(
|
1039
|
-
expected_output
|
1040
|
-
).in_color(color_enabled)
|
1041
|
-
end
|
1042
|
-
end
|
1043
|
-
end
|
1044
|
-
|
1045
|
-
context "when the expected error and/or actual message is long" do
|
1046
|
-
it "produces the correct failure message" do
|
1047
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1048
|
-
snippet = <<~TEST.strip
|
1049
|
-
expect { raise StandardError.new('this is a super super super long message') }.to raise_error(a_kind_of(RuntimeError))
|
1050
|
-
TEST
|
1051
|
-
program =
|
1052
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1053
|
-
|
1054
|
-
expected_output =
|
1055
|
-
build_expected_output(
|
1056
|
-
color_enabled: color_enabled,
|
1057
|
-
snippet:
|
1058
|
-
"expect { raise StandardError.new('this is a super super super long message') }.to raise_error(a_kind_of(RuntimeError))",
|
1059
|
-
newline_before_expectation: true,
|
1060
|
-
expectation:
|
1061
|
-
proc do
|
1062
|
-
line do
|
1063
|
-
plain "Expected raised exception "
|
1064
|
-
actual %|#<StandardError "this is a super super super long message">|
|
1065
|
-
end
|
1066
|
-
|
1067
|
-
line do
|
1068
|
-
plain " to match "
|
1069
|
-
expected "#<a kind of RuntimeError>"
|
1070
|
-
end
|
1071
|
-
end
|
1072
|
-
)
|
1073
|
-
|
1074
|
-
expect(program).to produce_output_when_run(
|
1075
|
-
expected_output
|
1076
|
-
).in_color(color_enabled)
|
1077
|
-
end
|
1078
|
-
end
|
1079
|
-
end
|
1080
|
-
end
|
1081
|
-
|
1082
|
-
context "when the block raises no error" do
|
1083
|
-
it "produces the correct failure message" do
|
1084
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1085
|
-
snippet = <<~TEST.strip
|
1086
|
-
expect { }.to raise_error(a_kind_of(RuntimeError))
|
1087
|
-
TEST
|
1088
|
-
program =
|
1089
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1090
|
-
|
1091
|
-
expected_output =
|
1092
|
-
build_expected_output(
|
1093
|
-
color_enabled: color_enabled,
|
1094
|
-
snippet: "expect { }.to raise_error(a_kind_of(RuntimeError))",
|
1095
|
-
expectation:
|
1096
|
-
proc do
|
1097
|
-
line do
|
1098
|
-
plain "Expected "
|
1099
|
-
actual "exception-free block"
|
1100
|
-
plain " to raise "
|
1101
|
-
expected "#<a kind of RuntimeError>"
|
1102
|
-
plain "."
|
1103
|
-
end
|
1104
|
-
end
|
1105
|
-
)
|
1106
|
-
|
1107
|
-
expect(program).to produce_output_when_run(
|
1108
|
-
expected_output
|
1109
|
-
).in_color(color_enabled)
|
1110
|
-
end
|
1111
|
-
end
|
1112
|
-
end
|
1113
|
-
end
|
1114
|
-
|
1115
|
-
context "when used in the negative" do
|
1116
|
-
context "when the expected error and/or actual message is short" do
|
1117
|
-
it "produces the correct failure message" do
|
1118
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1119
|
-
snippet = <<~TEST.strip
|
1120
|
-
expect { raise StandardError.new('boo') }.not_to raise_error(a_kind_of(StandardError))
|
1121
|
-
TEST
|
1122
|
-
program =
|
1123
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1124
|
-
|
1125
|
-
expected_output =
|
1126
|
-
build_expected_output(
|
1127
|
-
color_enabled: color_enabled,
|
1128
|
-
snippet:
|
1129
|
-
"expect { raise StandardError.new('boo') }.not_to raise_error(a_kind_of(StandardError))",
|
1130
|
-
expectation:
|
1131
|
-
proc do
|
1132
|
-
line do
|
1133
|
-
plain "Expected raised exception "
|
1134
|
-
actual %|#<StandardError "boo">|
|
1135
|
-
plain " not to match "
|
1136
|
-
expected "#<a kind of StandardError>"
|
1137
|
-
plain "."
|
1138
|
-
end
|
1139
|
-
end
|
1140
|
-
)
|
1141
|
-
|
1142
|
-
expect(program).to produce_output_when_run(
|
1143
|
-
expected_output
|
1144
|
-
).in_color(color_enabled)
|
1145
|
-
end
|
1146
|
-
end
|
1147
|
-
end
|
1148
|
-
|
1149
|
-
context "when the expected error and/or actual message is long" do
|
1150
|
-
it "produces the correct failure message" do
|
1151
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1152
|
-
snippet = <<~TEST.strip
|
1153
|
-
expect { raise StandardError.new('this is a super super long message') }.not_to raise_error(a_kind_of(StandardError))
|
1154
|
-
TEST
|
1155
|
-
program =
|
1156
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1157
|
-
|
1158
|
-
expected_output =
|
1159
|
-
build_expected_output(
|
1160
|
-
color_enabled: color_enabled,
|
1161
|
-
snippet:
|
1162
|
-
"expect { raise StandardError.new('this is a super super long message') }.not_to raise_error(a_kind_of(StandardError))",
|
1163
|
-
newline_before_expectation: true,
|
1164
|
-
expectation:
|
1165
|
-
proc do
|
1166
|
-
line do
|
1167
|
-
plain "Expected raised exception "
|
1168
|
-
actual %|#<StandardError "this is a super super long message">|
|
1169
|
-
end
|
1170
|
-
|
1171
|
-
line do
|
1172
|
-
plain " not to match "
|
1173
|
-
expected "#<a kind of StandardError>"
|
1174
|
-
end
|
1175
|
-
end
|
1176
|
-
)
|
1177
|
-
|
1178
|
-
expect(program).to produce_output_when_run(
|
1179
|
-
expected_output
|
1180
|
-
).in_color(color_enabled)
|
1181
|
-
end
|
1182
|
-
end
|
1183
|
-
end
|
1184
|
-
end
|
1185
|
-
end
|
1186
|
-
|
1187
|
-
context "given only a simple RSpec matcher and string message" do
|
1188
|
-
context "when used in the positive" do
|
1189
|
-
context "when the block raises a different error than what is given" do
|
1190
|
-
it "produces the correct failure message" do
|
1191
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1192
|
-
snippet = <<~TEST.strip
|
1193
|
-
expect { raise StandardError.new('boo') }.to raise_error(a_kind_of(RuntimeError), "boo")
|
1194
|
-
TEST
|
1195
|
-
program =
|
1196
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1197
|
-
|
1198
|
-
expected_output =
|
1199
|
-
build_expected_output(
|
1200
|
-
color_enabled: color_enabled,
|
1201
|
-
snippet:
|
1202
|
-
%|expect { raise StandardError.new('boo') }.to raise_error(a_kind_of(RuntimeError), "boo")|,
|
1203
|
-
newline_before_expectation: true,
|
1204
|
-
expectation:
|
1205
|
-
proc do
|
1206
|
-
line do
|
1207
|
-
plain "Expected raised exception "
|
1208
|
-
actual %|#<StandardError "boo">|
|
1209
|
-
end
|
1210
|
-
|
1211
|
-
line do
|
1212
|
-
plain " to match "
|
1213
|
-
expected %|#<a kind of RuntimeError> with message "boo"|
|
1214
|
-
end
|
1215
|
-
end
|
1216
|
-
)
|
1217
|
-
|
1218
|
-
expect(program).to produce_output_when_run(
|
1219
|
-
expected_output
|
1220
|
-
).in_color(color_enabled)
|
1221
|
-
end
|
1222
|
-
end
|
1223
|
-
end
|
1224
|
-
end
|
1225
|
-
|
1226
|
-
context "when used in the negative" do
|
1227
|
-
it "produces the correct failure message" do
|
1228
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1229
|
-
snippet = <<~TEST.strip
|
1230
|
-
expect { raise StandardError.new('boo') }.not_to raise_error(a_kind_of(StandardError), "boo")
|
1231
|
-
TEST
|
1232
|
-
program =
|
1233
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1234
|
-
|
1235
|
-
expected_output =
|
1236
|
-
build_expected_output(
|
1237
|
-
color_enabled: color_enabled,
|
1238
|
-
snippet:
|
1239
|
-
%|expect { raise StandardError.new('boo') }.not_to raise_error(a_kind_of(StandardError), "boo")|,
|
1240
|
-
newline_before_expectation: true,
|
1241
|
-
expectation:
|
1242
|
-
proc do
|
1243
|
-
line do
|
1244
|
-
plain "Expected raised exception "
|
1245
|
-
actual %|#<StandardError "boo">|
|
1246
|
-
end
|
1247
|
-
|
1248
|
-
line do
|
1249
|
-
plain " not to match "
|
1250
|
-
expected %|#<a kind of StandardError> with message "boo"|
|
1251
|
-
end
|
1252
|
-
end
|
1253
|
-
)
|
1254
|
-
|
1255
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
1256
|
-
color_enabled
|
1257
|
-
)
|
1258
|
-
end
|
1259
|
-
end
|
1260
|
-
end
|
1261
|
-
end
|
1262
|
-
|
1263
|
-
context "given only a simple RSpec matcher and regexp message" do
|
1264
|
-
context "when used in the positive" do
|
1265
|
-
context "when the block raises a different error than what is given" do
|
1266
|
-
it "produces the correct failure message" do
|
1267
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1268
|
-
snippet = <<~TEST.strip
|
1269
|
-
expect { raise StandardError.new('boo') }.to raise_error(a_kind_of(RuntimeError), /boo/i)
|
1270
|
-
TEST
|
1271
|
-
program =
|
1272
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1273
|
-
|
1274
|
-
expected_output =
|
1275
|
-
build_expected_output(
|
1276
|
-
color_enabled: color_enabled,
|
1277
|
-
snippet:
|
1278
|
-
"expect { raise StandardError.new('boo') }.to raise_error(a_kind_of(RuntimeError), /boo/i)",
|
1279
|
-
newline_before_expectation: true,
|
1280
|
-
expectation:
|
1281
|
-
proc do
|
1282
|
-
line do
|
1283
|
-
plain "Expected raised exception "
|
1284
|
-
actual %|#<StandardError "boo">|
|
1285
|
-
end
|
1286
|
-
|
1287
|
-
line do
|
1288
|
-
plain " to match "
|
1289
|
-
expected "#<a kind of RuntimeError> with message matching /boo/i"
|
1290
|
-
end
|
1291
|
-
end
|
1292
|
-
)
|
1293
|
-
|
1294
|
-
expect(program).to produce_output_when_run(
|
1295
|
-
expected_output
|
1296
|
-
).in_color(color_enabled)
|
1297
|
-
end
|
1298
|
-
end
|
1299
|
-
end
|
1300
|
-
end
|
1301
|
-
|
1302
|
-
context "when used in the negative" do
|
1303
|
-
it "produces the correct failure message" do
|
1304
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1305
|
-
snippet = <<~TEST.strip
|
1306
|
-
expect { raise StandardError.new('boo') }.not_to raise_error(a_kind_of(StandardError), /boo/i)
|
1307
|
-
TEST
|
1308
|
-
program =
|
1309
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1310
|
-
|
1311
|
-
expected_output =
|
1312
|
-
build_expected_output(
|
1313
|
-
color_enabled: color_enabled,
|
1314
|
-
snippet:
|
1315
|
-
"expect { raise StandardError.new('boo') }.not_to raise_error(a_kind_of(StandardError), /boo/i)",
|
1316
|
-
newline_before_expectation: true,
|
1317
|
-
expectation:
|
1318
|
-
proc do
|
1319
|
-
line do
|
1320
|
-
plain "Expected raised exception "
|
1321
|
-
actual %|#<StandardError "boo">|
|
1322
|
-
end
|
1323
|
-
|
1324
|
-
line do
|
1325
|
-
plain " not to match "
|
1326
|
-
expected "#<a kind of StandardError> with message matching /boo/i"
|
1327
|
-
end
|
1328
|
-
end
|
1329
|
-
)
|
1330
|
-
|
1331
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
1332
|
-
color_enabled
|
1333
|
-
)
|
1334
|
-
end
|
1335
|
-
end
|
1336
|
-
end
|
1337
|
-
end
|
1338
|
-
|
1339
|
-
# NOTE: No need to test this using a string or regexp message — we've tested
|
1340
|
-
# it enough above
|
1341
|
-
context "given a compound RSpec matcher" do
|
1342
|
-
context "when used in the positive" do
|
1343
|
-
context "when the block raises a different error than what is given" do
|
1344
|
-
context "when the expected error and/or actual message is short" do
|
1345
|
-
it "produces the correct failure message" do
|
1346
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1347
|
-
snippet = <<~TEST.strip
|
1348
|
-
expect { raise StandardError.new('boo') }.to raise_error(a_kind_of(Array).or eq(true))
|
1349
|
-
TEST
|
1350
|
-
program =
|
1351
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1352
|
-
|
1353
|
-
expected_output =
|
1354
|
-
build_expected_output(
|
1355
|
-
color_enabled: color_enabled,
|
1356
|
-
snippet:
|
1357
|
-
"expect { raise StandardError.new('boo') }.to raise_error(a_kind_of(Array).or eq(true))",
|
1358
|
-
expectation:
|
1359
|
-
proc do
|
1360
|
-
line do
|
1361
|
-
plain "Expected raised exception "
|
1362
|
-
actual %|#<StandardError "boo">|
|
1363
|
-
plain " to match "
|
1364
|
-
expected "#<a kind of Array or eq true>"
|
1365
|
-
plain "."
|
1366
|
-
end
|
1367
|
-
end
|
1368
|
-
)
|
1369
|
-
|
1370
|
-
expect(program).to produce_output_when_run(
|
1371
|
-
expected_output
|
1372
|
-
).in_color(color_enabled)
|
1373
|
-
end
|
1374
|
-
end
|
1375
|
-
end
|
1376
|
-
|
1377
|
-
context "when the expected error and/or actual message is long"
|
1378
|
-
end
|
1379
|
-
|
1380
|
-
context "when the block raises no error" do
|
1381
|
-
it "produces the correct failure message" do
|
1382
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1383
|
-
snippet = <<~TEST.strip
|
1384
|
-
expect { }.to raise_error(a_kind_of(RuntimeError).and having_attributes(beep: :boop))
|
1385
|
-
TEST
|
1386
|
-
program =
|
1387
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1388
|
-
|
1389
|
-
expected_output =
|
1390
|
-
build_expected_output(
|
1391
|
-
color_enabled: color_enabled,
|
1392
|
-
snippet:
|
1393
|
-
"expect { }.to raise_error(a_kind_of(RuntimeError).and having_attributes(beep: :boop))",
|
1394
|
-
newline_before_expectation: true,
|
1395
|
-
expectation:
|
1396
|
-
proc do
|
1397
|
-
line do
|
1398
|
-
plain "Expected "
|
1399
|
-
actual "exception-free block"
|
1400
|
-
end
|
1401
|
-
|
1402
|
-
line do
|
1403
|
-
plain "to raise "
|
1404
|
-
expected "#<a kind of RuntimeError and having attributes (beep: :boop)>"
|
1405
|
-
end
|
1406
|
-
end
|
1407
|
-
)
|
1408
|
-
|
1409
|
-
expect(program).to produce_output_when_run(
|
1410
|
-
expected_output
|
1411
|
-
).in_color(color_enabled)
|
1412
|
-
end
|
1413
|
-
end
|
1414
|
-
end
|
1415
|
-
end
|
1416
|
-
|
1417
|
-
context "when used in the negative" do
|
1418
|
-
context "when the expected and/or actual message is short" do
|
1419
|
-
it "produces the correct failure message" do
|
1420
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1421
|
-
snippet = <<~TEST.strip
|
1422
|
-
expect { raise StandardError.new('boo') }.not_to raise_error(a_kind_of(StandardError).or eq(true))
|
1423
|
-
TEST
|
1424
|
-
program =
|
1425
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1426
|
-
|
1427
|
-
expected_output =
|
1428
|
-
build_expected_output(
|
1429
|
-
color_enabled: color_enabled,
|
1430
|
-
snippet:
|
1431
|
-
"expect { raise StandardError.new('boo') }.not_to raise_error(a_kind_of(StandardError).or eq(true))",
|
1432
|
-
expectation:
|
1433
|
-
proc do
|
1434
|
-
line do
|
1435
|
-
plain "Expected raised exception "
|
1436
|
-
actual %|#<StandardError "boo">|
|
1437
|
-
plain " not to match "
|
1438
|
-
expected "#<a kind of StandardError or eq true>"
|
1439
|
-
plain "."
|
1440
|
-
end
|
1441
|
-
end
|
1442
|
-
)
|
1443
|
-
|
1444
|
-
expect(program).to produce_output_when_run(
|
1445
|
-
expected_output
|
1446
|
-
).in_color(color_enabled)
|
1447
|
-
end
|
1448
|
-
end
|
1449
|
-
end
|
1450
|
-
|
1451
|
-
context "when the expected and/or actual message is long" do
|
1452
|
-
it "produces the correct failure message" do
|
1453
|
-
as_both_colored_and_uncolored do |color_enabled|
|
1454
|
-
snippet = <<~TEST.strip
|
1455
|
-
expect { raise StandardError.new('this is a super super long message') }.not_to raise_error(a_kind_of(StandardError).and having_attributes(message: kind_of(String)))
|
1456
|
-
TEST
|
1457
|
-
program =
|
1458
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1459
|
-
|
1460
|
-
expected_output =
|
1461
|
-
build_expected_output(
|
1462
|
-
color_enabled: color_enabled,
|
1463
|
-
snippet:
|
1464
|
-
"expect { raise StandardError.new('this is a super super long message') }.not_to raise_error(a_kind_of(StandardError).and having_attributes(message: kind_of(String)))",
|
1465
|
-
newline_before_expectation: true,
|
1466
|
-
expectation:
|
1467
|
-
proc do
|
1468
|
-
line do
|
1469
|
-
plain "Expected raised exception "
|
1470
|
-
actual %|#<StandardError "this is a super super long message">|
|
1471
|
-
end
|
1472
|
-
|
1473
|
-
line do
|
1474
|
-
plain " not to match "
|
1475
|
-
expected "#<a kind of StandardError and having attributes (message: #<a kind of String>)>"
|
1476
|
-
end
|
1477
|
-
end
|
1478
|
-
)
|
1479
|
-
|
1480
|
-
expect(program).to produce_output_when_run(
|
1481
|
-
expected_output
|
1482
|
-
).in_color(color_enabled)
|
1483
|
-
end
|
1484
|
-
end
|
1485
|
-
end
|
1486
|
-
end
|
1487
|
-
end
|
1488
|
-
end
|