Sha256: 735daefcfc678f5bf51e550089659de43a8c4f93300f56504659b3c6d047e860

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require "spec_helper"

describe Primo::Config do

  describe ".instance" do
    it "should create the config file when needed" do
      Primo::Config.instance
      expect(File.exists?(Primo::Config::CONFIG_FILE)).to be_true
    end

    it "should not create the config file twice" do
      Primo::Config.instance
      created_at = File.new(Primo::Config::CONFIG_FILE).mtime
      Primo::Config.instance
      expect(File.new(Primo::Config::CONFIG_FILE).mtime).to be == created_at
    end
  end

  describe "#[]" do
    it "should return the right value" do
      Primo::Config.instance["foo"] = "bar"
      expect(Primo::Config.instance["foo"]).to be == "bar"
    end
  end

  describe "#[]=" do
    it "should save the config to file" do
      Primo::Config.instance
      created_at = File.new(Primo::Config::CONFIG_FILE).mtime
      Primo::Config.instance["foo"] = "bar"
      expect(File.new(Primo::Config::CONFIG_FILE).mtime).not_to be == created_at
    end
  end

  describe "#save" do
    it "should save the config to file" do
      Primo::Config.instance
      created_at = File.new(Primo::Config::CONFIG_FILE).mtime
      Primo::Config.instance.save
      expect(File.new(Primo::Config::CONFIG_FILE).mtime).not_to be == created_at
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
primo-0.1.0 spec/primo/config_spec.rb