Class: HTTPRedirectTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- HTTPRedirectTest
- Defined in:
- lib/traffic_cop/http_redirect_test.rb
Class Method Summary collapse
- .domain=(domain) ⇒ Object
- .name_for(path) ⇒ Object
- .should_not_redirect(path) ⇒ Object
- .should_redirect(source, options) ⇒ Object
Instance Method Summary collapse
-
#default_test ⇒ Object
placeholder to stop Test::Unit from complaining.
Class Method Details
.domain=(domain) ⇒ Object
7 8 9 |
# File 'lib/traffic_cop/http_redirect_test.rb', line 7 def self.domain=(domain) RedirectCheck.domain = domain end |
.name_for(path) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/traffic_cop/http_redirect_test.rb', line 22 def self.name_for(path) name = path.gsub(/\W+/, '_') name.gsub!(/^_+/, '') name.gsub!(/_+$/, '') name = 'root' if name == '' name end |
.should_not_redirect(path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/traffic_cop/http_redirect_test.rb', line 11 def self.should_not_redirect(path) class_eval " def test_\#{name_for(path)}_should_not_redirect\n check = RedirectCheck.new('\#{path}')\n \n assert_equal false, check.redirected?, \"\#{path} is redirecting\"\n assert_equal true, check.success?, \"\#{path} is not a success response\"\n end\n CODE\nend\n" |
.should_redirect(source, options) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/traffic_cop/http_redirect_test.rb', line 32 def self.should_redirect(source, ) source_path = ResourcePath.new(source, :param => 'subdir').to_s destination_path = ResourcePath.new([:to], :param => 'subdir').to_s permanent = .fetch(:permanent, true) class_eval " def test_\#{name_for(source_path)}_should_redirect_to_\#{name_for(destination_path)}\n redirection = RedirectCheck.new('\#{source_path}', '\#{destination_path}')\n \n assert_equal true, redirection.redirected?, \"'\#{source_path}' is not redirecting\"\n assert_equal '\#{destination_path}', redirection.redirected_path, \n \"'\#{source_path}' is not redirecting to '\#{destination_path}'\"\n \n if \#{permanent}\n assert_equal true, redirection.permanent_redirect?, \n \"The redirection from '\#{source_path}' to '\#{destination_path}' doesn't appear to be a permanent redirect\"\n end\n end\n CODE\n\nend\n" |
Instance Method Details
#default_test ⇒ Object
placeholder to stop Test::Unit from complaining
5 |
# File 'lib/traffic_cop/http_redirect_test.rb', line 5 def default_test; end |