Skip to content

Commit 6839ec9

Browse files
committed
Give FailureMessageTemplate and FailureMessageBuilders better names
1 parent 7eb25ec commit 6839ec9

File tree

12 files changed

+49
-55
lines changed

12 files changed

+49
-55
lines changed

lib/super_diff/rspec.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@ module RSpec
66
autoload :Configuration, "super_diff/rspec/configuration"
77
autoload :Differ, "super_diff/rspec/differ"
88
autoload :Differs, "super_diff/rspec/differs"
9-
autoload(
10-
:FailureMessageBuilders,
11-
"super_diff/rspec/failure_message_builders",
12-
)
13-
autoload(
14-
:FailureMessageTemplate,
15-
"super_diff/rspec/failure_message_template",
16-
)
9+
autoload :MatcherTextBuilders, "super_diff/rspec/matcher_text_builders"
10+
autoload :MatcherTextTemplate, "super_diff/rspec/matcher_text_template"
1711
autoload :ObjectInspection, "super_diff/rspec/object_inspection"
1812
autoload :OperationalSequencers, "super_diff/rspec/operational_sequencers"
1913

lib/super_diff/rspec/augmented_matcher.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module AugmentedMatcher
44
# Update to use expected_for_description instead of @expected
55
# TODO: Test
66
def description
7-
failure_message_template_builder.matcher_description
7+
matcher_text_builder.matcher_description
88
end
99

1010
# Colorize the 'actual' value
@@ -26,7 +26,7 @@ def diffable?
2626
protected
2727

2828
def build_failure_message(negated:)
29-
failure_message_template_builder.call(negated: negated)
29+
matcher_text_builder.call(negated: negated)
3030
end
3131

3232
def actual_for_failure_message
@@ -37,17 +37,17 @@ def expected_for_failure_message
3737
description_of(expected)
3838
end
3939

40-
def failure_message_template_builder
41-
@_failure_message_template_builder ||=
42-
failure_message_template_builder_class.new(
40+
def matcher_text_builder
41+
@_matcher_text_builder ||=
42+
matcher_text_builder_class.new(
4343
actual: actual_for_failure_message,
4444
expected: expected_for_failure_message,
4545
expected_action: expected_action,
4646
)
4747
end
4848

49-
def failure_message_template_builder_class
50-
FailureMessageBuilders::Base
49+
def matcher_text_builder_class
50+
MatcherTextBuilders::Base
5151
end
5252

5353
private

lib/super_diff/rspec/failure_message_builders.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module SuperDiff
2+
module RSpec
3+
module MatcherTextBuilders
4+
autoload :Base, "super_diff/rspec/matcher_text_builders/base"
5+
autoload(
6+
:BePredicate,
7+
"super_diff/rspec/matcher_text_builders/be_predicate",
8+
)
9+
autoload(
10+
:ContainExactly,
11+
"super_diff/rspec/matcher_text_builders/contain_exactly",
12+
)
13+
autoload :Match, "super_diff/rspec/matcher_text_builders/match"
14+
autoload(
15+
:RaiseError,
16+
"super_diff/rspec/matcher_text_builders/raise_error",
17+
)
18+
autoload(
19+
:RespondTo,
20+
"super_diff/rspec/matcher_text_builders/respond_to",
21+
)
22+
end
23+
end
24+
end

lib/super_diff/rspec/failure_message_builders/base.rb renamed to lib/super_diff/rspec/matcher_text_builders/base.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module SuperDiff
22
module RSpec
3-
module FailureMessageBuilders
3+
module MatcherTextBuilders
44
class Base
55
def initialize(actual:, expected:, expected_action:)
66
@actual = actual
77
@expected = expected
88
@expected_action = expected_action
99

1010
@negated = nil
11-
@template = FailureMessageTemplate.new
11+
@template = MatcherTextTemplate.new
1212
end
1313

1414
def call(negated:)
@@ -19,7 +19,7 @@ def call(negated:)
1919
end
2020

2121
def matcher_description
22-
template = FailureMessageTemplate.new do |t|
22+
template = MatcherTextTemplate.new do |t|
2323
t.add_text expected_action
2424
add_expected_value_to(t)
2525
end
@@ -78,7 +78,7 @@ def add_actual_value
7878
end
7979

8080
def expected_section
81-
FailureMessageTemplate.new do |t|
81+
MatcherTextTemplate.new do |t|
8282
t.add_text_in_singleline_mode expected_phrase
8383
t.add_text_in_multiline_mode do
8484
expected_phrase.to_s.rjust(phrase_width)

lib/super_diff/rspec/failure_message_builders/be_predicate.rb renamed to lib/super_diff/rspec/matcher_text_builders/be_predicate.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module SuperDiff
22
module RSpec
3-
module FailureMessageBuilders
3+
module MatcherTextBuilders
44
class BePredicate < Base
55
def initialize(
66
predicate_accessible:,
@@ -15,7 +15,7 @@ def initialize(
1515
end
1616

1717
def matcher_description
18-
template = FailureMessageTemplate.new do |t|
18+
template = MatcherTextTemplate.new do |t|
1919
t.add_text "return true for"
2020
add_expected_value_to(t)
2121
end

lib/super_diff/rspec/failure_message_builders/contain_exactly.rb renamed to lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module SuperDiff
22
module RSpec
3-
module FailureMessageBuilders
3+
module MatcherTextBuilders
44
class ContainExactly < Base
55
protected
66

lib/super_diff/rspec/failure_message_builders/match.rb renamed to lib/super_diff/rspec/matcher_text_builders/match.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module SuperDiff
22
module RSpec
3-
module FailureMessageBuilders
3+
module MatcherTextBuilders
44
class Match < Base
55
def initialize(expected_captures:, **rest)
66
super(rest)

lib/super_diff/rspec/failure_message_builders/raise_error.rb renamed to lib/super_diff/rspec/matcher_text_builders/raise_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module SuperDiff
22
module RSpec
3-
module FailureMessageBuilders
3+
module MatcherTextBuilders
44
class RaiseError < Base
55
protected
66

lib/super_diff/rspec/failure_message_builders/respond_to.rb renamed to lib/super_diff/rspec/matcher_text_builders/respond_to.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module SuperDiff
22
module RSpec
3-
module FailureMessageBuilders
3+
module MatcherTextBuilders
44
class RespondTo < Base
55
def initialize(
66
expected_arity:,

0 commit comments

Comments
 (0)