Sha256: 0cb6de2d66b0477f2ca9841c3c2c2fd121b252db6f2ba9ae7c4f0370a02739eb

Contents?: true

Size: 360 Bytes

Versions: 5

Compression:

Stored size: 360 Bytes

Contents

# frozen_string_literal: true

require 'uri'

RSpec::Matchers.define :have_query_param do |key|
  match do |url|
    query_params_from(url)[key].present?
  end

  def query_params_from(url)
    Hash[query_for(url).split('&').map { |x| x.split('=', 2) }]
  end

  def uri_for(url)
    URI.parse(url)
  end

  def query_for(url)
    uri_for(url).query
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
saml-kit-1.0.14 lib/saml/kit/rspec/have_query_param.rb
saml-kit-1.0.13 lib/saml/kit/rspec/have_query_param.rb
saml-kit-1.0.12 lib/saml/kit/rspec/have_query_param.rb
saml-kit-1.0.11 lib/saml/kit/rspec/have_query_param.rb
saml-kit-1.0.10 lib/saml/kit/rspec/have_query_param.rb