Sha256: 6cdf3e752eb203357281ab4889409b5a7cada653966627c733a28874c3075f7c
Contents?: true
Size: 1.38 KB
Versions: 8
Compression:
Stored size: 1.38 KB
Contents
require File.dirname(__FILE__) + '/../../../spec_helper' require 'rack/test' require 'useless/doc/proxy/subject' describe Useless::Doc::Proxy::Subject do include Rack::Test::Methods def app @app ||= lambda do |env| base_app = lambda do |env| [200, {'Content-Type' => 'text/plain'}, [env['useless.doc.subject']]] end env['useless.doc.url'] = 'some.api.com' Useless::Doc::Proxy::Subject.new(base_app).call(env) end end it 'should retrieve the subject from the stub client in a non-production environment' do Useless::Doc::Client.stub.should_receive(:get).with('some.api.com').and_return('test subject') get 'some.doc.api.com' last_response.should be_ok last_response.body.should == 'test subject' end it 'should retrieve the subject from the standard client in a production environment' do begin ENV['RACK_ENV'] = 'production' Useless::Doc::Client.standard.should_receive(:get).with('some.api.com').and_return('production subject') get 'some.doc.api.com' last_response.should be_ok last_response.body.should == 'production subject' ensure ENV['RACK_ENV'] = 'test' end end it 'should return a 404 if no subject is returned' do Useless::Doc::Client.stub.should_receive(:get).with('some.api.com').and_return(nil) get 'some.doc.api.com' last_response.should be_not_found end end
Version data entries
8 entries across 8 versions & 1 rubygems