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
# 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")}) |
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
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 | |
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 "dm-core" | |
require 'dm-migrations' | |
require "test/unit" | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Person | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String |
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
#!/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) | |
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
{ | |
"directory": "vendor/assets/bower_components" | |
} |
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
# 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 |
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
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 |
NewerOlder