File: enum_definition_spec.rb

package info (click to toggle)
r10k 5.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,228 kB
  • sloc: ruby: 18,180; makefile: 10; sh: 1
file content (20 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'spec_helper'
require 'r10k/settings/enum_definition'

describe R10K::Settings::EnumDefinition do

  subject { described_class.new(:enum, :enum => %w[one two three]) }

  describe '#validate' do
    it "doesn't raise an error when given an expected value" do
      subject.assign('two')
      subject.validate
    end
    it "raises an error when given a value outside the enum" do
      subject.assign('dos')
      expect {
        subject.validate
      }.to raise_error(ArgumentError, "Setting enum should be one of #{%w[one two three].inspect}, not 'dos'")
    end
  end
end