Skip to content

Instantly share code, notes, and snippets.

View jdelStrother's full-sized avatar
👋

Jonathan del Strother jdelStrother

👋
View GitHub Profile
it "receive_message_chain allows inline return values" do
object = double('hi')
allow(object).to receive_message_chain(:msg1, :msg2 => :return_value)
expect {
object.msg1("nonsense", :value).msg2("another", :nonsense, 3.0, "value")
}.not_to raise_error
end
diff --git a/lib/rspec/mocks/message_chain.rb b/lib/rspec/mocks/message_chain.rb
index 97f2762..3445364 100644
--- a/lib/rspec/mocks/message_chain.rb
+++ b/lib/rspec/mocks/message_chain.rb
@@ -44,7 +44,7 @@ module RSpec
hash = chain.pop
hash.each do |k,v|
chain << k
- blk = lambda { v }
+ blk = lambda {|*args| v }
describe "a blank category" do
let(:subject) { Category.new }
it { should have(1).error_on(:title) }
....
end
# rspec 3
describe "a blank category" do
let(:subject) { Category.new }
specify { expect(subject.errors_on(:title)).to be_present }
require 'mysql2'
require 'fast_stack'
client = Mysql2::Client.new(:host => "localhost", :username => "root")
query = "SELECT * FROM information_schema.COLUMNS LIMIT 58"
# '58' is something of a magic number for this query. Any less, and the bug doesn't show up. At 58 or greater, I get:
# "Lost connection to MySQL server during query (Mysql2::Error)"
# The bug goes away if you comment out the FastStack.profile{} line.
@interface MyAudioPlayer() {
AVAudioPlayer* currentPlayer;
}
@end
@implementation MyAudioPlayer
+(instance_type)sharedPlayer {
static MyAudioPlayer* sharedPlayer;
static dispatch_once_t onceToken;
2013-11-01 12:58:14.004 Audioboo[174:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
#0 0x37c9d688 in objc_exception_throw ()
#1 0x2d800d40 in -[__NSArrayM insertObject:atIndex:] ()
#2 0x302e8ace in __46-[UITableView _updateWithItems:updateSupport:]_block_invoke687 ()
#3 0x3006d2ac in +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] ()
#4 0x3008416c in +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] ()
#5 0x3023311c in -[UITableView _updateWithItems:updateSupport:] ()
#6 0x3020ad8a in -[UITableView _endCellAnimationsWithContext:] ()
#7 0x302698ee in -[UITableView insertRowsAtIndexPaths:withRowAnimation:] ()
#6 0x00165802 in -[ABBoardsViewController tableView:cellForRowAtIndexPath:] at /Users/jon/Developer/iphone/Classes/ABBoardsViewController.m:95
#7 0x33a70314 in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] ()
#8 0x33a186cc in -[UITableView _updateVisibleCellsNow:] ()
#9 0x33a17ef0 in -[UITableView layoutSubviews] ()
#10 0x3393e352 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#11 0x335c4942 in -[CALayer layoutSublayers] ()
#12 0x335c0166 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#13 0x335bfff8 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#14 0x335bfa0c in CA::Context::commit_transaction(CA::Transaction*) ()
#15 0x335bf81e in CA::Transaction::commit() ()
@protocol FooDelegate;
@interface Foo : NSObject
@property id<FooDelegate> delegate;
@end
@protocol FooDelegate
-(void)foo:(Foo*)x didBar:(NSString*)bar;
@end
class RecurringWorker
def perform
next_runtime = Time.now+10.minutes
do_something
Delayed::Job.enqueue RecurringWorker.new, :run_at => next_runtime
end
end
require 'rack/handler/webrick'
require 'selenium-webdriver'
require 'rack'
class Selenium::WebDriver::Chrome::Bridge
def extract_service_args(args)
["--log-path=chromedriver.log", "--verbose"]
end
end