{"action":"created","comment":{"url":"https://api.github.com/repos/michaelherold/hashie/pulls/comments/42951349","id":42951349,"diff_hunk":"@@ -0,0 +1,170 @@\n+require 'spec_helper'\n+\n+RSpec.describe Hashie::Extensions::Persistable do\n+  describe '.load' do\n+    let(:full_options) { { adapter: adapter } }\n+    let(:options) { full_options }\n+\n+    subject { Hashie::Extensions::Persistable.load(source, options) }\n+\n+    context 'with a JSON adapter' do\n+      let(:adapter) { Hashie::Extensions::Persistable::Json::Adapter.new }\n+      let(:source) { StringIO.new('{\"test\":\"value\"}') }\n+\n+      it 'loads the source' do\n+        expect(subject).to eq('test' => 'value')\n+      end\n+    end\n+\n+    context 'with a YAML adapter' do\n+      let(:adapter) { Hashie::Extensions::Persistable::Yaml::Adapter.new }\n+      let(:source) { StringIO.new(\"---\\ntest: value\\n\") }\n+\n+      it 'loads the source' do\n+        expect(subject).to eq('test' => 'value')\n+      end\n+    end\n+  end\n+\n+  describe '.persist' do\n+    let(:adapter) { Hashie::Extensions::Persistable::Json::Adapter.new }\n+    let(:hash) { { 'test' => 'value' } }\n+    let(:store) { StringIO.new }\n+    let(:full_options) { { adapter: adapter, target: store } }\n+    let(:options) { full_options }\n+\n+    subject { Hashie::Extensions::Persistable.persist(hash, options) }\n+\n+    it 'persists the hash to the store in a JSON format' do\n+      subject\n+      store.rewind\n+      expect(store.read).to eq '{\"test\":\"value\"}'\n+    end\n+\n+    context 'without an adapter' do\n+      let(:options) { full_options.reject { |k, _| k == :adapter } }\n+\n+      it 'raises an ArgumentError' do\n+        expect { subject }.to raise_error ArgumentError\n+      end\n+    end\n+\n+    context 'without a target' do\n+      let(:options) { full_options.reject { |k, _| k == :target } }\n+\n+      it 'raises an ArgumentError' do\n+        expect { subject }.to raise_error ArgumentError\n+      end\n+    end\n+  end\n+\n+  context 'when included plainly' do\n+    class UnconfiguredPersistableHash < Hash\n+      include Hashie::Extensions::Persistable\n+    end\n+\n+    subject(:hash) { UnconfiguredPersistableHash['test' => 'value'] }\n+\n+    it { is_expected.to respond_to :persist }\n+\n+    describe '#adapter' do\n+      subject { hash.adapter }\n+\n+      it { is_expected.to be_a Hashie::Extensions::Persistable::Json::Adapter }\n+    end\n+  end\n+\n+  context 'when included as a built module' do\n+    context 'without any configuration' do\n+      class PersistableHash < Hash\n+        include Hashie::Extensions::Persistable.new\n+      end\n+\n+      subject(:hash) { PersistableHash['test' => 'value'] }\n+\n+      it { is_expected.to respond_to :persist }\n+\n+      describe '#adapter' do\n+        subject { hash.adapter }\n+\n+        it { is_expected.to be_a Hashie::Extensions::Persistable::Json::Adapter }\n+      end\n+\n+      describe '#persist' do\n+        let(:store) { StringIO.new }\n+\n+        subject { hash.persist(store) }\n+\n+        it 'persists the hash to the store in a JSON format' do\n+          subject\n+          store.rewind\n+          expect(store.read).to eq '{\"test\":\"value\"}'\n+        end\n+\n+        context 'with a String path for the store' do\n+          let(:file) { Tempfile.new('string-test.json') }\n+          let(:store) { file.path }\n+\n+          it 'persists the hash to the file stored at the path' do\n+            subject\n+            file.rewind\n+            expect(file.read).to eq '{\"test\":\"value\"}'\n+          end\n+        end\n+\n+        context 'without a store' do","path":"spec/hashie/extensions/persistable_spec.rb","position":115,"original_position":115,"commit_id":"932d21b191f78d1e022aa3e8722881cb61f97d85","original_commit_id":"932d21b191f78d1e022aa3e8722881cb61f97d85","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.","created_at":"2015-10-25T22:28:01Z","updated_at":"2015-10-25T22:28:01Z","html_url":"https://github.com/michaelherold/hashie/pull/1#discussion_r42951349","pull_request_url":"https://api.github.com/repos/michaelherold/hashie/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/michaelherold/hashie/pulls/comments/42951349"},"html":{"href":"https://github.com/michaelherold/hashie/pull/1#discussion_r42951349"},"pull_request":{"href":"https://api.github.com/repos/michaelherold/hashie/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/michaelherold/hashie/pulls/1","id":48689722,"html_url":"https://github.com/michaelherold/hashie/pull/1","diff_url":"https://github.com/michaelherold/hashie/pull/1.diff","patch_url":"https://github.com/michaelherold/hashie/pull/1.patch","issue_url":"https://api.github.com/repos/michaelherold/hashie/issues/1","number":1,"state":"open","locked":false,"title":"Test Hound PR","user":{"login":"michaelherold","id":424833,"avatar_url":"https://avatars.githubusercontent.com/u/424833?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelherold","html_url":"https://github.com/michaelherold","followers_url":"https://api.github.com/users/michaelherold/followers","following_url":"https://api.github.com/users/michaelherold/following{/other_user}","gists_url":"https://api.github.com/users/michaelherold/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelherold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelherold/subscriptions","organizations_url":"https://api.github.com/users/michaelherold/orgs","repos_url":"https://api.github.com/users/michaelherold/repos","events_url":"https://api.github.com/users/michaelherold/events{/privacy}","received_events_url":"https://api.github.com/users/michaelherold/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-25T22:27:56Z","updated_at":"2015-10-25T22:28:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8268f5e667fd690bd0748825a63676f8922aa407","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/michaelherold/hashie/pulls/1/commits","review_comments_url":"https://api.github.com/repos/michaelherold/hashie/pulls/1/comments","review_comment_url":"https://api.github.com/repos/michaelherold/hashie/pulls/comments{/number}","comments_url":"https://api.github.com/repos/michaelherold/hashie/issues/1/comments","statuses_url":"https://api.github.com/repos/michaelherold/hashie/statuses/932d21b191f78d1e022aa3e8722881cb61f97d85","head":{"label":"michaelherold:persistence-framework","ref":"persistence-framework","sha":"932d21b191f78d1e022aa3e8722881cb61f97d85","user":{"login":"michaelherold","id":424833,"avatar_url":"https://avatars.githubusercontent.com/u/424833?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelherold","html_url":"https://github.com/michaelherold","followers_url":"https://api.github.com/users/michaelherold/followers","following_url":"https://api.github.com/users/michaelherold/following{/other_user}","gists_url":"https://api.github.com/users/michaelherold/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelherold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelherold/subscriptions","organizations_url":"https://api.github.com/users/michaelherold/orgs","repos_url":"https://api.github.com/users/michaelherold/repos","events_url":"https://api.github.com/users/michaelherold/events{/privacy}","received_events_url":"https://api.github.com/users/michaelherold/received_events","type":"User","site_admin":false},"repo":{"id":22090870,"name":"hashie","full_name":"michaelherold/hashie","owner":{"login":"michaelherold","id":424833,"avatar_url":"https://avatars.githubusercontent.com/u/424833?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelherold","html_url":"https://github.com/michaelherold","followers_url":"https://api.github.com/users/michaelherold/followers","following_url":"https://api.github.com/users/michaelherold/following{/other_user}","gists_url":"https://api.github.com/users/michaelherold/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelherold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelherold/subscriptions","organizations_url":"https://api.github.com/users/michaelherold/orgs","repos_url":"https://api.github.com/users/michaelherold/repos","events_url":"https://api.github.com/users/michaelherold/events{/privacy}","received_events_url":"https://api.github.com/users/michaelherold/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/michaelherold/hashie","description":"Hashie is a simple collection of useful Hash extensions.","fork":true,"url":"https://api.github.com/repos/michaelherold/hashie","forks_url":"https://api.github.com/repos/michaelherold/hashie/forks","keys_url":"https://api.github.com/repos/michaelherold/hashie/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michaelherold/hashie/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michaelherold/hashie/teams","hooks_url":"https://api.github.com/repos/michaelherold/hashie/hooks","issue_events_url":"https://api.github.com/repos/michaelherold/hashie/issues/events{/number}","events_url":"https://api.github.com/repos/michaelherold/hashie/events","assignees_url":"https://api.github.com/repos/michaelherold/hashie/assignees{/user}","branches_url":"https://api.github.com/repos/michaelherold/hashie/branches{/branch}","tags_url":"https://api.github.com/repos/michaelherold/hashie/tags","blobs_url":"https://api.github.com/repos/michaelherold/hashie/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michaelherold/hashie/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michaelherold/hashie/git/refs{/sha}","trees_url":"https://api.github.com/repos/michaelherold/hashie/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michaelherold/hashie/statuses/{sha}","languages_url":"https://api.github.com/repos/michaelherold/hashie/languages","stargazers_url":"https://api.github.com/repos/michaelherold/hashie/stargazers","contributors_url":"https://api.github.com/repos/michaelherold/hashie/contributors","subscribers_url":"https://api.github.com/repos/michaelherold/hashie/subscribers","subscription_url":"https://api.github.com/repos/michaelherold/hashie/subscription","commits_url":"https://api.github.com/repos/michaelherold/hashie/commits{/sha}","git_commits_url":"https://api.github.com/repos/michaelherold/hashie/git/commits{/sha}","comments_url":"https://api.github.com/repos/michaelherold/hashie/comments{/number}","issue_comment_url":"https://api.github.com/repos/michaelherold/hashie/issues/comments{/number}","contents_url":"https://api.github.com/repos/michaelherold/hashie/contents/{+path}","compare_url":"https://api.github.com/repos/michaelherold/hashie/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michaelherold/hashie/merges","archive_url":"https://api.github.com/repos/michaelherold/hashie/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michaelherold/hashie/downloads","issues_url":"https://api.github.com/repos/michaelherold/hashie/issues{/number}","pulls_url":"https://api.github.com/repos/michaelherold/hashie/pulls{/number}","milestones_url":"https://api.github.com/repos/michaelherold/hashie/milestones{/number}","notifications_url":"https://api.github.com/repos/michaelherold/hashie/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michaelherold/hashie/labels{/name}","releases_url":"https://api.github.com/repos/michaelherold/hashie/releases{/id}","created_at":"2014-07-22T04:35:37Z","updated_at":"2014-08-26T13:44:10Z","pushed_at":"2015-10-25T22:27:56Z","git_url":"git://github.com/michaelherold/hashie.git","ssh_url":"git@github.com:michaelherold/hashie.git","clone_url":"https://github.com/michaelherold/hashie.git","svn_url":"https://github.com/michaelherold/hashie","homepage":"http://rdoc.info/projects/intridea/hashie","size":840,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"michaelherold:master","ref":"master","sha":"9298241eb2d500fa573b1c2aa22ecd91c877d812","user":{"login":"michaelherold","id":424833,"avatar_url":"https://avatars.githubusercontent.com/u/424833?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelherold","html_url":"https://github.com/michaelherold","followers_url":"https://api.github.com/users/michaelherold/followers","following_url":"https://api.github.com/users/michaelherold/following{/other_user}","gists_url":"https://api.github.com/users/michaelherold/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelherold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelherold/subscriptions","organizations_url":"https://api.github.com/users/michaelherold/orgs","repos_url":"https://api.github.com/users/michaelherold/repos","events_url":"https://api.github.com/users/michaelherold/events{/privacy}","received_events_url":"https://api.github.com/users/michaelherold/received_events","type":"User","site_admin":false},"repo":{"id":22090870,"name":"hashie","full_name":"michaelherold/hashie","owner":{"login":"michaelherold","id":424833,"avatar_url":"https://avatars.githubusercontent.com/u/424833?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelherold","html_url":"https://github.com/michaelherold","followers_url":"https://api.github.com/users/michaelherold/followers","following_url":"https://api.github.com/users/michaelherold/following{/other_user}","gists_url":"https://api.github.com/users/michaelherold/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelherold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelherold/subscriptions","organizations_url":"https://api.github.com/users/michaelherold/orgs","repos_url":"https://api.github.com/users/michaelherold/repos","events_url":"https://api.github.com/users/michaelherold/events{/privacy}","received_events_url":"https://api.github.com/users/michaelherold/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/michaelherold/hashie","description":"Hashie is a simple collection of useful Hash extensions.","fork":true,"url":"https://api.github.com/repos/michaelherold/hashie","forks_url":"https://api.github.com/repos/michaelherold/hashie/forks","keys_url":"https://api.github.com/repos/michaelherold/hashie/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michaelherold/hashie/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michaelherold/hashie/teams","hooks_url":"https://api.github.com/repos/michaelherold/hashie/hooks","issue_events_url":"https://api.github.com/repos/michaelherold/hashie/issues/events{/number}","events_url":"https://api.github.com/repos/michaelherold/hashie/events","assignees_url":"https://api.github.com/repos/michaelherold/hashie/assignees{/user}","branches_url":"https://api.github.com/repos/michaelherold/hashie/branches{/branch}","tags_url":"https://api.github.com/repos/michaelherold/hashie/tags","blobs_url":"https://api.github.com/repos/michaelherold/hashie/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michaelherold/hashie/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michaelherold/hashie/git/refs{/sha}","trees_url":"https://api.github.com/repos/michaelherold/hashie/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michaelherold/hashie/statuses/{sha}","languages_url":"https://api.github.com/repos/michaelherold/hashie/languages","stargazers_url":"https://api.github.com/repos/michaelherold/hashie/stargazers","contributors_url":"https://api.github.com/repos/michaelherold/hashie/contributors","subscribers_url":"https://api.github.com/repos/michaelherold/hashie/subscribers","subscription_url":"https://api.github.com/repos/michaelherold/hashie/subscription","commits_url":"https://api.github.com/repos/michaelherold/hashie/commits{/sha}","git_commits_url":"https://api.github.com/repos/michaelherold/hashie/git/commits{/sha}","comments_url":"https://api.github.com/repos/michaelherold/hashie/comments{/number}","issue_comment_url":"https://api.github.com/repos/michaelherold/hashie/issues/comments{/number}","contents_url":"https://api.github.com/repos/michaelherold/hashie/contents/{+path}","compare_url":"https://api.github.com/repos/michaelherold/hashie/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michaelherold/hashie/merges","archive_url":"https://api.github.com/repos/michaelherold/hashie/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michaelherold/hashie/downloads","issues_url":"https://api.github.com/repos/michaelherold/hashie/issues{/number}","pulls_url":"https://api.github.com/repos/michaelherold/hashie/pulls{/number}","milestones_url":"https://api.github.com/repos/michaelherold/hashie/milestones{/number}","notifications_url":"https://api.github.com/repos/michaelherold/hashie/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michaelherold/hashie/labels{/name}","releases_url":"https://api.github.com/repos/michaelherold/hashie/releases{/id}","created_at":"2014-07-22T04:35:37Z","updated_at":"2014-08-26T13:44:10Z","pushed_at":"2015-10-25T22:27:56Z","git_url":"git://github.com/michaelherold/hashie.git","ssh_url":"git@github.com:michaelherold/hashie.git","clone_url":"https://github.com/michaelherold/hashie.git","svn_url":"https://github.com/michaelherold/hashie","homepage":"http://rdoc.info/projects/intridea/hashie","size":840,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/michaelherold/hashie/pulls/1"},"html":{"href":"https://github.com/michaelherold/hashie/pull/1"},"issue":{"href":"https://api.github.com/repos/michaelherold/hashie/issues/1"},"comments":{"href":"https://api.github.com/repos/michaelherold/hashie/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/michaelherold/hashie/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/michaelherold/hashie/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/michaelherold/hashie/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/michaelherold/hashie/statuses/932d21b191f78d1e022aa3e8722881cb61f97d85"}}}}