Sha256: c1c123b846421d407076ff8b36c1f1341045ea747be0ee78cf75962a8caf23f3

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 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"
      }
      expect {
        subject.attribute("test_cookbook/test", options)
      }.not_to raise_error
  
      options = {
        :type => "boolean",
        :choice => [ true, false ],
        :default => true
      }
      expect {
        subject.attribute("test_cookbook/test", options)
      }.not_to raise_error

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

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ridley-5.1.1 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-5.1.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-5.0.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.6.1 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.6.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.5.1 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.5.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.4.3 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.4.2 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.4.1 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.4.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.3.2 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.3.1 spec/unit/ridley/chef/cookbook/metadata_spec.rb
ridley-4.3.0 spec/unit/ridley/chef/cookbook/metadata_spec.rb