Skip to content

Commit c8ab089

Browse files
committed
Reorganize tests
This commit is mainly about splitting up rspec_spec.rb into many files so we don't have a 3000-line file that we have to manage.
1 parent 937a5d3 commit c8ab089

18 files changed

+3497
-3465
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require "spec_helper"
2+
3+
RSpec.describe "Integration with Rails's ActiveRecord class", type: :integration do
4+
context "when using 'super_diff/rspec-rails'" do
5+
include_context "integration with ActiveRecord"
6+
7+
def make_program(test)
8+
make_rspec_rails_test_program(test)
9+
end
10+
end
11+
12+
context "when using 'super_diff/active_record'" do
13+
include_context "integration with ActiveRecord"
14+
15+
def make_program(test)
16+
make_rspec_active_record_program(test)
17+
end
18+
end
19+
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require "spec_helper"
2+
3+
RSpec.describe "Integration with Rails's HashWithIndifferentAccess", type: :integration do
4+
context "when using 'super_diff/rspec-rails'" do
5+
include_context "integration with HashWithIndifferentAccess"
6+
7+
def make_program(test)
8+
make_rspec_rails_test_program(test)
9+
end
10+
end
11+
12+
xcontext "when using 'super_diff/active_support'" do
13+
include_context "integration with HashWithIndifferentAccess"
14+
15+
def make_program(test)
16+
make_rspec_active_support_program(test)
17+
end
18+
end
19+
end
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
require "spec_helper"
2+
3+
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
9+
10+
expected_output = build_colored_expected_output(
11+
snippet: %|expect(:foo).to be_falsey|,
12+
expectation: proc {
13+
line do
14+
plain "Expected "
15+
green %|:foo|
16+
plain " to be "
17+
red %|falsey|
18+
plain "."
19+
end
20+
},
21+
)
22+
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)
47+
end
48+
end
49+
end

0 commit comments

Comments
 (0)