Created
October 3, 2013 08:29
-
-
Save kizzx2/6806924 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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