Skip to content

Commit

Permalink
Omit the redundant empty header criteria to fix stubbing with HTTMult…
Browse files Browse the repository at this point in the history
…iParty
  • Loading branch information
knu committed May 26, 2023
1 parent 7f20a9a commit 5a79d85
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions spec/models/agents/telegram_agent_spec.rb
Expand Up @@ -175,7 +175,6 @@ def stub_methods
describe '#complete_chat_id' do
it 'returns a list of all recents chats, groups and channels' do
stub_request(:post, "https://api.telegram.org/botxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/getUpdates").
with(headers: {}).
to_return(status: 200, body: '{"ok":true,"result":[{"update_id":252965475,"message":{"message_id":15,"from":{"id":97201077,"is_bot":false,"first_name":"Dominik","last_name":"Sander","language_code":"en-US"},"chat":{"id":97201077,"first_name":"Dominik","last_name":"Sander","type":"private"},"date":1506774710,"text":"test"}},{"update_id":252965476,"channel_post":{"message_id":4,"chat":{"id":-1001144599139,"title":"Much channel","type":"channel"},"date":1506782283,"text":"channel"}},{"update_id":252965477,"message":{"message_id":18,"from":{"id":97201077,"is_bot":false,"first_name":"Dominik","last_name":"Sander","language_code":"en-US"},"chat":{"id":-217850512,"title":"Just a test","type":"group","all_members_are_administrators":true},"date":1506782504,"left_chat_participant":{"id":136508315,"is_bot":true,"first_name":"Huginn","username":"HuginnNotificationBot"},"left_chat_member":{"id":136508315,"is_bot":true,"first_name":"Huginn","username":"HuginnNotificationBot"}}}]}', headers: {'Content-Type' => 'application/json'})

expect(@checker.complete_chat_id).to eq([{:id=>97201077, :text=>"Dominik Sander"},
Expand All @@ -187,15 +186,13 @@ def stub_methods
describe '#validate_auth_token' do
it 'returns true if the token is valid' do
stub_request(:post, "https://api.telegram.org/botxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/getMe").
with(headers: {}).
to_return(status: 200, body: '{"ok": true}', headers: {'Content-Type' => 'application/json'})

expect(@checker.validate_auth_token).to be_truthy
end

it 'returns false if the token is invalid' do
stub_request(:post, "https://api.telegram.org/botxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/getMe").
with(headers: {}).
to_return(status: 200, body: "{}")

expect(@checker.validate_auth_token).to be_falsy
Expand Down

0 comments on commit 5a79d85

Please sign in to comment.