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-1.7.6 test/mongoid_test.rb
representable-1.7.5 test/mongoid_test.rb
representable-1.7.4 test/mongoid_test.rb
representable-1.7.3 test/mongoid_test.rb
representable-1.7.2 test/mongoid_test.rb
representable-1.7.1 test/mongoid_test.rb
representable-1.7.0 test/mongoid_test.rb
representable-1.6.1 test/mongoid_test.rb
representable-1.6.0 test/mongoid_test.rb
representable-1.5.3 test/mongoid_test.rb
representable-1.5.2 test/mongoid_test.rb
representable-1.5.1 test/mongoid_test.rb
representable-1.5.0 test/mongoid_test.rb
representable-1.4.2 test/mongoid_test.rb
representable-1.4.1 test/mongoid_test.rb
representable-1.4.0 test/mongoid_test.rb
representable-1.3.5 test/mongoid_test.rb
representable-1.3.4 test/mongoid_test.rb
representable-1.3.3 test/mongoid_test.rb
representable-1.3.2 test/mongoid_test.rb