Skip to content

Instantly share code, notes, and snippets.

# 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")})
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
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
#!/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)
@probablykabari
probablykabari / .bowerrc
Last active August 29, 2015 14:22
Foundation Apps with Rails
{
"directory": "vendor/assets/bower_components"
}
@probablykabari
probablykabari / some_file_doing_stuff.rb
Created September 10, 2014 19:41
just showing some syntax stuff
# I see this a lot, and it is perfectly OK to do this
def new_cat(name, color)
cat = Cat.new
cat.name = name
cat.owner = self
cat.color = color
cat.save
end
# Here's another way to do that
@probablykabari
probablykabari / hashes_and_such.rb
Created September 3, 2014 17:52
Quick look at hash nesting
hash = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
hash["down"]["in-the"]["basement"] = "hello?"
hash
# => {"down"=>{"in-the"=>{"basement"=>"hello?"}}}
hash.has_key?("i-do-not")
# => false
hash.default = lambda{|h,k| h[k] = "bankai!" } # no longer a deeply nested/fun hash