ldp 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/lib/ldp/client/methods.rb +1 -1
- data/lib/ldp/resource.rb +2 -2
- data/lib/ldp/version.rb +1 -1
- data/spec/lib/ldp/client_spec.rb +15 -0
- data/spec/lib/ldp/resource/binary_source_spec.rb +3 -4
- data/spec/lib/ldp/response_spec.rb +2 -2
- data/spec/spec_helper.rb +77 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e8d452c791e099e1a633bcc58b3861b1fadb599
|
4
|
+
data.tar.gz: edac475bb689f7e2cbd582d620aeb7249935d843
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14049aa77e903891b22c95f294d091ec859ea87a640ab137dc41a639477a1b23f0c1f752bec23a4505bdc504d0dd3448e54571d474559bed5287b8519c21add3
|
7
|
+
data.tar.gz: 3f61c96706429e86ba276f9c1d7a52df970f926e9f26f81f89aa3f8aaa2abd3ae414596f712a2c3a52dcbac83030585fbe82bcc14b0426de3ac0b6deef870741
|
data/.gitignore
CHANGED
data/lib/ldp/client/methods.rb
CHANGED
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-
|
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-
|
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
data/spec/lib/ldp/client_spec.rb
CHANGED
@@ -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) {
|
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(
|
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(
|
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) {
|
8
|
-
let(:mock_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.
|
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-
|
11
|
+
date: 2016-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|