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.



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

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



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

def call(negated:)
  @negated = negated

  fill_template
  template.to_s
end

#matcher_descriptionObject



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

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