Sha256: 1707030596d2ba6685144f48b7bc41590e9a9f56c3c7d5ea55027d15e173d193

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

require File.join(File.dirname(__FILE__), 'set_session_matcher') 

module Remarkable
  module ActionController
    module Matchers
      class SetTheFlashMatcher < SetSessionMatcher #:nodoc:

        protected
          def session
            @subject ? (@subject.response.session['flash'] || {}) : {}
          end

          def interpolation_options
            { :flash_inspect => session.symbolize_keys!.inspect }
          end

      end

      # Ensures that a session keys were set. If you want to check that a flash
      # is not being set, please do:
      #
      #   should_not_set_the_flash(:user)
      #
      # If you want to assure that a flash is being set to nil, do instead:
      #
      #   should_set_the_flash(:user).to(nil)
      #
      # == Options
      #
      # * <tt>:to</tt> - The value to compare the flash key. It accepts procs and can also be given as a block (see examples below)
      #
      # == Examples
      #
      #   should_set_the_flash
      #   should_not_set_the_flash
      #
      #   should_set_the_flash :to => 'message'
      #   should_set_the_flash :notice, :warn
      #   should_set_the_flash :notice, :to => 'message'
      #   should_set_the_flash :notice, :to => proc{ 'hi ' + users(:first).name }
      #   should_set_the_flash(:notice){ 'hi ' + users(:first).name }
      #
      #   it { should set_the_flash }
      #   it { should set_the_flash.to('message') }
      #   it { should set_the_flash(:notice, :warn) }
      #   it { should set_the_flash(:notice, :to => 'message') }
      #   it { should set_the_flash(:notice, :to => ('hi ' + users(:first).name)) }
      #
      def set_the_flash(*args, &block)
        SetTheFlashMatcher.new(*args, &block).spec(self)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
remarkable_rails-3.0.2 lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb
remarkable_rails-3.0.3 lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb
remarkable_rails-3.0.5 lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb
remarkable_rails-3.0.4 lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb