Sha256: e30bb29badb5f732f94b8705d15dae25c502acbaa70f539cddf913fc1b271b61

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 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 "#all" do
    it { subject.all.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

5 entries across 5 versions & 1 rubygems

Version Path
riveter-0.0.6 spec/riveter/enumerated_spec.rb
riveter-0.0.5 spec/riveter/enumerated_spec.rb
riveter-0.0.4 spec/riveter/enumerated_spec.rb
riveter-0.0.3 spec/riveter/enumerated_spec.rb
riveter-0.0.1 spec/riveter/enumerated_spec.rb