Skip to content

Instantly share code, notes, and snippets.

#
# Macro that creates a test asserting that the controller sends the
# content type given.
# Example:
#
# should_send_content_type :pdf
# should_send_content_type :csv
def should_send_content_type(content_type)
should "send content type #{content_type}" do
assert_equal Mime::Type.lookup_by_extension(content_type.to_s).to_s,
# Prevents autotest from running your entire test suite after fixing a failed test.
# Works with ZenTest 3.10.0
# Place this in your .autotest file:
class Autotest
def run
hook :initialize
reset
add_sigint_handler
...............F.F.F.........................F.F.F.F.F.F
Finished in 0.619878 seconds.
1) Failure:
test: A logged in user dealing with another user's account on get :edit, :id => @user.to_param should redirect to "root_url". (UsersControllerTest)
Expected response to be a redirect to <http://test.host/> but was a redirect to <http://test.host/login>.
2) Failure:
test: A logged in user dealing with another user's account on get :show, :id => @user.to_param should redirect to "root_url". (UsersControllerTest)
1) Failure:
test: Given a user a POST to #create with bad credentials should return the correct value from the session for key :user_id. (SessionsControllerTest)
Expected 63 but was .
<63> expected but was
<nil>.
2) Failure:
test: Given a user on GET to /sessions/new should have a session form.
test: Class Document with attachment upload should have the correct definition. (DocumentTest):
NoMethodError: undefined method `attachment_definition' for #<Class:0x23cbb60>
method method_missing in base.rb at line 1768
method __bind_1223056228_747486 in paperclip.rb at line 14
method call in context.rb at line 257
method test: Class Document with attachment upload should have the correct definition. in context.rb at line 257
method __send__ in setup_and_teardown.rb at line 94
method run in setup_and_teardown.rb at line 94
2) Error:
# http://pastie.org/250821
require 'tlsmail'
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
God::Contacts::Email.message_settings = {
:from => 'admin@mydomain.com'
}
God::Contacts::Email.server_settings = {
@hardbap
hardbap / gist:19445
Created October 24, 2008 14:58
fixed code sample from section 5.3 of Rails 2.2 release notes
# fixed code sample from section 5.3 of Rails 2.2 release notes.
class Photo < ActiveRecord::Base
belongs_to :product
end
class Product < ActiveRecord::Base
has_many :photos
end
require File.dirname(__FILE__) + '/../test_helper'
class PhotoTest < ActiveSupport::TestCase
# FIXME: http://thoughtbot.lighthouseapp.com/projects/8794/tickets/35-should_have_attached_file - AVS
should_have_attached_file :image, :styles => { :medium => "500", :thumb => "150x150#" },
:path => ":rails_root/public/assets/images/:id/:style.:extension",
:url => "/assets/images/:id/:style.:extension", :validations => []
should_belong_to :property
@hardbap
hardbap / bashrc
Created November 11, 2008 14:19 — forked from defunkt/bashrc
alias gemi='sudo gem install --no-rdoc --no-ri'
alias svnst='svn st | grep -v status | grep \s'
alias dns='dscacheutil -flushcache'
alias ls='ls -G'
alias grep='grep --color'
alias less='less -r'
alias m='mate'
# prompt
def greeting
puts 'hello'
throw 'something bad'
rescue Exception => e
puts 'error'
ensure
puts 'goodbye'