Created
November 16, 2010 14:15
-
-
Save j1n3l0/701864 to your computer and use it in GitHub Desktop.
HowTo: test private methods in Ruby [ruby, test]
This file contains hidden or 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
# HowTo: test private methods in Ruby | |
# | |
# @author Nelo Onyiah | |
require "rubygems" | |
require "shoulda" | |
module Baz | |
private | |
def quux | |
"Hello, World!" | |
end | |
end | |
class Foo | |
private | |
def bar | |
42 | |
end | |
end | |
class TestFoo < Test::Unit::TestCase | |
include Baz | |
public :quux | |
context "A new Foo" do | |
setup do | |
@foo = Foo.new | |
end | |
should "have bar == 42" do | |
assert_equal 42, @foo.send( :bar ) | |
end | |
should "have quux == 'Hello, World!'" do | |
assert_equal "Hello, World!", quux | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See this thread on stackoverflow for details