Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pathsny/338532 to your computer and use it in GitHub Desktop.
Save pathsny/338532 to your computer and use it in GitHub Desktop.
require File.expand_path('../../spec_helper', __FILE__)
describe "DataMapper Collections" do
class SuperHero
include DataMapper::Resource
property :id, Serial
property :status, Enum[:dead, :alive, :limbo], :required => true
end
SuperHero.auto_migrate!
it 'allows you to update all fields directly in the database' do
superman = SuperHero.create(:status => :dead)
SuperHero.all(:status => :dead).update(:status => :limbo)
superman.reload
superman.status.should == :limbo
SuperHero.all(:status => :limbo).update!(:status => :alive)
superman.reload
superman.status.should == :alive
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment