Class: BaconExpect::Matcher::StartWith

Inherits:
Object
  • Object
show all
Defined in:
lib/bacon-expect/matchers/start_with.rb

Instance Method Summary collapse

Constructor Details

#initialize(start_string) ⇒ StartWith

Returns a new instance of StartWith.



3
4
5
# File 'lib/bacon-expect/matchers/start_with.rb', line 3

def initialize(start_string)
  @start_string = start_string
end

Instance Method Details

#fail!(subject, negated) ⇒ Object

Raises:



11
12
13
# File 'lib/bacon-expect/matchers/start_with.rb', line 11

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

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/bacon-expect/matchers/start_with.rb', line 7

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