Class: BaconExpect::Matcher::StartWith
- Inherits:
-
Object
- Object
- BaconExpect::Matcher::StartWith
- Defined in:
- lib/bacon-expect/matchers/start_with.rb
Instance Method Summary collapse
- #fail!(subject, negated) ⇒ Object
-
#initialize(start_string) ⇒ StartWith
constructor
A new instance of StartWith.
- #matches?(subject) ⇒ Boolean
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
11 12 13 |
# File 'lib/bacon-expect/matchers/start_with.rb', line 11 def fail!(subject, negated) raise FailedExpectation.new(FailMessageRenderer.(negated, subject, @start_string)) end |
#matches?(subject) ⇒ 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 |