Sha256: 83ef8d82936f2d7f86957379bd74b441e9b1468f1be28e64266e96a386312679
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 KB
Contents
require "spec_helper" require "rack" describe SocialAvatarProxy::App do subject do app = SocialAvatarProxy::App Rack::MockRequest.new(app) end let(:successful_response) do response = Net::HTTPSuccess.new("1.1", 200, "Success") response.stub(:stream_check).and_return(true) response.stub(:read_body).and_return("data") response end let(:not_found_response) do Net::HTTPNotFound.new("1.1", 404, "Not Found") end let(:response) { nil } before(:each) do klass = SocialAvatarProxy::Avatar klass.any_instance.stub(:response).and_return(response) end context "given an invalid path" do it "should return a 404 response" do path = "/unknown" expect(subject.get(path).status).to eq(404) end end context "given a valid path" do context "that finds an existing avatar" do let(:response) { successful_response } it "should return a 200 response" do path = "/facebook/61413673" expect(subject.get(path).status).to eq(200) end end context "that fails to find an avatar" do let(:response) { not_found_response } it "should return a 404 response" do path = "/facebook/someRandomUserThatDoesntExist" expect(subject.get(path).status).to eq(404) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems