Skip to content

Instantly share code, notes, and snippets.

View Zequez's full-sized avatar

Ezequiel Schwartzman Zequez

View GitHub Profile
@Zequez
Zequez / gist:1218098
Created September 14, 2011 23:26
ActiveRecord::AssociationTypeMismatch Full Trace
activerecord (3.1.0.rc8) lib/active_record/associations/association.rb:205:in `raise_on_type_mismatch'
activerecord (3.1.0.rc8) lib/active_record/associations/belongs_to_association.rb:6:in `replace'
activerecord (3.1.0.rc8) lib/active_record/associations/singular_association.rb:17:in `writer'
activerecord (3.1.0.rc8) lib/active_record/associations/builder/association.rb:49:in `block in define_writers'
activerecord (3.1.0.rc8) lib/active_record/base.rb:1745:in `block in assign_attributes'
activerecord (3.1.0.rc8) lib/active_record/base.rb:1741:in `each'
activerecord (3.1.0.rc8) lib/active_record/base.rb:1741:in `assign_attributes'
activerecord (3.1.0.rc8) lib/active_record/associations/association.rb:237:in `block in build_record'
activerecord (3.1.0.rc8) lib/active_record/base.rb:1563:in `initialize'
activerecord (3.1.0.rc8) lib/active_record/reflection.rb:190:in `new'
@Zequez
Zequez / attr_readonly_error.rb
Created September 6, 2011 15:07
attr_readonly error
# Model:
class User < ActiveRecord::Base
attr_readonly :email
end
# Controller:
user = User.new :email => 'foo@bar.com'
@Zequez
Zequez / user_spec.rb
Created September 1, 2011 11:19
My tests are a mess
require 'spec_helper'
describe User do
subject { @user }
before(:each) { @user = User.new }
context "when creating .new User" do
before(:each) { @user = User.new }
@Zequez
Zequez / Backtrace_rspec_shoulda.log
Created August 29, 2011 03:50
Shoulda not showing error, Rspec backtrace
$ rspec spec/models/user_spec.rb:118 --drb -d -b
Run filtered including {:line_number=>118}
F
Failures:
1) User validation for password should not require password confirmation
Failure/Error: should allow_value('something').for :password
Did not expect errors when password is set to "something", got error:
# /home/zequez/.rvm/gems/ruby-1.9.2-p290/gems/rspec-expectations-2.6.0/lib/rspec/expectations/fail_with.rb:29:in `fail_with'