зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-05 02:35:50 +03:00
v0.1.0
Этот коммит содержится в:
51
spec/telegram/bot_spec.rb
Обычный файл
51
spec/telegram/bot_spec.rb
Обычный файл
@@ -0,0 +1,51 @@
|
||||
RSpec.describe Telegram::Bot do
|
||||
it 'has a version number' do
|
||||
expect(Telegram::Bot::VERSION).not_to be nil
|
||||
end
|
||||
|
||||
describe '.wrap' do
|
||||
subject { described_class.wrap(input) }
|
||||
let(:result) { double(:result) }
|
||||
let(:token) { 'token' }
|
||||
let(:username) { 'username' }
|
||||
let(:instance) { described_class.new 'token' }
|
||||
|
||||
context 'when input is a string' do
|
||||
let(:input) { token }
|
||||
|
||||
it 'treats string as token' do
|
||||
expect(described_class).to receive(:new).with(token) { result }
|
||||
should eq result
|
||||
end
|
||||
end
|
||||
|
||||
context 'when input is a hash' do
|
||||
let(:input) { {token: token, username: username, ignore: :ignore} }
|
||||
|
||||
it 'extracts token & username' do
|
||||
expect(described_class).to receive(:new).with(token, username) { result }
|
||||
should eq result
|
||||
end
|
||||
end
|
||||
|
||||
context 'when input is an instance of described_class' do
|
||||
let!(:input) { instance }
|
||||
|
||||
it 'returns input' do
|
||||
expect(described_class).to_not receive(:new)
|
||||
should eq input
|
||||
end
|
||||
end
|
||||
|
||||
context 'when input is an array' do
|
||||
let!(:input) { ['other_token', instance, token: token, username: username] }
|
||||
let(:result_2) { double(:result_2) }
|
||||
|
||||
it 'calls wrap for every element' do
|
||||
expect(described_class).to receive(:new).with('other_token') { result }
|
||||
expect(described_class).to receive(:new).with(token, username) { result_2 }
|
||||
should eq [result, instance, result_2]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Ссылка в новой задаче
Block a user