Sha256: f9adaee2108005c874ab2459902345eae1adc706097658ebc229a10eade140ea

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require File.dirname(__FILE__) + '/flashing_behavior'
require File.dirname(__FILE__) + '/../spec_helper'

describe "flash messages with blocks", :type => :controller do
  setup = lambda {
    class PiratesController < ActionController::Base
      expose_many(:pirates)
    end 
  }
  setup.call
  
  def setup_flasher(action, success = nil)
    PiratesController.flash_for action, :on => success do
      "the flash is set to #{@pirate.title}"
    end
  end
  
  ActionController::Routing::Routes.draw do |map| 
    map.resources :pirates, :collection => {:test => :any}
  end
  
  controller_name :pirates
  Object.remove_class(PiratesController)
  
  before(:each) do
    setup.call
    @controller = PiratesController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
    
    @pirate = Factory.stub(:pirate, {:title => 'Captain'})
    Pirate.stub(:new => @pirate)
    
    @pirate.stub(:save => true)
    
    @custom_flash_message = "the flash is set to #{@pirate.title}"
    
    post(:create)
  end
  
  after(:each) do
    Object.remove_class(PiratesController)
  end
  
  it_should_behave_like "a flasher"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
exposure-0.2.1 spec/flashers/flash_with_block_spec.rb
exposure-0.2.0 spec/flashers/flash_with_block_spec.rb
exposure-0.1.3 spec/flashers/flash_with_block_spec.rb
exposure-0.1.2 spec/flashers/flash_with_block_spec.rb