Skip to content

Instantly share code, notes, and snippets.

def define_simple_predicate_matcher options={}
options.each_pair do |name, predicate|
Spec::Matchers.define name do
match {|actual| actual.send(predicate)}
end
end
end
def changed_set_or_cleared(attribute, current, previous=nil, html=true)
change = ''
if previous.nil? && !current.nil?
change = "#{html ? '→' : 'set to'} #{current.send(attribute).name}" if !current.send(attribute).nil?
else
if !current.send(attribute).nil? && !previous.send(attribute).nil?
change = "#{previous.send(attribute).name} #{html ? '→' : 'changed to'} #{current.send(attribute).name}"
elsif !current.send(attribute).nil? && previous.send(attribute).nil?
change = "#{html ? '→' : 'set to'} #{current.send(attribute).name}"
else
undefined method `ToString' for #<V8::Object:0x10034c7d0 @native=#<V8::C::Object:0x10034d720>> (NoMethodError)
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.7.3/bin/../lib/cucumber/js_support/js_language.rb:37:in `initialize'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.7.3/bin/../lib/cucumber/js_support/js_language.rb:140:in `new'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.7.3/bin/../lib/cucumber/js_support/js_language.rb:140:in `add_step_definition'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.7.0/lib/v8/to.rb:39:in `call'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.7.0/lib/v8/to.rb:39
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.7.0/lib/v8/context.rb:29:in `call'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.7.0/lib/v8/context.rb:29:in `Run'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.7.0/lib/v8/context.rb:29:in `eval'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-
Using the default profile...
segfault: game over.
0 v8.bundle 0x0000000101605f45 _ZN12_GLOBAL__N_18segfaultEi + 53
1 libSystem.B.dylib 0x00007fff8006480a _sigtramp + 26
2 ??? 0x00000001008bf610 0x0 + 4304139792
3 ruby 0x000000010003b685 rb_hash_lookup + 21
4 v8.bundle 0x00000001016078ec _ZN12_GLOBAL__N_13Obj23RubyNamedPropertyGetterEN2v85LocalINS1_6StringEEERKNS1_12AccessorInfoE + 92
5 v8.bundle 0x00000001016c85cf _ZN2v88internal8JSObject26GetPropertyWithInterceptorEPS1_PNS0_6StringEP18PropertyAttributes + 575
Uncaught SyntaxError: Unexpected token ILLEGAL: <eval>:1 (V8::JavascriptError)
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.6.3/lib/v8/context.rb:27:in `eval'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.6.3/lib/v8/context.rb:26:in `tap'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.6.3/lib/v8/context.rb:26:in `eval'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.6.3/lib/v8/context.rb:25:in `open'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.6.3/lib/v8/context.rb:25:in `eval'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.6.3/lib/v8/object.rb:41
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.6.3/lib/v8/context.rb:13:in `call'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.6.3/lib/v8/context.rb:13:in `open'
/Users/coreyhaines/.rvm/gems/ruby-1.8.7-p249/gems/therubyracer-0.6.3/lib/v8/context.rb:12:in `open'
1) check_boxes input for a has_many association should call find on the association class when no collection is provided
Failure/Error: Unable to find matching line from backtrace
(<Author (class)>).find(any args)
expected: 1 time
received: 0 times
# ./spec/support/custom_macros.rb:247:in `it_should_call_find_on_association_class_when_no_collection_is_provided'
==> production.log <==
Starting the New Relic Agent.
Started GET "/" for 64.81.225.149 at Wed Aug 18 20:08:22 -0700 2010
NameError (undefined local variable or method `connection' for ActiveRecord::Base:Class):
# Or......
class CommentsController < ApplicationController
def index
@comments = Topic.find(params[:topic_id]).not_shitty_comments
end
end
function uncheckAllDays() {
$("#group_walk_mon").attr('checked', false);
$("#group_walk_tue").attr('checked', false);
$("#group_walk_wed").attr('checked', false);
$("#group_walk_thu").attr('checked', false);
$("#group_walk_fri").attr('checked', false);
$("#group_walk_sat").attr('checked', false);
$("#group_walk_sun").attr('checked', false);
}
function day_elements() {
return $("#group_walk_mon, #group_walk_tue, #group_walk_wed, ...");
}
function uncheckAllDays() {
day_elements().attr('checked', false);
}