Sha256: 41d14029ba288c987c9a2312d4249fd5614f3a4a91757d2f7a41e67103dc9fd6

Contents?: true

Size: 1019 Bytes

Versions: 10

Compression:

Stored size: 1019 Bytes

Contents

# Basic class method specs

require 'lib/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

10 entries across 10 versions & 1 rubygems

Version Path
maintain-0.2.17 spec/class_methods_spec.rb
maintain-0.2.16 spec/class_methods_spec.rb
maintain-0.2.15 spec/class_methods_spec.rb
maintain-0.2.14 spec/class_methods_spec.rb
maintain-0.2.13 spec/class_methods_spec.rb
maintain-0.2.12 spec/class_methods_spec.rb
maintain-0.2.11 spec/class_methods_spec.rb
maintain-0.2.10 spec/class_methods_spec.rb
maintain-0.2.9 spec/class_methods_spec.rb
maintain-0.2.8 spec/class_methods_spec.rb