Skip to content

Instantly share code, notes, and snippets.

View lmarburger's full-sized avatar
🥖
Temporally nondeterministic

Larry Marburger lmarburger

🥖
Temporally nondeterministic
View GitHub Profile
class ActionView::TestCase
class TestController < ActionController::Base
attr_accessor :params
# Save the current initialize method to call in the new initialize method below.
alias_method :base_initialize, :initialize
def initialize
base_initialize
require 'test_helper'
require 'flexmock/test_unit'
class SomeControllerTest < ActionController::TestCase
context "viewing the test page" do
setup do
get :index
end
should_respond_with :success
require 'test_helper'
require 'flexmock/test_unit'
class BlogHelperTest < ActionView::TestCase
tests BlogHelper
context "getting tweet list" do
setup do
@twitter_user = 'test'
@tweets = get_tweets_mock
require 'test_helper'
class PersonControllerTest < ActionController::TestCase
context "viewing a person" do
setup do
@session = { :person_id => @person_id = 1 }
@get_person = lambda { get :index, { :person_id => @person_id }, @session }
end
context "anonymously" do
# <div class="pagination clearfix first">
# <span class="pages">
# <a href="/wines/page/0" class="previous">Previous</a>
# <span>Page 1 of 14</span>
# <a href="/wines/page/1" class="next">Next</a>
# </span>
# <span class="goto">
# <label>Go to page:<input id="page" name="page" type="text"></label>
# <button class="go" type="submit">
# <span class="goto">Go</span>
>> puts <<-FIRST, <<-SECOND.upcase
This is the first here doc.
FIRST
This is
the second
here doc.
SECOND
# Prints:
# This is the first here doc.
module Test #:nodoc:
module Unit #:nodoc:
class TestCase #:nodoc:
class << self
def factories(*names)
names.each { |name| load_factory(name) }
end
private
def load_factory(name)
# How awful is this hack?
should "work" do
@response = OpenStruct.new(:body => some_helper_method)
assert_select 'div'
end
/*
Bookmarklet to load the current Twitter user page in CoTweet.
The condensed bookmarklet code expands to:
javascript:(function() {
var m = /https?:\/\/twitter\.com\/(\w+)/.exec(window.location.href);
if (m && m[1] != "home") {
window.location.href="https://cotweet.com/twitter/" + m[1];
}
})();
# Monkeypatching so we can write tests for helpers.
class ActionView::TestCase::TestController < ActionController::Base
attr_accessor :params
# Save the current initialize method to call in the new initialize method below.
alias :base_initialize :initialize # unless method_defined?(:base_initialize)
def initialize
base_initialize