Sha256: 763215b353ea2fc6486d4fa90ca21cc89890e1981ea5f6b319efe0485e5d99b9

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'sham/config/parameters'

describe Sham::Config::Parameters do
  before(:all) do
    Object.send(:remove_const, :ParamTester) if defined?(ParamTester)
    class ParamTester
      attr_accessor :first, :last

      def initialize(first, last)
        self.first = first
        self.last = last
      end
    end
  end

  let(:first){ double }
  let(:last){ double }
  let(:params){ [first, last] }
  let(:subject){ described_class.new(lambda{ params }) }
  let(:config){ subject.object(ParamTester) }

  it 'passes default options' do
    ParamTester.should_receive(:new).with(*params)
    config.options.sham
  end

  it 'prioritizes passed options' do
    ParamTester.should_receive(:new).with('A', 'B')
    config.options('A', 'B').sham
  end

  it 'parses default options' do
    subject.should_receive(:parse!).with(first)
    subject.should_receive(:parse!).with(last)
    config.options.sham
  end

  it 'does not parse passed options' do
    subject.should_receive(:parse!).with(1).never
    subject.should_receive(:parse!).with(2).never
    config.options(1, 2).sham
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sham-2.0.0 spec/lib/sham/config/parameters_spec.rb
sham-1.2.0 spec/lib/sham/config/parameters_spec.rb