Sha256: 1a34604865e7d2570e846df181395f3330c7dc0fb6b02ab5a9f097c101762e8c

Contents?: true

Size: 1.81 KB

Versions: 19

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Sinclair::Configurable do
  describe 'README' do
    describe 'Configured with' do
      before do
        MyConfigurable.configure(port: 5555) do |config|
          config.host 'interstella.art'
        end
      end

      after do
        MyConfigurable.reset_config
      end

      it 'sets configuration host' do
        expect(MyConfigurable.config.host)
          .to eq('interstella.art')
      end

      it 'sets configuration port' do
        expect(MyConfigurable.config.port)
          .to eq(5555)
      end

      it 'enables options to be returned' do
        expect(MyConfigurable.as_options.host)
          .to eq('interstella.art')
      end

      it 'enables custom options to be returned' do
        expect(MyConfigurable.as_options(host: 'other').host)
          .to eq('other')
      end

      context 'when #reset_config is called' do
        before do
          MyConfigurable.reset_config
        end

        it 'resets configuration host' do
          expect(MyConfigurable.config.host)
            .to be_nil
        end

        it 'resets configuration port' do
          expect(MyConfigurable.config.port).to eq(80)
        end
      end
    end

    describe 'Configured by' do
      before do
        Client.configure do
          host 'interstella.com'
        end
      end

      after do
        Client.reset_config
      end

      it 'sets host' do
        expect(Client.config.url)
          .to eq('http://interstella.com')
      end

      context 'when setting the port' do
        before do
          Client.configure do |config|
            config.port 8080
          end
        end

        it 'sets host and port' do
          expect(Client.config.url)
            .to eq('http://interstella.com:8080')
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
sinclair-2.1.1 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-2.1.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-2.0.1 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-2.0.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.16.3 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.16.2 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.16.1 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.16.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.15.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.14.2 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.14.1 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.14.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.13.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.12.1 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.12.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.11.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.10.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.9.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.8.0 spec/integration/readme/sinclair/configurable_spec.rb