Sha256: ca6da73f927f86656b06dd81ce788e16ee07d082425407ca19a7a49bfa47d4a3

Contents?: true

Size: 991 Bytes

Versions: 2

Compression:

Stored size: 991 Bytes

Contents

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

describe 'Rack::GoogleImage' do
  include Rack::Test::Methods

  def app
    Rack::GoogleImage.new(TestRackApp.new)
  end

  describe '#call' do

    context "GET /" do
      before(:each) do
        get '/'
      end

      it "should return status code 200" do
        last_response.status.should == 200
      end

      it "should return html" do
        last_response.body.should == TestRackApp::DummyBody.to_s
      end
    end

    context "GET /yahoo.jpg" do
      before(:each) do
        Rack::GoogleImage.any_instance.stub(:search_image).and_return('foo')
        get '/yahoo.jpg'
      end

      it "should return jpg via google search" do
        last_response.body.should == "foo"
      end

      it "should change jpg content" do
        last_response.body.should_not == TestRackApp::DummyImage.to_s
      end

      it "should return status code 200" do
        last_response.status.should == 200
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-middleware-google-image-0.0.3 spec/middleware_spec.rb
rack-middleware-google-image-0.0.2 spec/middleware_spec.rb