Sha256: 7fc7ca1dec9c5b6d3514c03805a5bb02045d2cfb3b1052507213b9a1042bd370

Contents?: true

Size: 1.53 KB

Versions: 14

Compression:

Stored size: 1.53 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

      context 'when #rest_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

14 entries across 14 versions & 1 rubygems

Version Path
sinclair-1.7.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.6.7 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.6.6 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.6.5 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.6.4 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.6.3 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.6.2 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.6.1 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.6.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.5.2 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.5.1 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.5.0 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.4.2 spec/integration/readme/sinclair/configurable_spec.rb
sinclair-1.4.1 spec/integration/readme/sinclair/configurable_spec.rb