Sha256: bdc81ebd78e78444691f6ade7925cb15ee670b34ad2889f64ed6461a490c9618

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

shared_examples_for "a responder" do
  describe "responding with a method call" do
    before(:each) do
      setup_responder(:create)
    end
    
    it "should respond with redirect to test on success" do
      @pirate.stub(:save => true)
      post(:create)
      should redirect_to({:action => 'test'})
    end
    
    it "should respond with redirect to test on failure" do
      @pirate.stub(:save => false)
      post(:create)
      should redirect_to({:action => 'test'})
    end
  end
  
  describe "responding with a method call :on => :success" do
    before(:each) do
      setup_responder(:create, :success)
     end

    it "should respond with custom response on success" do
       @pirate.stub(:save => true)
       post(:create)
       should redirect_to({:action => 'test'})
     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_responder(: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 redirect_to({:action => 'test'})
      end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
exposure-0.2.1 spec/responders/responding_behavior.rb
exposure-0.2.0 spec/responders/responding_behavior.rb
exposure-0.1.3 spec/responders/responding_behavior.rb
exposure-0.1.2 spec/responders/responding_behavior.rb