Sha256: b2612cc1fa5ebd6821f520af835c4e1fde23d4995033751b56e69e5df7576a07
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
require 'spec_helper' describe Tinder::Connection do describe "authentication" do it "should raise an exception with bad credentials" do 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 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 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tinder-1.4.4 | spec/tinder/connection_spec.rb |
tinder-1.4.3 | spec/tinder/connection_spec.rb |
tinder-1.4.2 | spec/tinder/connection_spec.rb |