Sha256: 6d6e1430e3834d108185eb555dd4d580f5a91a691134f2561ff65d429f37ee49
Contents?: true
Size: 1.42 KB
Versions: 12
Compression:
Stored size: 1.42 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper' require 'rack' def dummy_rack_app lambda{|env| [200, {"Content-Type" => "text/html"}, ["dummy_rack_app body"]] } end describe Dragonfly::Middleware do def make_request(app, url) Rack::MockRequest.new(app).get(url) end before(:each) do @stack = Rack::Builder.new do use Dragonfly::Middleware, :images run dummy_rack_app end end it "should continue the calling chain if the app returns a 404 for that url" do Dragonfly::App[:images].should_receive(:call).and_return( [404, {"Content-Type" => 'text/plain'}, ['Not found']] ) response = make_request(@stack, 'hello.png?howare=you') response.status.should == 200 response.body.should == 'dummy_rack_app body' end it "should return as per the dragonfly app if the app returns a 200" do Dragonfly::App[:images].should_receive(:call).and_return( [200, {"Content-Type" => 'text/plain'}, ['ABCD']] ) response = make_request(@stack, 'hello.png?howare=you') response.status.should == 200 response.body.should == 'ABCD' end it "should return as per the dragonfly app if the app returns a 400" do Dragonfly::App[:images].should_receive(:call).and_return( [400, {"Content-Type" => 'text/plain'}, ['ABCD']] ) response = make_request(@stack, 'hello.png?howare=you') response.status.should == 400 response.body.should == 'ABCD' end end
Version data entries
12 entries across 12 versions & 1 rubygems