Skip to content

Instantly share code, notes, and snippets.

diff --git a/lib/mocha/expectation.rb b/lib/mocha/expectation.rb
index 5dddac9..b1b0a73 100644
--- a/lib/mocha/expectation.rb
+++ b/lib/mocha/expectation.rb
@@ -287,10 +287,14 @@ module Mocha # :nodoc:
# :call-seq: raises(exception = RuntimeError, message = nil) -> expectation
#
- # Modifies expectation so that when the expected method is called, it raises the specified +exception+ with the specified +message+.
+ # Modifies expectation so that when the expected method is called, it raises the specified +exception+ with the specified +message+ i.e. calls Kernel#raise(exception, message).
class Red
def gets(*args)
@input.gets(*args)
end
def puts(*args)
@output.puts(*args)
end
def initialize
@input = $stdin
@output = $stdout
@floehopper
floehopper / capybara-envjs-textarea-issue.txt
Created September 15, 2010 08:25
illustrates a problem i'm seeing with capybara-envjs
# HTML file with form including textarea
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>test</title>
</head>
<body>
<form action="/blah" id="wemForm" method="post">
<textarea id="wem" name="wem"></textarea>
@floehopper
floehopper / gist:640838
Created October 22, 2010 16:12
mocha-mailing-list-question-
# I have a setup method in my controller test that looks like this:
def setup
@order = Order.new
@order.save_new
session[:order_id] = @order.id
end
# I have a test that looks like this:
require "test/unit"
require "rubygems"
require "mocha"
class Bar
def bar; end
end
def foo
timer = Timer.start(60)
@floehopper
floehopper / wem.rb
Created November 24, 2010 18:23
Use httparty to connect using SSL mutual authentication
require "rubygems"
require "httparty"
class Wem
include HTTParty
debug_output $stderr
ssl_ca_file '/Users/jamesmead/Sites/ssltest/demoCA/ca.crt'
pem File.read('/Users/jamesmead/Sites/ssltest/user/hashblue.pem')
base_uri "https://127.0.0.1/"
def self.wem
@floehopper
floehopper / net_https.rb
Created November 24, 2010 22:35
SSL Mutual Authentication using Ruby Net::HTTP
require 'net/https'
url = ARGV[0] || 'www.random.org'
https = Net::HTTP.new(url, Net::HTTP.https_default_port)
https.use_ssl = true
https.ssl_timeout = 2
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
https.ca_file = '/usr/share/curl/curl-ca-bundle.crt'
https.verify_depth = 2
https.enable_post_connection_check = true
@floehopper
floehopper / tsung.txt
Created November 25, 2010 14:04
Some notes where we tried to work out what the Tsung stats meant
127.0.0.1 - - [07/Oct/2010:16:37:05 +0100] "GET / HTTP/1.1" 200 3463 359023
127.0.0.1 - - [07/Oct/2010:16:37:07 +0100] "GET / HTTP/1.1" 200 3463 523320
127.0.0.1 - - [07/Oct/2010:16:37:09 +0100] "GET / HTTP/1.1" 200 3463 332680
127.0.0.1 - - [07/Oct/2010:16:37:16 +0100] "GET / HTTP/1.1" 200 3463 434459
127.0.0.1 - - [07/Oct/2010:16:37:20 +0100] "GET / HTTP/1.1" 200 3463 311130
127.0.0.1 - - [07/Oct/2010:16:37:36 +0100] "GET / HTTP/1.1" 200 3463 688370
$rate,$mean,$stdvar,$max,$min,$meanfb,$countfb
require "test/unit"
require "rubygems"
require "mocha"
class Controller
def showplain(params)
output = nil
Cleaner.parse(params[:content]) do |cleaner|
output = cleaner.plainversion
end
require "test/unit"
require "rubygems"
require "shoulda"
require "mocha"
class Red
def gets(*args)
@input.gets(*args)
end
def puts(*args)