зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-05 02:35:50 +03:00
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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7bcb0caded
Коммит
57b17f068c
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::CallbackQueryContext do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
let(:controller_class) do
|
||||
@@ -6,7 +8,8 @@ RSpec.describe Telegram::Bot::UpdatesController::CallbackQueryContext do
|
||||
include described_class
|
||||
|
||||
attr_accessor :filter_done
|
||||
before_action only: :ctx2_callback_query do
|
||||
|
||||
before_action only: :ctx_2_callback_query do
|
||||
self.filter_done = true
|
||||
end
|
||||
|
||||
@@ -14,12 +17,12 @@ RSpec.describe Telegram::Bot::UpdatesController::CallbackQueryContext do
|
||||
[:no_context, data]
|
||||
end
|
||||
|
||||
def ctx1_callback_query(data)
|
||||
[:ctx1, data]
|
||||
def ctx_1_callback_query(data)
|
||||
[:ctx_1, data]
|
||||
end
|
||||
|
||||
def ctx2_callback_query(data)
|
||||
[:ctx2, data]
|
||||
def ctx_2_callback_query(data)
|
||||
[:ctx_2, data]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -40,19 +43,19 @@ RSpec.describe Telegram::Bot::UpdatesController::CallbackQueryContext do
|
||||
let(:data) { "#{ctx}:#{text}" }
|
||||
|
||||
context 'and valid' do
|
||||
let(:ctx) { 'ctx1' }
|
||||
its(:call) { should eq [:ctx1, text] }
|
||||
let(:ctx) { 'ctx_1' }
|
||||
its(:call) { should eq [:ctx_1, text] }
|
||||
it { should_not change(controller, :filter_done) }
|
||||
|
||||
context 'and context has callback' do
|
||||
let(:ctx) { 'ctx2' }
|
||||
its(:call) { should eq [:ctx2, text] }
|
||||
let(:ctx) { 'ctx_2' }
|
||||
its(:call) { should eq [:ctx_2, text] }
|
||||
it { should change(controller, :filter_done) }
|
||||
end
|
||||
|
||||
context 'and data has multiple colons' do
|
||||
let(:text) { super().tr(' ', ':') }
|
||||
its(:call) { should eq [:ctx1, text] }
|
||||
its(:call) { should eq [:ctx_1, text] }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::Commands do
|
||||
describe '#action_for_command' do
|
||||
subject { ->(*args) { object.action_for_command(*args) } }
|
||||
@@ -88,11 +90,11 @@ RSpec.describe Telegram::Bot::UpdatesController::Commands do
|
||||
context 'with command' do
|
||||
let(:text) { "/test#{"@#{mention}" if mention} arg 1 2" }
|
||||
let(:mention) {}
|
||||
it { should eq [['test!', type: :command, command: 'test'], %w[arg 1 2]] }
|
||||
it { should eq [['test!', {type: :command, command: 'test'}], %w[arg 1 2]] }
|
||||
|
||||
context 'with mention' do
|
||||
let(:mention) { bot.username }
|
||||
it { should eq [['test!', type: :command, command: 'test'], %w[arg 1 2]] }
|
||||
it { should eq [['test!', {type: :command, command: 'test'}], %w[arg 1 2]] }
|
||||
end
|
||||
|
||||
context 'with mention for other bot' do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::Instrumentation do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::MessageContext do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
let(:controller_class) do
|
||||
@@ -6,11 +8,13 @@ RSpec.describe Telegram::Bot::UpdatesController::MessageContext do
|
||||
include described_class
|
||||
|
||||
attr_accessor :filter_done
|
||||
|
||||
before_action only: :context_with_filter do
|
||||
self.filter_done = true
|
||||
end
|
||||
|
||||
attr_reader :callbacks_runs
|
||||
|
||||
before_action { @callbacks_runs = (@callbacks_runs || 0) + 1 }
|
||||
|
||||
def message(*args)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
let(:params) { {arg: 1, 'other_arg' => 2} }
|
||||
@@ -38,7 +40,7 @@ RSpec.describe Telegram::Bot::UpdatesController do
|
||||
end
|
||||
|
||||
context 'when update is not set' do
|
||||
let(:controller_args) { [bot, chat: deep_stringify(chat)] }
|
||||
let(:controller_args) { [bot, {chat: deep_stringify(chat)}] }
|
||||
it 'sets chat_id' do
|
||||
expect(bot).to receive("send_#{respond_type}").
|
||||
with(params.merge(chat_id: chat[:id])) { result }
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::Rescue do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::Session do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
let(:controller_class) do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'action_dispatch'
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::Testing do
|
||||
@@ -43,7 +45,7 @@ RSpec.describe Telegram::Bot::UpdatesController::Testing do
|
||||
|
||||
context 'when webhook_request is given' do
|
||||
it 'passes it to controller' do
|
||||
webhook_request = ::ActionDispatch::Request.new({})
|
||||
webhook_request = ActionDispatch::Request.new({})
|
||||
dispatch(update, bot, webhook_request)
|
||||
expect(controller.webhook_request).to eq webhook_request
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::Translation do
|
||||
def self.stub_translations(translations)
|
||||
around do |ex|
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::TypedUpdate do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
let(:controller_class) do
|
||||
|
||||
Ссылка в новой задаче
Block a user