Sha256: 86f27d98b04bab7fc48979c19a3c5c9621003964a99f20cb42567614541aa275

Contents?: true

Size: 847 Bytes

Versions: 14

Compression:

Stored size: 847 Bytes

Contents

require 'telegram/bot/rspec/integration/shared'

RSpec.shared_context 'telegram/bot/integration/rails', type: :request do
  include_context 'telegram/bot/integration/shared'

  let(:controller_path) do
    route_name = Telegram::Bot::RoutesHelper.route_name_for_bot(bot)
    Rails.application.routes.url_helpers.public_send("#{route_name}_path")
  end
  let(:request_headers) do
    {
      'Accept' => 'application/json',
      'Content-Type' => 'application/json',
    }
  end

  def dispatch(update)
    if ActionPack::VERSION::MAJOR >= 5
      post(controller_path, params: update.to_json, headers: request_headers)
    else
      post(controller_path, update.to_json, request_headers)
    end
  end
end

Telegram::Bot::RSpec.with_include_context do |config|
  config.include_context 'telegram/bot/integration/rails', telegram_bot: :rails
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
telegram-bot-0.16.1 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.16.0 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.15.7 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.15.6 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.15.4 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.15.3 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.15.2 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.15.1 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.15.0 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.14.4 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.14.3 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.14.2 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.14.1 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.14.0 lib/telegram/bot/rspec/integration/rails.rb