Sha256: 09271e31656c901fdda43b343e717a695e17eea29465c9ea2e4cb578edd95db3

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

require 'state_mate/adapters/defaults'

describe "StateMate::Adapters::Defaults.read_defaults" do
  include_context "defaults"
  include_context "#{ DOMAIN } empty"

  let(:key) {
    'x'
  }

  it "returns an empty hash when the domain is empty" do
    expect( defaults.read_defaults DOMAIN ).to eq({})
  end

  context "string value" do

    let(:string) {
      'en_US@currency=USD'
    }

    before(:each) {
      `defaults write #{ DOMAIN } #{ key } -string '#{ string }'`
    }

    it "reads the domain with a string in it" do
      expect( defaults.read_defaults DOMAIN ).to eq({key => string})
    end

    it "still reads the current host domain as empty" do
      expect( defaults.read_defaults DOMAIN, true ).to eq({})
    end

  end

  context "string value in current host" do

    let(:string) {
      'en_US@currency=USD'
    }

    before(:each) {
      `defaults -currentHost write #{ DOMAIN } #{ key } -string '#{ string }'`
    }

    it "reads the domain with a string in it" do
      expect( defaults.read_defaults DOMAIN, true ).to eq({key => string})
    end

    it "still reads the current host domain as empty" do
      expect( defaults.read_defaults DOMAIN, false ).to eq({})
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
state_mate-0.0.3 spec/state_mate/adapters/defaults/read_defaults_spec.rb
state_mate-0.0.2 spec/state_mate/adapters/defaults/read_defaults_spec.rb
state_mate-0.0.1 spec/state_mate/adapters/defaults/read_defaults_spec.rb