Sha256: 200ac1f3582868ab746d5fc52b342150875152d6eab44b1928629784c10b3d63

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'
module Alf
  module Operator::NonRelational
    describe Defaults do
      
      let(:operator_class){ Defaults }
      it_should_behave_like("An operator class")
        
      subject{ operator.to_a }
  
      describe "when used without --strict" do
        
        let(:input) {[
          {:a => nil, :b => "b"},
        ]}
    
        let(:expected) {[
          {:a => 1, :b => "b", :c => "blue"},
        ]}
    
        describe "When factored with Lispy" do 
          let(:operator){ Lispy.defaults(input, :a => 1, :c => "blue") }
          it{ should == expected }
        end
    
        describe "When factored from commandline args" do
          let(:operator){ Defaults.run(%w{-- a 1 c 'blue'}) }
          before{ operator.pipe(input) }
          it{ should == expected }
        end
  
      end
        
      describe "when used with --strict" do
        
        let(:input) {[
          {:a => 3,   :b => "b", :c => "blue"},
          {:a => nil, :b => "b", :c => "blue"},
        ]}
    
        let(:expected) {[
          {:a => 3, :b => "b"},
          {:a => 1, :b => "b"},
        ]}
    
        describe "When factored with Lispy" do 
          let(:operator){ Lispy.defaults(input, {:a => 1, :b => "b"}, true) }
          it{ should == expected }
        end
    
      end
        
    end 
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-0.9.3 spec/unit/operator/non_relational/test_defaults.rb
alf-0.9.2 spec/unit/operator/non_relational/test_defaults.rb
alf-0.9.1 spec/unit/operator/non_relational/test_defaults.rb
alf-0.9.0 spec/operator/non_relational/defaults_spec.rb