spec/tinder/connection_spec.rb in tinder-1.4.1 vs spec/tinder/connection_spec.rb in tinder-1.4.2

- old
+ new

@@ -1,29 +1,32 @@ require 'spec_helper' describe Tinder::Connection do describe "authentication" do it "should raise an exception with bad credentials" do - FakeWeb.register_uri(:get, "https://foo:X@test.campfirenow.com/rooms.json", - :status => ["401", "Unauthorized"]) + stub_connection(Tinder::Connection) do |stub| + stub.get("/rooms.json") {[ 401, {}, "Unauthorized" ]} + end + connection = Tinder::Connection.new('test', :token => 'foo') lambda { connection.get('/rooms.json') }.should raise_error(Tinder::AuthenticationFailed) end it "should lookup token when username/password provided" do - FakeWeb.register_uri(:get, "https://user:pass@test.campfirenow.com/users/me.json", - :body => fixture('users/me.json'), :content_type => "application/json") + stub_connection(Tinder::Connection) do |stub| + stub.get("/users/me.json") {[ 200, {}, fixture('users/me.json') ]} + end + connection = Tinder::Connection.new('test', :username => 'user', :password => 'pass') connection.token.should.should == "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" end it "should use basic auth for credentials" do - FakeWeb.register_uri(:get, "https://mytoken:X@test.campfirenow.com/rooms.json", - :body => fixture('rooms.json'), :content_type => "application/json") + stub_connection(Tinder::Connection) do |stub| + stub.get("/rooms.json") {[ 200, {}, fixture('rooms.json') ]} + end connection = Tinder::Connection.new('test', :token => 'mytoken') lambda { connection.get('/rooms.json') }.should_not raise_error end end - - end \ No newline at end of file