spec/request_spec.rb in gerry-0.1.2 vs spec/request_spec.rb in gerry-0.1.3

- old
+ new

@@ -18,11 +18,11 @@ client.projects expect(stub).to have_been_requested end - it 'should request projects as user' do + it 'should request projects as user with digest auth' do username = 'gerry' password = 'whoop' body = get_fixture('projects.json') @@ -37,6 +37,26 @@ expect(stub).to have_been_requested.twice expect(projects['awesome']['description']).to eq('Awesome project') expect(projects['clean']['description']).to eq('Clean code!') end -end \ No newline at end of file + + it 'should request projects as user with basic auth' do + username = 'gerry' + password = 'whoop' + + body = get_fixture('projects.json') + + stub = stub_request(:get, "http://#{username}:#{password}@localhost/a/projects/"). + with(:headers => {'Accept'=>'application/json'}). + to_return(:status => 200, :body => body, :headers => {}) + + client = Gerry.new(MockGerry::URL, 'gerry', 'whoop') + client.set_auth_type(:basic_auth) + projects = client.projects + + expect(stub).to have_been_requested + + expect(projects['awesome']['description']).to eq('Awesome project') + expect(projects['clean']['description']).to eq('Clean code!') + end +end