Sha256: 73fb5b4a0cfa550119bafb66f87261b58c021ebbf629aa33c2275bceda4d4107

Contents?: true

Size: 760 Bytes

Versions: 17

Compression:

Stored size: 760 Bytes

Contents

require 'spec_helper'

class Drink
  include CouchPotato::Persistence
  
  property :alcohol
end

describe CouchPotato::Persistence::Json do
  context '#to_hash' do
    it "should inject JSON.create_id into the hash representation of a persistent object" do
      sake = Drink.new(:alcohol => "18%")
      expect(sake.to_hash[JSON.create_id]).to eql("Drink")
    end
    
    it "should not include _attachments if there are none" do
      sake = Drink.new(:alcohol => "18%")
      expect(sake.to_hash.keys).not_to include('_attachments')
    end
    
  end
  
  context '.json_create' do
    it 'should assign the _document' do
      sake = Drink.json_create({"alcohol" => "18%"})
      expect(sake._document).to eq({"alcohol" => "18%"})
    end
  end
  
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
couch_potato-1.18.0 spec/unit/json_spec.rb
couch_potato-1.17.0 spec/unit/json_spec.rb
couch_potato-1.16.0 spec/unit/json_spec.rb
couch_potato-1.15.0 spec/unit/json_spec.rb
couch_potato-1.14.0 spec/unit/json_spec.rb
couch_potato-1.13.0 spec/unit/json_spec.rb
couch_potato-1.12.1 spec/unit/json_spec.rb
couch_potato-1.12.0 spec/unit/json_spec.rb
couch_potato-1.11.0 spec/unit/json_spec.rb
couch_potato-1.10.1 spec/unit/json_spec.rb
couch_potato-1.10.0 spec/unit/json_spec.rb
couch_potato-1.9.0 spec/unit/json_spec.rb
couch_potato-1.7.1 spec/unit/json_spec.rb
couch_potato-1.7.0 spec/unit/json_spec.rb
couch_potato-1.6.5 spec/unit/json_spec.rb
couch_potato-1.6.4 spec/unit/json_spec.rb
couch_potato-1.6.3 spec/unit/json_spec.rb