ldp 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 956f52c643432907584236bd1d46ee3ceeaa720e
4
- data.tar.gz: caf6a6247b19c4d86aacb9d882f62254bdc4b682
3
+ metadata.gz: 0e8d452c791e099e1a633bcc58b3861b1fadb599
4
+ data.tar.gz: edac475bb689f7e2cbd582d620aeb7249935d843
5
5
  SHA512:
6
- metadata.gz: e5b586a5af1bbcfd97850786ed8cd139e53ed103a4770b27ff9774681247d54bc9c493f3eada647b6282efc6b55b5829174139734fd84d434f75e661da4d01f4
7
- data.tar.gz: d742e30ac69b306314885a11352ae248a1e516c136758663a3d18ff27329682b2a03d7f8cc3dfdf629b6cfb4a20ec51ec3c822263f0dd299de76a3a8ce7a53e6
6
+ metadata.gz: 14049aa77e903891b22c95f294d091ec859ea87a640ab137dc41a639477a1b23f0c1f752bec23a4505bdc504d0dd3448e54571d474559bed5287b8519c21add3
7
+ data.tar.gz: 3f61c96706429e86ba276f9c1d7a52df970f926e9f26f81f89aa3f8aaa2abd3ae414596f712a2c3a52dcbac83030585fbe82bcc14b0426de3ac0b6deef870741
data/.gitignore CHANGED
@@ -15,4 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- .storage
18
+ .storage
19
+ /spec/examples.txt
@@ -115,7 +115,7 @@ module Ldp::Client::Methods
115
115
 
116
116
  def check_for_errors resp
117
117
  resp.tap do |resp|
118
- unless resp.success?
118
+ unless resp.status < 400
119
119
  raise case resp.status
120
120
  when 400
121
121
  if resp.env.method == :head
data/lib/ldp/resource.rb CHANGED
@@ -66,7 +66,7 @@ module Ldp
66
66
  # Delete the resource
67
67
  def delete
68
68
  client.delete subject do |req|
69
- req.headers['If-Match'] = get.etag if retrieved_content?
69
+ req.headers['If-Unmodified-Since'] = get.last_modified if retrieved_content?
70
70
  end
71
71
  end
72
72
 
@@ -95,7 +95,7 @@ module Ldp
95
95
  def update new_content = nil
96
96
  new_content ||= content
97
97
  resp = client.put subject, new_content do |req|
98
- req.headers['If-Match'] = get.etag if retrieved_content?
98
+ req.headers['If-Unmodified-Since'] = get.last_modified if retrieved_content?
99
99
  yield req if block_given?
100
100
  end
101
101
  update_cached_get(resp) if retrieved_content?
data/lib/ldp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ldp
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -29,6 +29,10 @@ describe "Ldp::Client" do
29
29
  stub.put("/forbidden_resource") { [403, {}, ''] }
30
30
  stub.put("/conflict_resource") { [409, {}, ''] }
31
31
  stub.get("/deleted_resource") { [410, {}, 'Gone'] }
32
+ stub.head("/temporary_redirect1") { [302, {"Location" => "http://example.com/new"}] }
33
+ stub.head("/temporary_redirect2") { [307, {"Location" => "http://example.com/new"}] }
34
+ stub.head("/permanent_redirect1") { [301, {"Location" => "http://example.com/new"}] }
35
+ stub.head("/permanent_redirect2") { [308, {"Location" => "http://example.com/new"}] }
32
36
  end
33
37
  end
34
38
 
@@ -276,6 +280,17 @@ describe "Ldp::Client" do
276
280
  resource = subject.find_or_initialize "a_binary_resource"
277
281
  expect(resource).to be_a_kind_of(Ldp::Resource::BinarySource)
278
282
  end
283
+ end
284
+
285
+ describe "head" do
286
+ it "treats temporary redirects as successful" do
287
+ expect { subject.head "temporary_redirect1" }.not_to raise_error
288
+ expect { subject.head "temporary_redirect2" }.not_to raise_error
289
+ end
279
290
 
291
+ it "treats permanent redirects as successful" do
292
+ expect { subject.head "permanent_redirect1" }.not_to raise_error
293
+ expect { subject.head "permanent_redirect2" }.not_to raise_error
294
+ end
280
295
  end
281
296
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Ldp::Resource::BinarySource do
4
- let(:client) { double }
4
+ let(:client) { instance_double(Ldp::Client) }
5
5
  let(:uri) { 'http://example.com/foo/bar' }
6
6
  let(:content) { 'somecontent' }
7
7
  subject { described_class.new(client, uri, content) }
@@ -14,7 +14,7 @@ describe Ldp::Resource::BinarySource do
14
14
  describe '#described_by' do
15
15
  context 'without a description' do
16
16
  before do
17
- allow(client).to receive(:head).and_return(double(links: { }))
17
+ allow(client).to receive(:head).and_return(instance_double(Ldp::Response, links: { }))
18
18
  end
19
19
 
20
20
  it 'retrieves the description object' do
@@ -24,7 +24,7 @@ describe Ldp::Resource::BinarySource do
24
24
 
25
25
  context 'with a description' do
26
26
  before do
27
- allow(client).to receive(:head).and_return(double(links: { 'describedby' => ['http://example.com/foo/bar/desc']}))
27
+ allow(client).to receive(:head).and_return(instance_double(Ldp::Response, links: { 'describedby' => ['http://example.com/foo/bar/desc']}))
28
28
  allow(client).to receive(:find_or_initialize).with('http://example.com/foo/bar/desc').and_return(desc)
29
29
  end
30
30
 
@@ -35,5 +35,4 @@ describe Ldp::Resource::BinarySource do
35
35
  end
36
36
  end
37
37
  end
38
-
39
38
  end
@@ -4,8 +4,8 @@ describe Ldp::Response do
4
4
  LDP_RDF_RESOURCE_HEADERS = { "Link" => "<#{RDF::Vocab::LDP.Resource}>;rel=\"type\", <#{RDF::Vocab::LDP.DirectContainer}>;rel=\"type\""}
5
5
  LDP_NON_RDF_SOURCE_HEADERS = { "Link" => "<#{RDF::Vocab::LDP.Resource}>;rel=\"type\", <#{RDF::Vocab::LDP.NonRDFSource}>;rel=\"type\""}
6
6
 
7
- let(:mock_response) { double("mock response", headers: {}, env: { url: "info:a" }) }
8
- let(:mock_client) { double(Ldp::Client) }
7
+ let(:mock_response) { instance_double(Faraday::Response, headers: {}, env: { url: "info:a" }) }
8
+ let(:mock_client) { instance_double(Ldp::Client) }
9
9
 
10
10
  subject do
11
11
  Ldp::Response.new mock_response
data/spec/spec_helper.rb CHANGED
@@ -17,5 +17,82 @@ require 'faraday'
17
17
  require 'active_support/notifications'
18
18
 
19
19
  RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
20
33
 
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # Many RSpec users commonly either run the entire suite or an individual
44
+ # file, and it's useful to allow more verbose output when running an
45
+ # individual spec file.
46
+ if config.files_to_run.one?
47
+ # Use the documentation formatter for detailed output,
48
+ # unless a formatter has already been configured
49
+ # (e.g. via a command-line flag).
50
+ config.default_formatter = 'doc'
51
+ end
52
+
53
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
54
+ # have no way to turn it off -- the option exists only for backwards
55
+ # compatibility in RSpec 3). It causes shared context metadata to be
56
+ # inherited by the metadata hash of host groups and examples, rather than
57
+ # triggering implicit auto-inclusion in groups with matching metadata.
58
+ config.shared_context_metadata_behavior = :apply_to_host_groups
59
+
60
+ # This allows you to limit a spec run to individual examples or groups
61
+ # you care about by tagging them with `:focus` metadata. When nothing
62
+ # is tagged with `:focus`, all examples get run. RSpec also provides
63
+ # aliases for `it`, `describe`, and `context` that include `:focus`
64
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
65
+ config.filter_run_when_matching :focus
66
+
67
+ # Allows RSpec to persist some state between runs in order to support
68
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
69
+ # you configure your source control system to ignore this file.
70
+ config.example_status_persistence_file_path = 'spec/examples.txt'
71
+
72
+ # Many RSpec users commonly either run the entire suite or an individual
73
+ # file, and it's useful to allow more verbose output when running an
74
+ # individual spec file.
75
+ if config.files_to_run.one?
76
+ # Use the documentation formatter for detailed output,
77
+ # unless a formatter has already been configured
78
+ # (e.g. via a command-line flag).
79
+ config.default_formatter = 'doc'
80
+ end
81
+
82
+ # Print the 10 slowest examples and example groups at the
83
+ # end of the spec run, to help surface which specs are running
84
+ # particularly slow.
85
+ config.profile_examples = 10
86
+
87
+ # Run specs in random order to surface order dependencies. If you find an
88
+ # order dependency and want to debug it, you can fix the order by providing
89
+ # the seed, which is printed after each run.
90
+ # --seed 1234
91
+ config.order = :random
92
+
93
+ # Seed global randomization in this process using the `--seed` CLI option.
94
+ # Setting this allows you to use `--seed` to deterministically reproduce
95
+ # test failures related to randomization by passing the same `--seed` value
96
+ # as the one that triggered the failure.
97
+ Kernel.srand config.seed
21
98
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ldp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday