Sha256: 8458f6cd7c46277ba9658dbae2074525e4e6ad6785bc9e96ec9123268c317153

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

require 'stackable_flash/test_helpers'   # Used in the definition of these matchers
require 'stackable_flash/rspec_matchers' # Not used here, but for convenience
require 'cacheable_flash/test_helpers'   # Used in the definition of these matchers

module CacheableFlash
  module RspecMatchers
    include StackableFlash::TestHelpers
    include CacheableFlash::TestHelpers
    RSpec::Matchers.define :have_flash_cookie do |flash_status, expecting|
      define_method :has_flash_cookie? do |response|
        flash_in_stack(flash_cookie_for(response)[flash_status], expecting)
      end
      match{|response| has_flash_cookie?(response)}
      failure_message do |actual|
        "expected flash[:#{expected[0]}] to be or include #{expected[1].inspect}, but got #{flash_cookie_for(actual)[expected[0]]}"
      end
      failure_message_when_negated do |actual|
        "expected flash[:#{expected[0]}] to not be and not include #{expected[1].inspect}, but got #{flash_cookie_for(actual)[expected[0]]}"
      end
    end

    RSpec::Matchers.define :have_cacheable_flash do |flash_status, expecting|
      define_method :has_cacheable_flash? do |response|
        flash_in_stack(flash_cookie_for(response)[flash_status], expecting)
      end
      match{|response| has_cacheable_flash?(response)}
      failure_message do |actual|
        "expected flash[:#{expected[0]}] to be or include #{expected[1].inspect}, but got #{flash_cookie_for(actual)[expected[0]]}"
      end
      failure_message_when_negated do |actual|
        "expected flash[:#{expected[0]}] to not be and not include #{expected[1].inspect}, but got #{flash_cookie_for(actual)[expected[0]]}"
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cacheable_flash-1.0.0 lib/cacheable_flash/rspec_matchers.rb
cacheable_flash-0.3.4 lib/cacheable_flash/rspec_matchers.rb