Sha256: f9ee44730f89339ea0718ee99a11d197e4c5bbff7cdeda4bb2a8135211264d7d

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# Basic class method specs

require 'spec_helper'
require 'maintain'

describe Maintain do
  before :each do
    class ::MaintainTest
      attr_accessor :existant_attribute
      extend Maintain
    end
    MaintainTest.maintain :state do
      state :new
      state :overdue
      state :closed
    end
  end

  it "should provide a hash of key/value stores" do
    MaintainTest.state.should == [:new, :overdue, :closed]
  end

  it "should provide a hash of key/value stores in an Integer case, too" do
    MaintainTest.maintain :state_two, :integer => true do
      state :new, 1
      state :overdue, 2
      state :closed, 3
    end
    MaintainTest.state_two.should == [[:new, 1], [:overdue, 2], [:closed, 3]]
  end

  it "should not overwrite existing class methods" do
    def MaintainTest.foo
      "foo"
    end

    MaintainTest.maintain :foo do
      state :new
      state :overdue
      state :closed
    end
    MaintainTest.foo.should == "foo"
    MaintainTest.maintain_foo.should == [:new, :overdue, :closed]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
maintain-0.2.23 spec/class_methods_spec.rb
maintain-0.2.22 spec/class_methods_spec.rb
maintain-0.2.21 spec/class_methods_spec.rb
maintain-0.2.20 spec/class_methods_spec.rb
maintain-0.2.19 spec/class_methods_spec.rb
maintain-0.2.18 spec/class_methods_spec.rb