Sha256: c5454063fe187382707a461a3967c4eb1fc06b2f6419cf935fc2d7ea352afb39

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

# Specs for assigning states

require 'lib/maintain'

describe Maintain do
  before :each do
    class ::MaintainTest
      attr_accessor :existant_attribute
      extend Maintain
    end
  end

  describe "setting" do
    describe "string states" do
      before :each do
        MaintainTest.maintain :state do
          state :new
          state :overdue
          state :closed
        end
        @maintainer = MaintainTest.new
      end

      it "should, you know, work" do
        @maintainer.state = :new
        @maintainer.state.should == :new
        @maintainer.state = 'new'
        @maintainer.state.should == :new
        @maintainer.state = 0
        @maintainer.state.should == :new
        @maintainer.state.name.should == "new"
        @maintainer.state = 'nada'
        @maintainer.state.should be_nil
      end
    end

    describe "integer states" do
      before :each do
        MaintainTest.maintain :state do
          state :new, 1
          state :overdue, 2
          state :closed, 3
        end
        @maintainer = MaintainTest.new
      end

      it "should, you know, work" do
        @maintainer.state = 1
        @maintainer.state.should == :new
        @maintainer.state = 'new'
        @maintainer.state.should == :new
        @maintainer.state = :new
        @maintainer.state.should == :new
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
maintain-0.2.17 spec/setting_state_spec.rb
maintain-0.2.16 spec/setting_state_spec.rb
maintain-0.2.15 spec/setting_state_spec.rb
maintain-0.2.14 spec/setting_state_spec.rb
maintain-0.2.13 spec/setting_state_spec.rb
maintain-0.2.12 spec/setting_state_spec.rb
maintain-0.2.11 spec/setting_state_spec.rb
maintain-0.2.10 spec/setting_state_spec.rb
maintain-0.2.9 spec/setting_state_spec.rb
maintain-0.2.8 spec/setting_state_spec.rb
maintain-0.2.6 spec/setting_state_spec.rb
maintain-0.2.5 spec/setting_state_spec.rb
maintain-0.2.4 spec/setting_state_spec.rb
maintain-0.2.2 spec/setting_state_spec.rb
maintain-0.2.1 spec/setting_state_spec.rb
maintain-0.1.9 spec/setting_state_spec.rb
maintain-0.1.8 spec/setting_state_spec.rb
maintain-0.1.7 spec/setting_state_spec.rb