Sha256: 694d6c9252a8ba1919f00791a5c0be113246f8a9c30e320c055a8bffbadaab42

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

describe MercuryParser::Client do

  after do
    MercuryParser.reset!
  end

  context "with module configuration" do
    before do
      MercuryParser.configure do |config|
        MercuryParser::Configuration::VALID_CONFIG_KEYS.each do |key|
          config.send("#{key}=", key)
        end
      end
    end

    it "inherits the module configuration" do
      MercuryParser::Configuration::VALID_CONFIG_KEYS.each do |key|
        expect(MercuryParser.send(:"#{key}")).to eq(key)
      end
    end
  end

  context "with class configuration" do
    before do
      @configuration = {
        api_key: '1234'
      }
    end

    it "overrides the module configuration after initialization" do
      MercuryParser.configure do |config|
        @configuration.each do |key, value|
          config.send("#{key}=", value)
        end
      end

      MercuryParser::Configuration::VALID_OPTIONS_KEYS.each do |key|
        expect(MercuryParser.send(:"#{key}")).to eq(@configuration[key])
      end
    end
  end

  describe "#connection" do
    it "looks like Faraday connection" do
      expect(subject.send(:connection)).to respond_to(:run_request)
    end
  end

  describe "#request" do
    before { MercuryParser.api_key = '1234' }

    it "catches Faraday connection errors" do
      skip
    end

    it "catches Mercury Parser API errors" do
      skip
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mercury_parser-0.0.1 spec/mercury_parser/client_spec.rb