Sha256: cf54040a4fbb14a75ed856dc89f2ec175f5382071143f735b7bb905d2b498e57

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Instapaper::Client do

  before do
    @options = { :adapter => :em_synchrony, :user_agent => 'Instapaper::Client spec' }
    @keys = Instapaper::Configuration::VALID_OPTIONS_KEYS
  end

  describe '.new' do
    before(:each) do
      @keys.each do |key|
        Instapaper.send("#{key}=", key)
      end
    end

    after do
      Instapaper.reset
    end

    context 'with module configuration' do
      it "should inherit module configuration" do
        api = Instapaper::Client.new
        @keys.each do |key|
          api.send(key).should eq(key)
        end
      end
    end

    context 'with class configuration' do
      context "during initialization" do
        it "should override module configuration" do
          api = Instapaper::Client.new(@options)
          @keys.each do |key|
            h = @options.has_key?(key) ? @options : Instapaper.options
            api.send(key).should eq(h[key])
          end
        end
      end

      context "after initialization" do
        it "should override module configuration after initialization" do
          api = Instapaper::Client.new
          @options.each do |key, value|
            api.send("#{key}=", value)
          end
          @keys.each do |key|
            h = @options.has_key?(key) ? @options : Instapaper.options
            api.send(key).should eq(h[key])
          end
        end
      end
    end
  end

  describe '.endpoint_with_prefix' do
    before(:each) do
      @client = Instapaper::Client.new
    end

    it 'should return the ' do
      @client.endpoint_with_prefix.should == Instapaper.endpoint + Instapaper.path_prefix
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
instapaper-0.3.0 spec/instapaper/client_spec.rb
instapaper-0.2.1 spec/instapaper/client_spec.rb
instapaper-0.2.0 spec/instapaper/client_spec.rb