Skip to content

Commit a2ee9b4

Browse files
committed
Test each matcher with color enabled and disabled
1 parent e230082 commit a2ee9b4

18 files changed

+1624
-1484
lines changed

spec/integration/rails/active_record_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
context "when using 'super_diff/rspec-rails'" do
55
include_context "integration with ActiveRecord"
66

7-
def make_program(test)
8-
make_rspec_rails_test_program(test)
7+
def make_program(test, color_enabled:)
8+
make_rspec_rails_test_program(test, color_enabled: color_enabled)
99
end
1010
end
1111

1212
context "when using 'super_diff/active_record'" do
1313
include_context "integration with ActiveRecord"
1414

15-
def make_program(test)
16-
make_rspec_active_record_program(test)
15+
def make_program(test, color_enabled:)
16+
make_rspec_active_record_program(test, color_enabled: color_enabled)
1717
end
1818
end
1919
end

spec/integration/rails/hash_with_indifferent_access_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
context "when using 'super_diff/rspec-rails'" do
55
include_context "integration with HashWithIndifferentAccess"
66

7-
def make_program(test)
8-
make_rspec_rails_test_program(test)
7+
def make_program(test, color_enabled:)
8+
make_rspec_rails_test_program(test, color_enabled: color_enabled)
99
end
1010
end
1111

1212
context "when using 'super_diff/active_support'" do
1313
include_context "integration with HashWithIndifferentAccess"
1414

15-
def make_program(test)
16-
make_rspec_active_support_program(test)
15+
def make_program(test, color_enabled:)
16+
make_rspec_active_support_program(test, color_enabled: color_enabled)
1717
end
1818
end
1919
end
Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
require "spec_helper"
22

33
RSpec.describe "Integration with RSpec's #be_falsey matcher", type: :integration do
4-
context "assuming color is enabled" do
5-
it "produces the correct output" do
6-
program = make_plain_test_program(<<~TEST.strip)
7-
expect(:foo).to be_falsey
8-
TEST
4+
it "produces the correct failure message" do
5+
as_both_colored_and_uncolored do |color_enabled|
6+
snippet = %|expect(:foo).to be_falsey|
7+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
98

10-
expected_output = build_colored_expected_output(
11-
snippet: %|expect(:foo).to be_falsey|,
9+
expected_output = build_expected_output(
10+
color_enabled: color_enabled,
11+
snippet: snippet,
1212
expectation: proc {
1313
line do
1414
plain "Expected "
@@ -20,30 +20,9 @@
2020
},
2121
)
2222

23-
expect(program).to produce_output_when_run(expected_output)
24-
end
25-
end
26-
27-
context "if color has been disabled" do
28-
it "does not include the color in the output" do
29-
program = make_plain_test_program(<<~TEST.strip, color_enabled: false)
30-
expect(:foo).to be_falsey
31-
TEST
32-
33-
expected_output = build_uncolored_expected_output(
34-
snippet: %|expect(:foo).to be_falsey|,
35-
expectation: proc {
36-
line do
37-
plain "Expected "
38-
plain %|:foo|
39-
plain " to be "
40-
plain %|falsey|
41-
plain "."
42-
end
43-
},
44-
)
45-
46-
expect(program).to produce_output_when_run(expected_output)
23+
expect(program).
24+
to produce_output_when_run(expected_output).
25+
in_color(color_enabled)
4726
end
4827
end
4928
end

0 commit comments

Comments
 (0)