Class: RSpec::Matchers::BuiltIn::StartAndEndWith

Inherits:
Object
  • Object
show all
Defined in:
opal/opal/rspec/fixes/rspec/matchers/built_in/start_and_end_with.rb

Instance Method Summary collapse

Instance Method Details

#check_ordered_element(actual) ⇒ Object

see StartWith and EndWith below



22
23
24
25
26
# File 'opal/opal/rspec/fixes/rspec/matchers/built_in/start_and_end_with.rb', line 22

def check_ordered_element(actual)
  # Opal arity checking off by default, will check it manually
  arity = actual.method(:[]).arity
  raise ArgumentError.new "wrong number of arguments (2 for #{arity})" unless arity == 2
end

#failure_messageObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'opal/opal/rspec/fixes/rspec/matchers/built_in/start_and_end_with.rb', line 3

def failure_message
  msg = super
  if @actual_does_not_have_ordered_elements
    msg += ", but it does not have ordered elements"
  elsif !actual.respond_to?(:[])
    msg += ", but it cannot be indexed using #[]"
  end
  msg
  # string mutation
  # super.tap do |msg|
  #   if @actual_does_not_have_ordered_elements
  #     msg << ", but it does not have ordered elements"
  #   elsif !actual.respond_to?(:[])
  #     msg << ", but it cannot be indexed using #[]"
  #   end
  # end
end