Sha256: f4b918ae11d345b7352d1c345e115b6aac9fc1da718bbdb4e4b5bb82e6478ea9

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe Praxis::Application do
  describe 'configuration' do
    subject(:app) do
      app = Class.new(Praxis::Application).instance

      config = Object.new
      def config.define(key=nil, type=Attributor::Struct, **opts, &block)
        return [key,type,opts,block]
      end
      def config.get
        return 'gotconfig'
      end
      def config.set(config)
        return config
      end
      app.instance_variable_set(:@config, config)
      app
    end

    describe '#config' do
      let(:myblock){ lambda {} }
      it 'passes the block to config (and sets the right defaults)' do
        ret = app.config(&myblock)
        expect(ret).to eq([nil,Attributor::Struct,{},myblock])
      end

      it 'passes the params and block to config' do
        ret = app.config(:key, Attributor::Hash, {option: :one}, &myblock)
        expect(ret).to eq([:key, Attributor::Hash, {option: :one}, myblock])
      end

      it 'gets config with no block given' do
        expect(app.config).to eq('gotconfig')
      end
    end

    describe '#config=' do
      it 'sets config' do
        ret = (app.config = 'someconfig')
        expect(ret).to eq 'someconfig'
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
praxis-0.14.0 spec/praxis/application_spec.rb
praxis-0.13.0 spec/praxis/application_spec.rb
praxis-0.11.2 spec/praxis/application_spec.rb
praxis-0.11.1 spec/praxis/application_spec.rb
praxis-0.11 spec/praxis/application_spec.rb
praxis-0.11pre spec/praxis/application_spec.rb
praxis-0.10.1 spec/praxis/application_spec.rb
praxis-0.10.0 spec/praxis/application_spec.rb
praxis-0.9 spec/praxis/application_spec.rb