Sha256: 5285fc992f0957be9c05f7e4d01925964bb872ea4e4d0982ac90513192d87e04

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

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://username:password@test.com/api/petitions/#{petition_id}/signatures/lookup?email=#{email_address}")
        .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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
agra_api-0.3.3 spec/signature_spec.rb
agra_api-0.3.2 spec/signature_spec.rb
agra_api-0.3.1 spec/signature_spec.rb
agra_api-0.3.0 spec/signature_spec.rb
agra_api-0.2.1 spec/signature_spec.rb
agra_api-0.2.0 spec/signature_spec.rb