Sha256: 80aea8f3094095fb5e8c9b83de08093ad4c1f755aaf3e1ffcb771f1be0a3073d

Contents?: true

Size: 1.9 KB

Versions: 1

Compression:

Stored size: 1.9 KB

Contents

require 'kookaburra'

describe Kookaburra do
  let(:configuration) {
    OpenStruct.new
  }

  let(:k) { Kookaburra.new(configuration) }

  describe '#api' do
    it 'returns an instance of the configured APIDriver' do
      my_api_driver_class = double(Class)
      my_api_driver_class.should_receive(:new) \
        .with(configuration) \
        .and_return(:an_api_driver)
      configuration.stub(:api_driver_class => my_api_driver_class)
      k.api.should == :an_api_driver
    end
  end

  describe '#ui' do
    it 'returns an instance of the configured UIDriver' do
      my_ui_driver_class = double(Class)
      my_ui_driver_class.should_receive(:new) \
        .with(configuration) \
        .and_return(:a_ui_driver)
      configuration.stub(:ui_driver_class => my_ui_driver_class)
      k.ui.should == :a_ui_driver
    end
  end

  describe '#get_data' do
    it 'returns a dup of the specified MentalModel::Collection' do
      collection = double('MentalModel::Collection')
      collection.should_receive(:dup) \
        .and_return(:mental_model_collection_dup)
      configuration.stub(:mental_model => double(:foos => collection))
      k.get_data(:foos).should == :mental_model_collection_dup
    end
  end

  describe '.configuration' do
    it 'returns a Kookaburra::Configuration instance' do
      Kookaburra.configuration.should be_kind_of(Kookaburra::Configuration)
    end

    it 'always returns the same configuration' do
      x = Kookaburra.configuration
      y = Kookaburra.configuration
      x.app_host = 'http://example.com'
      y.app_host.should == 'http://example.com'
    end
  end

  describe '.configure' do
    it 'yields Kookaburra.configuration' do
      configuration = double('Kookaburra::Configuration')
      configuration.should_receive(:foo=).with(:bar)
      Kookaburra.stub(:configuration => configuration)
      Kookaburra.configure do |c|
        c.foo = :bar
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kookaburra-2.0.0 spec/kookaburra_spec.rb