-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_spec.rb
47 lines (33 loc) · 1.29 KB
/
client_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'rspec'
require 'webmock/rspec'
require_relative 'client.rb'
describe Client do
describe "#get_links" do
context "with an empty doc and empty hyperschema" do
it "returns an empty list" do
client = Client.new("{}", "{}")
expect(client.get_links).to eq([])
end
end
context "with a non-empty schema and doc" do
let!(:schema) { File.read("/Users/vandal/dev/hyperschema-client/example_hyperschema.json") }
let!(:doc) { File.read("/Users/vandal/dev/hyperschema-client/example_json_doc.json") }
it "returns list of links" do
client = Client.new(doc, schema)
expect(client.get_links.size).to eq(2)
end
it "returns the LDO as is if there are no template variables" do
client = Client.new(doc, schema)
expect(client.get_links).to include({"rel" => "author","href" => "https://api.example.com/author"})
end
it "replaces variables in the URI template" do
client = Client.new(doc, schema)
expect(client.get_links).to include({"rel" => "self","href" => "https://api.example.com/things/1"})
end
end
end
context "following the first link" do
let!(:schema) { File.read("example_hyperschema.json") }
let!(:doc) { File.read("example_json_doc.json") }
end
end