Sha256: a0f143e9beee3ddca5e0362ab538b3dd63903b97dc876f64a5c5e6789442dac7

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe ReadabilityParser::Client do

  after do
    ReadabilityParser.reset!
  end

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

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

  context "with class configuration" do
    before do
      @configuration = {
        api_token: '1234',
        format: :sriracha
      }
    end

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

      ReadabilityParser::Configuration::VALID_OPTIONS_KEYS.each do |key|
        expect(ReadabilityParser.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 { ReadabilityParser.api_token = '1234' }

    it "catches Faraday connection errors" do
      pending
    end

    it "catches Readability Parser API errors" do
      pending
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
readability_parser-0.0.4 spec/readability_parser/client_spec.rb