Sha256: a9f7a2315bf92b98b500732a548cd9ab737f61d4671b1139bb26bd410191c3b0

Contents?: true

Size: 1.45 KB

Versions: 19

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Sinclair::Config do
  describe 'yard' do
    describe '#to_hash' do
      subject(:config) { config_class.new }

      let(:config_class) { LoginConfig }

      it 'returns all configs hash' do
        expect(config.to_hash)
          .to eq('password' => nil, 'username' => 'bob')
      end

      it 'returns all configs hash on as_json calls' do
        expect(config.as_json)
          .to eq('password' => nil, 'username' => 'bob')
      end

      it 'returns all configs json on to_json calls' do
        expect(config.to_json)
          .to eq('{"password":null,"username":"bob"}')
      end
    end

    describe '#options' do
      subject(:config) { configurable.config }

      let(:configurable) { LoginConfigurable }

      before do
        LoginConfigurable.configure do |conf|
          conf.username :some_username
          conf.password :some_password
        end
      end

      it 'returns options with correct values' do
        expect(config.as_options.username).to eq(:some_username)
        expect(config.as_options.password).to eq(:some_password)
      end

      context 'when merging with given attributes' do
        subject(:options) { config.as_options(password: :correct_password) }

        it 'returns options with custom values' do
          expect(options.username).to eq(:some_username)
          expect(options.password).to eq(:correct_password)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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