1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-08-28 15:26:18 +03:00
Files
telegram-bot/spec/telegram/bot/middleware_spec.rb
Max Melentiev 57b17f068c Update rubopcop (#227)
* Update rubopcop [WIP]

* Further rubocop fixes

* Fix rubocop-rails cops

* Fix spec

* Disable rubocop suggestions

* Run rubocop in github actions rather than in codeclimate
2023-12-30 15:20:27 +00:00

37 строки
1.0 KiB
Ruby

# frozen_string_literal: true
require 'rack/mock'
RSpec.describe Telegram::Bot::Middleware do
let(:instance) { described_class.new bot, controller }
let(:bot) { double(:bot) }
let(:controller) { double(:controller, dispatch: :dispatch_result) }
describe '#call' do
subject { instance.call(env) }
let(:update) { {'message' => {'id' => 1}} }
let(:env) do
Rack::MockRequest.env_for('/',
method: :post,
input: JSON.dump(update),
'CONTENT_TYPE' => 'application/json',
)
end
require 'action_pack/version'
if ActionPack::VERSION::MAJOR < 5
# Before Rails 5, params are parsed in middleware.
# In Rails 5, they are parsed in Request#request_parameters.
let(:instance) { ActionDispatch::ParamsParser.new(super()) }
end
it 'calls dispatch on controller' do
expect(controller).to receive(:dispatch).
with(bot, update, instance_of(ActionDispatch::Request))
subject
end
it { should eq [200, {}, ['']] }
end
end