Sha256: 59c04fa00361588aaf7610ce8a1834edd31e8f9ed5ba33b7920ab835044c27ab

Contents?: true

Size: 609 Bytes

Versions: 1

Compression:

Stored size: 609 Bytes

Contents

require 'cacheable_flash/test_helpers'

module CacheableFlash
  module RspecMatchers
    include CacheableFlash::TestHelpers
    RSpec::Matchers.define :have_flash_cookie do |flash_status, regex|
      define_method :has_flash_cookie? do |response|
        regex = /#{Regexp.escape(regex)}/ if regex.is_a?(String)

        cook = begin
          response.cookies['flash'] ?
            JSON(response.cookies['flash']) :
            {}
        rescue JSON::ParserError
          {}
        end
        cook[flash_status] =~ regex
      end
      match{|response| has_flash_cookie?(response)}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cacheable_flash-0.2.10 lib/cacheable_flash/rspec_matchers.rb