Sha256: ec3c723c6183739ee03dfd9a6803d137280ba4561804d44a84f256aafcea8e59
Contents?: true
Size: 936 Bytes
Versions: 1
Compression:
Stored size: 936 Bytes
Contents
require 'json' require 'spec_helper' require 'state_mate/adapters/json' describe "StateMate::Adapters::JSON.write" do include_context "json" context "root value" do let(:value) { { "some_key" => "some value" } } it "should write the value" do json.write filepath, value expect( JSON.load(File.read(filepath)) ).to eq value end end context "deep value" do let(:doc) { { "top-level-key" => { 'second-level-key' => "old value" } } } let(:key) { [filepath, "top-level-key", "second-level-key"] } let(:value) { "new value" } before(:each) { File.open(filepath, 'w') do |f| f.write JSON.dump(doc) end } it "should write the value" do json.write key, value expect( JSON.load(File.read(filepath))[key[1]][key[2]] ).to eq value end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
state_mate-0.0.1 | spec/state_mate/adapters/json/write_spec.rb |