Sha256: f23d5845b33998677ac328c007b8cc35ced749631d9487cca7236b48874725d6

Contents?: true

Size: 1.01 KB

Versions: 19

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Riveter::Enumerated do
  subject { TestEnum }

  describe "#human" do
    it {
      subject.human.should be_present
    }
  end

  describe "#names" do
    it { subject.names.should eq(%i{Member1 Member2}) }
  end

  describe "#values" do
    it { subject.values.should eq([1, 2]) }
  end

  describe "#name_for" do
    it { subject.name_for(1).should be_present }
  end

  describe "#human_name_for" do
    it { subject.name_for(1).should be_present }
    it { subject.name_for(1).should eq(:Member1) }
  end

  describe "#value_for" do
    it { subject.value_for('Member1').should eq(1) }
    it { subject.value_for(:Member1).should eq(1) }
  end

  describe "#collection" do
    it { subject.collection.should be_present }
    it { subject.collection.length.should eq(2) }
  end

  describe "::All" do
    it { subject::All.should be_present }
    it { subject::All.length.should eq(2) }
  end

  # TODO: scenario for a member value of nil
  # TODO: scenario for a member value of a Class

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
riveter-0.8.3 spec/riveter/enumerated_spec.rb
riveter-0.8.2 spec/riveter/enumerated_spec.rb
riveter-0.8.1 spec/riveter/enumerated_spec.rb
riveter-0.8.0 spec/riveter/enumerated_spec.rb
riveter-0.7.0 spec/riveter/enumerated_spec.rb
riveter-0.6.0 spec/riveter/enumerated_spec.rb
riveter-0.3.0 spec/riveter/enumerated_spec.rb
riveter-0.2.1 spec/riveter/enumerated_spec.rb
riveter-0.2.0 spec/riveter/enumerated_spec.rb
riveter-0.1.1 spec/riveter/enumerated_spec.rb
riveter-0.0.15 spec/riveter/enumerated_spec.rb
riveter-0.0.14 spec/riveter/enumerated_spec.rb
riveter-0.0.13 spec/riveter/enumerated_spec.rb
riveter-0.0.12 spec/riveter/enumerated_spec.rb
riveter-0.0.11 spec/riveter/enumerated_spec.rb
riveter-0.0.10 spec/riveter/enumerated_spec.rb
riveter-0.0.9 spec/riveter/enumerated_spec.rb
riveter-0.0.8 spec/riveter/enumerated_spec.rb
riveter-0.0.7 spec/riveter/enumerated_spec.rb