Sha256: fef8b3c5ec92409e61e0745ab50a234c600770d937aa304941c1250244fc8e8a

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

require "pione/test-helper"

describe Pione::Global::Config do
  before do
    Global.define_external_item(:test)

    @path = Temppath.create
    @config = Global::Config.new(@path)
  end

  after do
    Global.item[:test].unregister
  end

  it "should set and get a item" do
    @config.set("test", "a")
    @config.get("test").should == "a"
  end

  it "should unset a item" do
    @config.set("test", "a")
    @config.unset("test")
    @config.get("test").should.nil
  end

  it "should save config file" do
    Global.define_external_item(:test1)
    Global.define_external_item(:test2)
    Global.define_external_item(:test3)

    # set
    @config.set("test1", "a")
    @config.set("test2", 1)
    @config.set("test3", true)

    # save
    @config.save

    # delete
    Global.item[:test1].unregister
    Global.item[:test2].unregister
    Global.item[:test3].unregister

    # test
    table = JSON.load(@path.read)
    table["test1"].should == "a"
    table["test2"].should == 1
    table["test3"].should.true
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pione-0.5.0 test/global/spec_config.rb
pione-0.5.0.alpha.2 test/global/spec_config.rb
pione-0.5.0.alpha.1 test/global/spec_config.rb
pione-0.4.2 test/global/spec_config.rb
pione-0.4.1 test/global/spec_config.rb
pione-0.4.0 test/global/spec_config.rb