This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# <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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How awful is this hack? | |
should "work" do | |
@response = OpenStruct.new(:body => some_helper_method) | |
assert_select 'div' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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]; | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
OlderNewer