Sha256: 98eb0436a563f09be965d470270dd34e393557cc57c249fdce7342d32d26ee3d

Contents?: true

Size: 705 Bytes

Versions: 79

Compression:

Stored size: 705 Bytes

Contents

require 'test_helper'
require 'mongoid'
require 'mongoid/document'

class MongoidTest < MiniTest::Spec
  describe "Mongoid compatibility" do
    it "allows #to_json" do
      class Profile
        include Mongoid::Document
        field :name
      end
      
      class Dude
        include Mongoid::Document
        embeds_one :profile, :class_name => "MongoidTest::Profile"
      end
      
      module ProfileRepresenter
       include Representable::JSON

       property :name
      end

      dude = Dude.new
      dude.profile = Profile.new
      dude.profile.name = "Kofi"
      
      assert_equal "{\"name\":\"Kofi\"}", dude.profile.extend(ProfileRepresenter).to_json
    end      
  end
end

Version data entries

79 entries across 75 versions & 1 rubygems

Version Path
representable-2.1.6 test/mongoid_test.rb
representable-2.1.5 test/mongoid_test.rb
representable-2.1.4 test/mongoid_test.rb
representable-2.1.3 test/mongoid_test.rb
representable-2.1.1 test/mongoid_test.rb
representable-2.1.0 test/mongoid_test.rb
representable-2.0.4 test/mongoid_test.rb
representable-2.0.3 test/mongoid_test.rb
representable-2.0.2 test/mongoid_test.rb
representable-2.0.1 test/mongoid_test.rb
representable-2.0.0 test/mongoid_test.rb
representable-2.0.0.rc2 test/mongoid_test.rb
representable-2.0.0.rc1 test/mongoid_test.rb
representable-1.8.5 test/mongoid_test.rb
representable-1.8.4 test/mongoid_test.rb
representable-1.8.3 test/mongoid_test.rb
representable-1.8.2 test/mongoid_test.rb
representable-1.8.1 test/mongoid_test.rb
representable-1.8.0 test/mongoid_test.rb
representable-1.7.7 test/mongoid_test.rb