Sha256: dabb99ea07dca8310a13d288784595074fc5f47ca85187d600f04ca320cb229f

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 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){ stub }
  let(:last){ stub }
  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-1.1.0 spec/lib/sham/config/parameters_spec.rb
sham-1.0.3 spec/lib/sham/config/parameters_spec.rb