Sha256: 16726179ec6deebdc6b350a578b6604e378fb60c988b67d4f96ae90cb16b8eca

Contents?: true

Size: 1.15 KB

Versions: 12

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe Ridley::Chef::Cookbook::Metadata do

  let(:metadata) do
    described_class.new
  end

  before(:each) do
     subject { metadata }
  end

  describe "#validate_choice_array" do
    it "should limit the types allowed in the choice array." do
      options = {
        :type => "string",
        :choice => [ "test1", "test2" ],
        :default => "test1"
      }
      lambda {
        subject.attribute("test_cookbook/test", options)
      }.should_not raise_error
  
      options = {
        :type => "boolean",
        :choice => [ true, false ],
        :default => true
      }
      lambda {
        subject.attribute("test_cookbook/test", options)
      }.should_not raise_error

      options = {
        :type => "numeric",
        :choice => [ 1337, 420 ],
        :default => 1337
      }
      lambda {
        subject.attribute("test_cookbook/test", options)
      }.should_not raise_error

      options = {
        :type => "numeric",
        :choice => [ true, "false" ],
        :default => false
      }
      lambda {
        subject.attribute("test_cookbook/test", options)
      }.should raise_error
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ridley-4.2.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.1.2 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.1.1 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.1.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.0.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-3.1.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-3.0.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-3.0.0.rc1 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-2.5.1 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-2.5.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-2.4.4 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-2.4.3 spec/unit/ridley/chef/cookbook/metadata_spec.rb