Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Don't expose all the private API
Browse files Browse the repository at this point in the history
  • Loading branch information
eightbitraptor committed Jun 18, 2014
1 parent 2aedbb0 commit 36c3ab7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
30 changes: 17 additions & 13 deletions lib/http_redirect_test/http_redirect_test.rb
Expand Up @@ -6,22 +6,10 @@ class HTTPRedirectTest < MiniTest::Unit::TestCase

def default_test; end # placeholder to stop Test::Unit from complaining

class <<self
module ClassMethods
attr_accessor :domain
attr_writer :permanent

def permanent?
!!@permanent
end

def name_for(path)
if path.empty?
'root'
else
path.strip.gsub(/\W+/, '_')
end
end

def should_not_redirect(path)
class_eval <<-CODE
def test_#{name_for(path)}_should_not_redirect
Expand Down Expand Up @@ -80,6 +68,22 @@ def test_should_return_value_for_#{name_for(header)}_header
end
CODE
end

private

def permanent?
!!@permanent
end

def name_for(path)
if path.empty?
'root'
else
path.strip.gsub(/\W+/, '_')
end
end

end

extend ClassMethods
end
5 changes: 3 additions & 2 deletions test/unit/http_redirect_test_test.rb
Expand Up @@ -2,9 +2,10 @@

class HttpRedirectTestTests < MiniTest::Unit::TestCase
def test_that_permanent_flag_is_being_set_correctly
assert_equal false, HTTPRedirectTest.permanent?
assert_equal false, HTTPRedirectTest.__send__(:permanent?)

HTTPRedirectTest.permanent=true
assert_equal true, HTTPRedirectTest.permanent?
assert_equal true, HTTPRedirectTest.__send__(:permanent?)
end

def test_each_class_should_have_its_own_domain
Expand Down

0 comments on commit 36c3ab7

Please sign in to comment.