Sha256: 1be332d9c55876025bdf0a8de5e69bd64e3d9d9f2efe22f6e43828dd2665d0f2

Contents?: true

Size: 878 Bytes

Versions: 3

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

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

3 entries across 3 versions & 1 rubygems

Version Path
telegram-bot-0.16.5 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.16.4 lib/telegram/bot/rspec/integration/rails.rb
telegram-bot-0.16.3 lib/telegram/bot/rspec/integration/rails.rb