Skip to content

Instantly share code, notes, and snippets.

@kizzx2
Created October 3, 2013 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kizzx2/6806924 to your computer and use it in GitHub Desktop.
Save kizzx2/6806924 to your computer and use it in GitHub Desktop.
require 'mongoid'
require 'minitest'
require 'minitest/autorun'
class Foo
include Mongoid::Document
field :x, type: Integer
field :y, type: Integer
end
class FooTest < MiniTest::Test
def setup
File.write(
'mongoid.yml', <<MONGOID
test:
sessions:
default:
database: test
hosts:
- localhost:27017
MONGOID
)
Mongoid.load!('mongoid.yml', :test)
Moped.logger = Logger.new($stdout)
Foo.delete_all
end
def test_update_attributes_should_only_change_provided_attributes
puts "Moped version: #{Moped::VERSION}"
puts "Mongoid version: #{Mongoid::VERSION}"
f = Foo.create!(x: 1, y: 2)
f.x = 3
f.update_attributes
f.reload
assert_equal 1, f.x
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment