1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-08-28 15:26:18 +03:00

Update rubocop, add appraisal gem

Этот коммит содержится в:
Max Melentiev
2017-11-16 22:49:04 +03:00
родитель da93abaaf7
Коммит 1a30b430df
25 изменённых файлов: 146 добавлений и 70 удалений

Просмотреть файл

@@ -27,7 +27,7 @@ end
Rails.application.initialize!
# # Controllers
%w(default other named).each do |bot_name|
%w[default other named].each do |bot_name|
controller = Class.new(Telegram::Bot::UpdatesController) do
define_method :start do |*|
respond_with :message, text: "from #{bot_name}"

Просмотреть файл

@@ -19,7 +19,7 @@ RSpec.describe Telegram::Bot::Client do
it 'encodes nested hashes to json' do
expected = input.dup
%i(c d e).each { |x| expected[x] = expected[x].to_json }
%i[c d e].each { |x| expected[x] = expected[x].to_json }
should eq expected
end
end
@@ -35,7 +35,7 @@ RSpec.describe Telegram::Bot::Client do
subject { described_class.new(*args) }
context 'when multiple args are given' do
let(:args) { %w(secret superbot) }
let(:args) { %w[secret superbot] }
its(:token) { should eq args[0] }
its(:username) { should eq args[1] }
its(:base_uri) { should include args[0] }

Просмотреть файл

@@ -45,7 +45,7 @@ RSpec.describe Telegram::Bot::ClientStub do
end
context 'when username and token are given' do
let(:args) { %w(token superbot) }
let(:args) { %w[token superbot] }
its(:token) { should eq args[0] }
its(:username) { should eq args[1] }
end

Просмотреть файл

@@ -5,7 +5,8 @@ require 'action_dispatch/testing/integration'
RSpec.describe 'Integrations helper', :telegram_bot do
include ActionDispatch::Integration::Runner
def reset_template_assertion; end
def reset_template_assertion
end
let(:app) do
app = Telegram::Bot::Middleware.new(bot, controller)
@@ -38,7 +39,7 @@ RSpec.describe 'Integrations helper', :telegram_bot do
describe '#dispatch_message' do
subject { -> { dispatch_message "/start #{args.join ' '}", options } }
let(:args) { %w(asd qwe) }
let(:args) { %w[asd qwe] }
let(:options) { {} }
it { should respond_with_message "Start: #{args.inspect}, option: " }
@@ -59,7 +60,7 @@ RSpec.describe 'Integrations helper', :telegram_bot do
it { should respond_with_message "Start: #{args.inspect}, option: " }
context 'with args' do
let(:args) { %w(asd qwe) }
let(:args) { %w[asd qwe] }
it { should respond_with_message "Start: #{args.inspect}, option: " }
end

Просмотреть файл

@@ -65,7 +65,7 @@ RSpec.describe Telegram::Bot::UpdatesController::MessageContext do
context 'when message has new command' do
let(:text) { '/action a s d' }
its(:call) { should eq [:action_result, *%w(a s d)] }
its(:call) { should eq [:action_result, 'a', 's', 'd'] }
it { should change { session[:context] }.to nil }
end
end

Просмотреть файл

@@ -9,11 +9,11 @@ RSpec.describe Telegram::Bot::UpdatesController::TypedUpdate do
context 'when `update` is a virtus model' do
subject { controller }
%w(
%w[
message
inline_query
chosen_inline_result
).each do |type|
].each do |type|
context "with #{type}" do
type_class = Telegram::Bot::Types.const_get(type.camelize)
let(:payload_type) { type }

Просмотреть файл

@@ -107,7 +107,7 @@ RSpec.describe Telegram::Bot::UpdatesController do
it { should eq [false, :unsupported_payload_type, []] }
end
%w(message channel_post).each do |type|
%w[message channel_post].each do |type|
context "when payload is edited_#{type}" do
let(:payload_type) { "edited_#{type}" }
it { should eq [false, payload_type, [payload]] }
@@ -123,11 +123,11 @@ RSpec.describe Telegram::Bot::UpdatesController do
context 'with command' do
let(:text) { "/test#{"@#{mention}" if mention} arg 1 2" }
let(:mention) {}
it { should eq [true, 'test', %w(arg 1 2)] }
it { should eq [true, 'test', %w[arg 1 2]] }
context 'with mention' do
let(:mention) { bot.username }
it { should eq [true, 'test', %w(arg 1 2)] }
it { should eq [true, 'test', %w[arg 1 2]] }
end
context 'with mention for other bot' do
@@ -143,7 +143,7 @@ RSpec.describe Telegram::Bot::UpdatesController do
end
end
custom_payload_types = %w(
custom_payload_types = %w[
message
edited_message
channel_post
@@ -151,7 +151,7 @@ RSpec.describe Telegram::Bot::UpdatesController do
inline_query
chosen_inline_result
callback_query
)
]
(described_class::PAYLOAD_TYPES - custom_payload_types).each do |type|
context "when payload is #{type}" do
let(:payload_type) { type }
@@ -163,11 +163,11 @@ RSpec.describe Telegram::Bot::UpdatesController do
context 'when `update` is a virtus model' do
subject { controller }
let(:update) { Telegram::Bot::Types::Update.new(super()) }
%w(
%w[
message
inline_query
chosen_inline_result
).each do |type|
].each do |type|
context "with #{type}" do
type_class = Telegram::Bot::Types.const_get(type.camelize)
let(:payload_type) { type }
@@ -194,7 +194,7 @@ RSpec.describe Telegram::Bot::UpdatesController do
describe '#process' do
subject { -> { controller.process(:action, *args) } }
let(:args) { [:arg1, :arg2] }
let(:args) { %i[arg1 arg2] }
let(:controller_class) do
Class.new(described_class) do
attr_reader :acted, :hooked