We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
jsonapi_indifferent_hash
1 parent b0a2582 commit 1abbf3aCopy full SHA for 1abbf3a
spec/jsonapi/rspec_spec.rb
@@ -0,0 +1,31 @@
1
+require 'securerandom'
2
+require 'spec_helper'
3
+
4
+RSpec.describe JSONAPI::RSpec, '#as_indifferent_hash' do
5
+ let(:doc) do
6
+ {
7
+ id: SecureRandom.uuid,
8
+ list: [
9
+ { one: 1, 'one + one' => :two }
10
+ ],
11
+ hash: { key: :value, 'another key' => 'another value' }
12
+ }
13
+ end
14
15
+ it do
16
+ expect(JSONAPI::RSpec.as_indifferent_hash(doc)).not_to eq(
17
+ JSON.parse(JSON.generate(doc))
18
+ )
19
20
21
+ context 'with jsonapi indifferent hash enabled' do
22
+ before(:all) { ::RSpec.configuration.jsonapi_indifferent_hash = true }
23
+ after(:all) { ::RSpec.configuration.jsonapi_indifferent_hash = false }
24
25
26
+ expect(JSONAPI::RSpec.as_indifferent_hash(doc)).to eq(
27
28
29
30
31
+end
0 commit comments