Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
Refactor[issuer.find]: Rename to find_with_token
Browse files Browse the repository at this point in the history
  • Loading branch information
benoror committed Mar 25, 2017
1 parent c26bb24 commit 4615991
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/ditto/issuer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def save
client.refresh_token = key
end

def self.find(id, token)
def self.find_with_token(id, token)
client = Ditto::Client.new
attrs = client.get("SearchEmisorById/#{id}?Token=#{token}")
new(attrs)
Expand Down
8 changes: 4 additions & 4 deletions spec/ditto/issuer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@

describe '#find' do
it 'fails to find an issuer with wrong token', :vcr do
expect { Ditto::Issuer.find('123', 'meep') }.to raise_error(Faraday::ClientError)
expect { Ditto::Issuer.find_with_token('123', 'meep') }.to raise_error(Faraday::ClientError)
end

it 'fails to find an unknown issuer', :vcr do
issuer1 = Ditto::Issuer.create(attributes)
expect { Ditto::Issuer.find('123', issuer1.token) }.to raise_error(Faraday::ClientError)
expect { Ditto::Issuer.find_with_token('123', issuer1.token) }.to raise_error(Faraday::ClientError)
end

it 'succeed to find same issuer', :vcr do
issuer1 = Ditto::Issuer.create(attributes)
issuer2 = Ditto::Issuer.find(issuer1.id, issuer1.token)
issuer2 = Ditto::Issuer.find_with_token(issuer1.id, issuer1.token)
expect(issuer2.id).to eq(issuer1.id)
end

it 'succeed to find different issuer', :vcr do
issuer1 = Ditto::Issuer.create(attributes)
issuer2 = Ditto::Issuer.create(attributes)
issuer3 = Ditto::Issuer.find(issuer1.id, issuer2.token)
issuer3 = Ditto::Issuer.find_with_token(issuer1.id, issuer2.token)
expect(issuer3.id).to eq(issuer1.id)
expect(issuer3.id).to_not eq(issuer2.id)
end
Expand Down

0 comments on commit 4615991

Please sign in to comment.