diff --git a/CHANGELOG.md b/CHANGELOG.md index 52ac692..ce712c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ - `build_update(type, data)` is dropped in favor of `deep_stringify(type => data)`. - Provide support for integration testing of bots in poller mode and non-Rails apps. __Breaking changes__: - - `telegram/bot/rspec/integration` is moved to `telegram/bot/rspec/integration/rails`. + - Requiring `telegram/bot/rspec/integration` is deprecated in favor of + `telegram/bot/rspec/integration/rails`. - `:telegram_bot` rspec tag is replaced with `telegram_bot: :rails`. # 0.13.1 diff --git a/lib/telegram/bot/rspec/integration.rb b/lib/telegram/bot/rspec/integration.rb new file mode 100644 index 0000000..e28ca80 --- /dev/null +++ b/lib/telegram/bot/rspec/integration.rb @@ -0,0 +1,10 @@ +require 'telegram/bot' +Telegram::Bot.deprecation_0_15.warn( + "`require 'telegram/bot/rspec/integration'` is deprecated in favor of " \ + "`require 'telegram/bot/rspec/integration/rails'`" +) +require 'telegram/bot/rspec/integration/rails' + +Telegram::Bot::RSpec.with_include_context do |config| + config.include_context 'telegram/bot/integration/rails', telegram_bot: true +end diff --git a/lib/telegram/bot/rspec/integration/rails.rb b/lib/telegram/bot/rspec/integration/rails.rb index aa7502e..1e43e09 100644 --- a/lib/telegram/bot/rspec/integration/rails.rb +++ b/lib/telegram/bot/rspec/integration/rails.rb @@ -24,6 +24,5 @@ RSpec.shared_context 'telegram/bot/integration/rails', type: :request do end Telegram::Bot::RSpec.with_include_context do |config| - config.include_context 'telegram/bot/integration/rails', :telegram_bot config.include_context 'telegram/bot/integration/rails', telegram_bot: :rails end diff --git a/spec/integration/requests/default_bot_spec.rb b/spec/integration/requests/default_bot_spec.rb index 3791341..81a442b 100644 --- a/spec/integration/requests/default_bot_spec.rb +++ b/spec/integration/requests/default_bot_spec.rb @@ -1,6 +1,6 @@ require 'integration_helper' -RSpec.describe DefaultBotController, :telegram_bot, type: :request do +RSpec.describe DefaultBotController, telegram_bot: :rails do describe '#start' do subject { -> { dispatch_command :start } } it { should respond_with_message 'from default' } diff --git a/spec/integration/requests/named_bot_spec.rb b/spec/integration/requests/named_bot_spec.rb index 11e2eb2..cccfbd4 100644 --- a/spec/integration/requests/named_bot_spec.rb +++ b/spec/integration/requests/named_bot_spec.rb @@ -1,6 +1,6 @@ require 'integration_helper' -RSpec.describe NamedBotController, :telegram_bot, type: :request do +RSpec.describe NamedBotController, telegram_bot: :rails do let(:bot) { Telegram.bots[:named] } describe '#start' do subject { -> { dispatch_command :start } } diff --git a/spec/integration/requests/other_bot_spec.rb b/spec/integration/requests/other_bot_spec.rb index ddcdb90..8ccb783 100644 --- a/spec/integration/requests/other_bot_spec.rb +++ b/spec/integration/requests/other_bot_spec.rb @@ -1,6 +1,6 @@ require 'integration_helper' -RSpec.describe OtherBotController, :telegram_bot, type: :request do +RSpec.describe OtherBotController, telegram_bot: :rails do let(:bot) { Telegram.bots[:other] } describe '#start' do subject { -> { dispatch_command :start } } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 54ce8e2..1be5648 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -32,6 +32,14 @@ RSpec.configure do |config| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end + # This config option will be enabled by default on RSpec 4, + # but for reasons of backwards compatibility, you have to + # set it on RSpec 3. + # + # It causes the host group and examples to inherit metadata + # from the shared context. + config.shared_context_metadata_behavior = :apply_to_host_groups + config.mock_with :rspec do |mocks| # Prevents you from mocking or stubbing a method that does not exist on # a real object. This is generally recommended, and will default to