Sha256: b3f1f672ceafca3b21cafc8a705b55ca3c0c8b4da6efddda9c4c6ba96142d446

Contents?: true

Size: 1.22 KB

Versions: 14

Compression:

Stored size: 1.22 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')

describe Twitter::Client, "#authenticate?" do
  before(:each) do
    @uri = '/account/verify_credentials.json'
    @request = mas_net_http_get(:basic_auth => nil)
    @twitter = client_context
    @default_header = @twitter.send(:http_header)
    @response = mas_net_http_response(:success)
    @error_response = mas_net_http_response(404, "Resource Not Found")
    @connection = mas_net_http(@response)
    Net::HTTP.stub!(:new).and_return(@connection)
    @login = "applestillsucks"
    @password = "linuxstillrocks"
  end
  
  it "creates expected HTTP GET request" do
    @twitter.should_receive(:create_http_get_request).with(@uri).and_return(@request)
    @twitter.authenticate?(@login, @password)
  end
  
  it "should return true if HTTP response is 20X" do
    @twitter.authenticate?(@login, @password).should be(true)
  end
  
  it "should return false if HTTP response is not 20X" do
    Net::HTTP.stub!(:new).and_return(mas_net_http(@error_response))
    @twitter.authenticate?(@login, @password).should be(false)
  end
  
  after(:each) do
    nilize(@uri, @request, @twitter, @default_header, @response, @error_response, @connection, @login, @password)
  end
end

Version data entries

14 entries across 14 versions & 9 rubygems

Version Path
NewMonarch-twitter4r-0.3.2 spec/twitter/client/auth_spec.rb
craigtmackenzie-twitter4r-0.3.1 spec/twitter/client/auth_spec.rb
dambalah-twitter4r-0.3.1 spec/twitter/client/auth_spec.rb
dambalah-twitter4r-0.3.2 spec/twitter/client/auth_spec.rb
dambalah-twitter4r-0.3.3 spec/twitter/client/auth_spec.rb
dferranti-twitter4r-0.4.0.1 spec/twitter/client/auth_spec.rb
filipegiusti-twitter4r-0.3.2.1 spec/twitter/client/auth_spec.rb
joshuamiller-twitter4r-0.3.1.2 spec/twitter/client/auth_spec.rb
mbbx6spp-twitter4r-0.3.1 spec/twitter/client/auth_spec.rb
mbbx6spp-twitter4r-0.4.0 spec/twitter/client/auth_spec.rb
theill-twitter4r-0.3.2 spec/twitter/client/auth_spec.rb
twitter4r-0.3.2 spec/twitter/client/auth_spec.rb
twitter4r-0.3.1 spec/twitter/client/auth_spec.rb
twitter4r-0.3.0 spec/twitter/client/auth_spec.rb