Sha256: dae0ec07cc686578e2b2ab2330eb7272648d42f8f662f478478a2294eae44e35

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'
module Alf
  describe "Reader#initialize" do
    
    subject{ Reader.new(*args) }
    
    describe "with full args" do
      let(:args){[
        "suppliers", Environment.examples, {:opts => true}
      ]}
      specify {
        subject.input.should eq("suppliers")
        subject.environment.should be_a(Environment)
        subject.options.should eq(:opts => true)
      }
    end
    
    describe "with only options" do
      let(:args){[
        {:opts => true}
      ]}
      specify {
        subject.input.should be_nil
        subject.environment.should be_nil
        subject.options.should eq(:opts => true)
      }
    end

    describe "on a subclass" do
      class FooReader < Reader
        DEFAULT_OPTIONS = {:from => :subclass}
      end
      subject{ FooReader.new(*args) }
        
      describe "without option overriding" do
        let(:args){[
          {:opts => true}
        ]}
        specify {
          subject.input.should be_nil
          subject.environment.should be_nil
          subject.options.should eq(:opts => true, :from => :subclass)
        }
      end
      
      describe "with option overriding" do
        let(:args){[
          {:opts => true, :from => :overrided}
        ]}
        specify {
          subject.input.should be_nil
          subject.environment.should be_nil
          subject.options.should eq(:opts => true, :from => :overrided)
        }
      end
      
    end
    
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-core/reader/test_initialize.rb
alf-0.12.1 spec/unit/alf-core/reader/test_initialize.rb
alf-0.12.0 spec/unit/alf-core/reader/test_initialize.rb
alf-0.11.1 spec/unit/alf-core/reader/test_initialize.rb
alf-0.11.0 spec/unit/alf-core/reader/test_initialize.rb
alf-0.10.1 spec/unit/reader/test_initialize.rb
alf-0.10.0 spec/unit/reader/test_initialize.rb
alf-0.9.3 spec/unit/reader/test_initialize.rb