Skip to content

Instantly share code, notes, and snippets.

1) Customer
Failure/Error: should_validate_uniqueness_of :email
could not find a Customer record in the database
# /Users/txus/.bundle/ruby/1.8/gems/remarkable_activerecord-4.0.0.alpha1/lib/remarkable_activerecord/matchers/validate_uniqueness_of_matcher.rb:49:in `find_first_object?'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:371:in `send'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:371:in `send_methods_and_generate_message'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:370:in `each'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:370:in `send_methods_and_generate_message'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/dsl/assertions.rb:406:in `matches_collection_assertions?'
# /Users/txus/.bundle/ruby/1.8/gems/remarkable-4.0.0.alpha1/lib/remarkable/base.
# in customers_controller.rb
def CustomersController < ApplicationController
before_filter :load_languages, :only => :new
def new
...
end
protected
# Comparison between after_or_equal_to and
# before_or_equal_to behaviors (they should
# be the same, just that the former sends a
# >= and the latter a <=.
class Product < ActiveRecord::Base
validates :expiration_date, :date => {:before_or_equal_to => Time.now}
end
model = Product.new(:expiration_date => Time.now) # Should be valid
# Curl command to post "3 whatever" to daytum through your twitter account remotely!
# (Replace twitter_user, twitter_password, whatever and 3 as you wish)
# Note: you must have your twitter account linked to daytum (go to daytum settings)
curl -u twitter_user:twitter_password -d "text=whatever:3&user=daytum" http://twitter.com/direct_messages/new.xml
/Users/user/Code/project/vendor/plugins/backupmyapp/lib/backupmyapp/init.rb:5:in `included': undefined local variable or method `filter_chain' for ActionController::Base:Class (NameError)
from /Users/user/Code/project/vendor/plugins/backupmyapp/lib/backupmyapp/init.rb:4:in `class_eval'
from /Users/user/Code/project/vendor/plugins/backupmyapp/lib/backupmyapp/init.rb:4:in `included'
from /Users/user/Code/project/vendor/plugins/backupmyapp/init.rb:1:in `include'
from /Users/user/Code/project/vendor/plugins/backupmyapp/init.rb:1:in `send'
from /Users/user/Code/project/vendor/plugins/backupmyapp/init.rb:1
from /Users/user/.rvm/gems/ruby-1.8.7-p302@project/gems/railties-3.0.0.rc/lib/rails/plugin.rb:81
from /Users/user/.rvm/gems/ruby-1.8.7-p302@project/gems/railties-3.0.0.rc/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/user/.rvm/gems/ruby-1.8.7-p302@project/gems/railties-3.0.0.rc/lib/rails/initializable.rb:25:in `run'
from /Users/user/.rvm/gems/ruby-1.8.7-p302@project/gems/railties-3.0.0.rc/
# lib/rspec/core/subject.rb
require 'ostruct'
def its(attribute, &block)
describe(attribute) do
example do
self.class.class_eval do
define_method(:subject) do
attribute.to_s.split('.').inject(super()) do |target, method|
@txus
txus / numlock.vim
Created September 23, 2010 08:04 — forked from oriolgual/numlock.vim
" Add it to your local vimrc
" Toggle it with <F4> in normal mode
let g:numberlock = 0
let g:numberlock_layout = 'us'
nnoremap <silent><F4> :call NumberLock()<CR>
function! NumberLock()
if g:numberlock
let g:numberlock = 0
@txus
txus / rspec-expectations_issue-19.rb
Created October 2, 2010 17:01
Sample spec for RSpec Matcher compatibility with TestUnit and Minitest
# matchers.rb
module RSpec
module Matchers
if RSpec.respond_to?(:configure)
RSpec.configure {|c| c.include self}
end
# Include Matchers for other test frameworks
if defined?(Test::Unit::TestCase)
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
task :default => :spec
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
task :default => :spec