require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe AgraApi::Signature do let(:petition_id) { 999 } let(:email_address) { 'pedro@test.com' } subject { AgraApi.new(host: 'test.com', username: 'username', password: 'password').signature(petition_id) } describe 'configuration' do it 'should propagate the host' do expect(subject.client.connection.configuration.host).to eq('test.com') end end describe '#find_by_email' do it 'should perform lookup on agra' do stub_request(:get, "https://test.com/api/petitions/#{petition_id}/signatures/lookup?email=#{email_address}") .with(basic_auth: ['username', 'password']) .to_return(:body => {id: 1000, email: email_address}.to_json, :status => 200, :headers => { content_type: "application/json; charset=utf-8"}) signature = subject.find_by_email(email_address) expect(signature).not_to be_nil expect(signature.id).to eq 1000 expect(signature.email).to eq email_address end end end