Class: GritterNotices::RSpecMatcher::HaveGritterNotice
- Inherits:
-
Object
- Object
- GritterNotices::RSpecMatcher::HaveGritterNotice
- Defined in:
- lib/gritter_notices/rspec_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_text_for_should ⇒ Object
- #failure_text_for_should_not ⇒ Object
-
#initialize(text) ⇒ HaveGritterNotice
constructor
A new instance of HaveGritterNotice.
-
#matches?(model) ⇒ Boolean
def to(value) @to = value self end.
Constructor Details
#initialize(text) ⇒ HaveGritterNotice
Returns a new instance of HaveGritterNotice.
8 9 10 |
# File 'lib/gritter_notices/rspec_matcher.rb', line 8 def initialize(text) @text = text end |
Instance Method Details
#description ⇒ Object
12 13 14 |
# File 'lib/gritter_notices/rspec_matcher.rb', line 12 def description "send gritter notice '#{@text}' to '#{@model}" end |
#failure_message ⇒ Object
24 25 26 |
# File 'lib/gritter_notices/rspec_matcher.rb', line 24 def 'gritter_notice failure' end |
#failure_text_for_should ⇒ Object
16 17 18 |
# File 'lib/gritter_notices/rspec_matcher.rb', line 16 def failure_text_for_should "#{@model.class} should have gritter_notice with text '#{@text}'" end |
#failure_text_for_should_not ⇒ Object
20 21 22 |
# File 'lib/gritter_notices/rspec_matcher.rb', line 20 def failure_text_for_should_not "#{@model.class} should not have an gritter_notice with text '#{@text}'" end |
#matches?(model) ⇒ Boolean
def to(value)
@to = value
self
end
38 39 40 41 |
# File 'lib/gritter_notices/rspec_matcher.rb', line 38 def matches?(model) @model = model not model.gritter_notices.select { |g| !@text or g.text == @text or g.[:gritter_key] == @text }.empty? end |