Class: GritterNotices::RSpecMatcher::HaveGritterNotice

Inherits:
Object
  • Object
show all
Defined in:
lib/gritter_notices/rspec_matcher.rb

Instance Method Summary collapse

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

#descriptionObject



12
13
14
# File 'lib/gritter_notices/rspec_matcher.rb', line 12

def description
  "send gritter notice '#{@text}' to '#{@model}"
end

#failure_messageObject



24
25
26
# File 'lib/gritter_notices/rspec_matcher.rb', line 24

def failure_message
  'gritter_notice failure'
end

#failure_text_for_shouldObject



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_notObject



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

Returns:

  • (Boolean)


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.options[:gritter_key] == @text }.empty?
end