Sha256: 0260913d74d9ddf215881aa4fa5499c7fa7a6ea4f312a2e15947435b12d6def8

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

module CacheableFlash
  describe TestHelpers do
    attr_reader :controller, :request, :response, :flash, :cookies
    include TestHelpers
    before do
      @controller = ActionController::Base.new
      @request = ActionController::TestRequest.new
      @response = ActionController::TestResponse.new
      controller.send(:initialize_template_class, response)
      controller.send(:assign_shortcuts, request, response)

      @flash = controller.send(:flash)
      class << controller
        include CacheableFlash
      end
    end

    describe "#flash_cookie" do
      it "returns the flash hash send as a cookie" do
        expected_flash = {
        'errors' => "This is an Error",
        'notice' => "This is a Notice"
        }
        flash['errors'] = expected_flash['errors']
        flash['notice'] = expected_flash['notice']

        controller.write_flash_to_cookie
        @cookies = response.cookies # simulate setting the cookie instance variable in rails tests

        flash_cookie.should == expected_flash
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cacheable_flash-0.2.2 spec/cacheable_flash/test_helpers_spec.rb
cacheable_flash-0.2.1 spec/cacheable_flash/test_helpers_spec.rb
cacheable_flash-0.2.0 spec/cacheable_flash/test_helpers_spec.rb