Sha256: 639b26fd45e6ecd9a4fdf7cb0bb820da2a0deb2420233a6920d66c20959908de
Contents?: true
Size: 941 Bytes
Versions: 2
Compression:
Stored size: 941 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
state_mate-0.0.3 | spec/state_mate/adapters/json/write_spec.rb |
state_mate-0.0.2 | spec/state_mate/adapters/json/write_spec.rb |