Sha256: 8f62d2682e57e0fedc6bcacd0e16562f279b3a18f4d117d87a6c794953b968ca
Contents?: true
Size: 1004 Bytes
Versions: 1
Compression:
Stored size: 1004 Bytes
Contents
require 'json' require 'spec_helper' require 'state_mate/adapters/json' describe "StateMate::Adapters::JSON.read" do include_context "json" it "reads an empty file as nil" do expect( json.read [filepath] ).to be nil end context "file with a string value in it" do let(:value) { "blah" } before(:each) { File.open(filepath, 'w') {|f| f.write JSON.dump(value) } } it "should read the value" do expect( json.read [filepath] ).to eq value end end context "file with a dict value in it" do let(:value) { { 'x' => 1, 'y' => 2, 'z' => { 'a' => 3, } } } before(:each) { File.open(filepath, 'w') {|f| f.write JSON.dump(value) } } it "should read the root value" do expect( json.read [filepath] ).to eq value end it "should read a deeper value" do expect( json.read "#{ filepath }:z:a" ).to eq 3 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/read_spec.rb |