Sha256: b2dbf03a2a5d1194c336829d52b75c8dc82dfe1761eec74ef5bea945f4bd67e3

Contents?: true

Size: 948 Bytes

Versions: 3

Compression:

Stored size: 948 Bytes

Contents

module GritterNotices
  module RSpecMatcher
    def have_gritter_notice(message=nil)
      HaveGritterNotice.new(message)
    end

    class HaveGritterNotice
      def initialize(message)
        @message = message
      end

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

      def failure_message_for_should
        "#{@model.class} should have gritter_notice with message '#{@message}'"
      end

      def failure_message_for_should_not
        "#{@model.class} should not have an gritter_notice with message '#{@message}'"
      end

      # def from(value)
      #   @from = value
      #   self
      # end

      # def to(value)
      #   @to = value
      #   self
      # end

      def matches?(model)
        @model = model
        not model.gritter_notices.select { |g| !@message or g.message == @message or g.options[:gritter_message_key] == @message }.empty?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gritter_notices-0.3.1 lib/gritter_notices/rspec_matcher.rb
gritter_notices-0.2.0 lib/gritter_notices/rspec_matcher.rb
gritter_notices-0.1.1 lib/gritter_notices/rspec_matcher.rb