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-3.0.1 test/mongoid_test.rb
representable-3.0.0 test/mongoid_test.rb
representable-2.4.1 test-with-deprecations/mongoid_test.rb
representable-2.4.1 test/mongoid_test.rb
representable-2.4.0 test/mongoid_test.rb
representable-2.4.0 test-with-deprecations/mongoid_test.rb
representable-2.4.0.rc5 test-with-deprecations/mongoid_test.rb
representable-2.4.0.rc5 test/mongoid_test.rb
representable-2.4.0.rc4 test-with-deprecations/mongoid_test.rb
representable-2.4.0.rc4 test/mongoid_test.rb
representable-2.4.0.rc3 test/mongoid_test.rb
representable-2.4.0.rc2 test/mongoid_test.rb
representable-2.4.0.rc1 test/mongoid_test.rb
representable-2.3.0 test/mongoid_test.rb
representable-2.2.3 test/mongoid_test.rb
representable-2.2.2 test/mongoid_test.rb
representable-2.2.1 test/mongoid_test.rb
representable-2.2.0 test/mongoid_test.rb
representable-2.1.8 test/mongoid_test.rb
representable-2.1.7 test/mongoid_test.rb