Sha256: c9a130a2ee4e70c3138cd82b6230100f796dc70098a9d5358cbcc6c3a3b05242

Contents?: true

Size: 628 Bytes

Versions: 1

Compression:

Stored size: 628 Bytes

Contents

require 'spec_helper'

class Colors
  include Ruby::Enum

  define :RED, "red"
  define :GREEN, "green"
end

describe Ruby::Enum do
  it "returns an enum value" do
    Colors::RED.should eq "red"
    Colors::GREEN.should eq "green"
  end
  context "parse" do
    it "parses exact value" do
      Colors.parse("red").should == Colors::RED
    end
    it "is case-insensitive" do
      Colors.parse("ReD").should == Colors::RED
    end
    it "returns nil for a null value" do
      Colors.parse(nil).should be_nil
    end
    it "returns nil for an invalid value" do
      Colors.parse("invalid").should be_nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-enum-0.1.0 spec/ruby-enum/enum_spec.rb