-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrspec.rb
37 lines (32 loc) · 849 Bytes
/
rspec.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
require 'json'
require 'rspec/matchers'
require 'rspec/core'
require 'jsonapi/rspec/id'
require 'jsonapi/rspec/type'
require 'jsonapi/rspec/attributes'
require 'jsonapi/rspec/relationships'
require 'jsonapi/rspec/links'
require 'jsonapi/rspec/meta'
require 'jsonapi/rspec/jsonapi_object'
require 'jsonapi/rspec/errors'
RSpec.configure do |c|
c.add_setting :jsonapi_indifferent_hash, default: false
end
module JSONAPI
module RSpec
include Id
include Type
include Attributes
include Relationships
include Links
include Meta
include JsonapiObject
def self.as_indifferent_hash(doc)
return doc unless ::RSpec.configuration.jsonapi_indifferent_hash
if doc.respond_to?(:with_indifferent_access)
return doc.with_indifferent_access
end
JSON.parse(JSON.generate(doc))
end
end
end