Sha256: 10987b59186d4a8409b3c33249a533d72f81fd0fe69f5798b562842fda017d24

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

# Specs for assigning states

require 'spec_helper'
require '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

4 entries across 4 versions & 1 rubygems

Version Path
maintain-0.2.21 spec/setting_state_spec.rb
maintain-0.2.20 spec/setting_state_spec.rb
maintain-0.2.19 spec/setting_state_spec.rb
maintain-0.2.18 spec/setting_state_spec.rb