File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 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+ end
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+ it do
26+ expect ( JSONAPI ::RSpec . as_indifferent_hash ( doc ) ) . to eq (
27+ JSON . parse ( JSON . generate ( doc ) )
28+ )
29+ end
30+ end
31+ end
You can’t perform that action at this time.
0 commit comments