Sha256: 9ae34ff7351e5671072688674d24af764532f964930415f3f432c5750f82dc50

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

module SpecHelpers
  def self.request_xml_for(service, action, filename)
    Nokogiri::XML(File.read(xml_path_for(service, action, filename)))
  end

  def self.response_xml_for(service, action, filename)
    File.read(xml_path_for(service, action, filename, false))
  end

  def self.fake_header
    OpenStruct.new(
      content: {
        "AuthenticationToken" => BingAdsRubySdk::LogMessage::FILTERED,
        "DeveloperToken" =>      BingAdsRubySdk::LogMessage::FILTERED,
        "CustomerId" =>          BingAdsRubySdk::LogMessage::FILTERED,
        "CustomerAccountId" =>   BingAdsRubySdk::LogMessage::FILTERED
    })
  end

  def self.soap_client(service, header = fake_header)
    BingAdsRubySdk::SoapClient.new(
      service_name: service,
      version: BingAdsRubySdk::DEFAULT_SDK_VERSION,
      environment: 'test',
      header: header
    )
  end

  def self.wrapper(service, action_name)
    soap_client(service).wsdl_wrapper(action_name)
  end

  def self.default_store
    ::BingAdsRubySdk::OAuth2::FsStore.new(ENV['BING_STORE_FILENAME'])
  end

  # default fixture for now is standard.xml but door is open to get more use cases
  def self.xml_path_for(service, action, filename, request = true)
    if request
      File.join(BingAdsRubySdk.root_path, 'spec', 'fixtures', service.to_s, action, "#{filename}.xml")
    else
      File.join(BingAdsRubySdk.root_path, 'spec', 'fixtures', service.to_s, action, "#{filename}_response.xml")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bing_ads_ruby_sdk-1.3.4 spec/support/spec_helpers.rb
bing_ads_ruby_sdk-1.3.3 spec/support/spec_helpers.rb
bing_ads_ruby_sdk-1.3.2 spec/support/spec_helpers.rb
bing_ads_ruby_sdk-1.3.1 spec/support/spec_helpers.rb
bing_ads_ruby_sdk-1.3.0 spec/support/spec_helpers.rb
bing_ads_ruby_sdk-1.2.0 spec/support/spec_helpers.rb
bing_ads_ruby_sdk-1.1.1 spec/support/spec_helpers.rb