Sha256: 75d6e4426279e070657542e64aec143bbdfcfe8815ed299771e942b010f12f17

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

shared_examples_for "a flasher" do
  describe "responding with a method call" do
    before(:each) do
      setup_flasher(:create)
    end
    
    it "should respond with redirect to test on success" do
      @pirate.stub(:save => true)
      post(:create)
      should set_the_flash.to(@custom_flash_message)
    end
    
    it "should respond with redirect to test on failure" do
      @pirate.stub(:save => false)
      post(:create)
      should set_the_flash.to(@custom_flash_message)
    end
  end
  
  describe "responding with a method call :on => :success" do
    before(:each) do
      setup_flasher(:create, :success)
     end

    it "should respond with custom response on success" do
       @pirate.stub(:save => true)
       post(:create)
       should set_the_flash.to(@custom_flash_message)
     end

    it "should not respond with custom response on failure" do
       @pirate.stub(:save => false)
       post(:create)
       should_not redirect_to({:action => 'test'})
     end
  end
  
  describe "responding with a method call :on => :failure" do
      before(:each) do
        setup_flasher(:create, :failure)
      end

      it "should not respond with custom response  on success" do
        @pirate.stub(:save => true)
        post(:create)        
        should_not redirect_to({:action => 'test'})
      end

      it "should respond with custom response on failure" do
        @pirate.stub(:save => false)
        post(:create)
        should set_the_flash.to(@custom_flash_message)
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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