Class: SuperDiff::RSpec::MatcherTextBuilders::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/super_diff/rspec/matcher_text_builders/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(actual:, expected_for_failure_message:, expected_for_description:, expected_action_for_failure_message:, expected_action_for_description:) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/super_diff/rspec/matcher_text_builders/base.rb', line 5

def initialize(
  actual:,
  expected_for_failure_message:,
  expected_for_description:,
  expected_action_for_failure_message:,
  expected_action_for_description:
)
  @actual = actual
  @expected_for_failure_message = expected_for_failure_message
  @expected_for_description = expected_for_description
  @expected_action_for_failure_message =
    expected_action_for_failure_message
  @expected_action_for_description = expected_action_for_description

  @negated = nil
  @template = MatcherTextTemplate.new
end

Instance Method Details

#call(negated:) ⇒ Object



23
24
25
26
27
28
# File 'lib/super_diff/rspec/matcher_text_builders/base.rb', line 23

def call(negated:)
  @negated = negated

  fill_template
  template.to_s
end

#matcher_descriptionObject



30
31
32
33
34
35
36
37
38
# File 'lib/super_diff/rspec/matcher_text_builders/base.rb', line 30

def matcher_description
  template = MatcherTextTemplate.new do |t|
    t.add_text expected_action_for_description
    add_expected_value_to_description(t)
    add_extra_after_expected_to(t)
  end

  Csi.decolorize(template.to_s(as_single_line: true))
end