Sha256: d25cea2f264bdcd6b01c1fe3d38f04ab6a097b55b884d7f0b144393653ff7dc8

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Yardstick::Config, '.coerce' do
  let(:hash) { { 'rules' => { 'foo' => 'bar' } } }

  context 'when without block' do
    subject { described_class.coerce(hash) }

    it { should be_instance_of(described_class) }

    it 'coerces hash' do
      rules = subject.instance_variable_get(:@rules)
      expect(rules).to eql(foo: 'bar')
    end
  end

  context 'when block provided' do
    subject do
      described_class.coerce(hash) { |config| config.path = new_path }
    end

    let(:new_path) { 'custom' }

    it { should be_instance_of(described_class) }

    it 'executes block as config' do
      expect(subject.path).to eql(new_path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yardstick-0.9.7 spec/unit/yardstick/config/class_methods/coerce_spec.rb