Class: MotionSpec::Matcher::StartWith

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-spec/matcher/start_with.rb

Instance Method Summary collapse

Constructor Details

#initialize(start_string) ⇒ StartWith

Returns a new instance of StartWith.



5
6
7
# File 'lib/motion-spec/matcher/start_with.rb', line 5

def initialize(start_string)
  @start_string = start_string
end

Instance Method Details

#fail!(subject, negated) ⇒ Object

Raises:



13
14
15
16
17
18
19
# File 'lib/motion-spec/matcher/start_with.rb', line 13

def fail!(subject, negated)
  raise FailedExpectation.new(
    FailMessageRenderer.message_for_start_with(
      negated, subject, @start_string
    )
  )
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/motion-spec/matcher/start_with.rb', line 9

def matches?(subject)
  subject[0...@start_string.size] == @start_string
end