Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
#
# A one file test to show count
require 'rubygems'
require 'dm-core'
require 'dm-aggregates'
# setup the logger
DataMapper::Logger.new(STDOUT, :debug)
require "dm-core"
require 'dm-migrations'
require "test/unit"
DataMapper.setup(:default, 'sqlite3::memory:')
class Person
include DataMapper::Resource
property :id, Serial
property :name, String
Spec::Runner.configure do |config|
config.before do
repository do |r|
transaction = DataMapper::Transaction.new(r)
transaction.begin
r.adapter.push_transaction(transaction)
end
end
# line 16
it "should tell you when it receives the right message with the wrong args if you stub the method (fix bug 15719)" do
# NOTE - for whatever reason, if you use a the block style of pending here,
# rcov gets unhappy. Don't know why yet.
m = mock("foo")
m.stub!(:bar)
m.should_receive(:bar).with("message")
lambda {
m.bar("different message")
}.should raise_error(Rspec::Mocks::MockExpectationError, %Q{Mock 'foo' expected :bar with ("message") but received it with ("different message")})
@probablykabari
probablykabari / datamapper_lazy_load_patch.patch
Created December 14, 2010 05:22
This fixes lazy loading in Datamapper
From 8e634002d6d79e2c5e2b599e69edd867628364d3 Mon Sep 17 00:00:00 2001
From: Kabari Hendrick <[email protected]>
Date: Mon, 13 Dec 2010 23:10:33 -0600
Subject: [PATCH] fixing lazy load
Signed-off-by: Kabari Hendrick <[email protected]>
---
lib/dm-core/model/property.rb | 2 +-
spec/public/property_spec.rb | 14 +++++++++++++-
@probablykabari
probablykabari / allow-subclassed-model-to-have-different-storage.patch
Created December 14, 2010 06:29
Allow DataMapper::Model descendants to have different storage names and work with auto_upgrade/auto_migrate
From dac3c04bba2898757e0ea7004b49ec7f63894d50 Mon Sep 17 00:00:00 2001
From: Kabari Hendrick <[email protected]>
Date: Tue, 14 Dec 2010 00:26:54 -0600
Subject: [PATCH] allow subclassesd models to have different storage
Signed-off-by: Kabari Hendrick <[email protected]>
---
lib/dm-migrations/auto_migration.rb | 6 +-
spec/integration/model_migration_spec.rb | 64 ++++++++++++++++++++++++++++++
@probablykabari
probablykabari / fix_hooks_in_before_on_non_dirty_resources.patch
Created December 18, 2010 16:53
fixing bug 1372: save method not catching validations on accessors
From feeb8da75a0f6b2dd6d07c53fa4235fef21f050f Mon Sep 17 00:00:00 2001
From: Kabari Hendrick <[email protected]>
Date: Sat, 18 Dec 2010 10:41:19 -0600
Subject: [PATCH] fixing bug 1372: save method not catching validations on accessors
Signed-off-by: Kabari Hendrick <[email protected]>
---
lib/dm-core/resource.rb | 5 ++---
lib/dm-core/spec/shared/resource_spec.rb | 5 +++--
From 95c7e993f0c124f6fda4fce45452d63ede469fd3 Mon Sep 17 00:00:00 2001
From: Kabari Hendrick <[email protected]>
Date: Wed, 22 Dec 2010 13:01:51 -0600
Subject: [PATCH] git rid of strict dependency
Signed-off-by: Kabari Hendrick <[email protected]>
---
Rakefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
@probablykabari
probablykabari / descendant_spec.rb
Created April 7, 2011 16:47
Dynamic model creation broken in DM 1.1
require 'spec_helper'
require 'dm-core'
def create_dm_model(name)
DataMapper::Model.new(name) do
property :id, DataMapper::Property::Serial
property :name, DataMapper::Property::String
end
end
@probablykabari
probablykabari / dm-rspec-transaction.rb
Created May 10, 2011 16:37
datamapper rspec transaction
config.before(:each) do
repository(:default) do
transaction = DataMapper::Transaction.new(repository)
transaction.begin
repository.adapter.push_transaction(transaction)
end
end
config.after(:each) do
repository(:default).adapter.pop_transaction.rollback