Class: HTTPRedirectTest

Inherits:
MiniTest::Test
  • Object
show all
Defined in:
lib/http_redirect_test/http_redirect_test.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.domainObject (readonly)

Returns the value of attribute domain.



5
6
7
# File 'lib/http_redirect_test/http_redirect_test.rb', line 5

def domain
  @domain
end

.permanentObject (readonly)

Returns the value of attribute permanent.



5
6
7
# File 'lib/http_redirect_test/http_redirect_test.rb', line 5

def permanent
  @permanent
end

Class Method Details

.permanent?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/http_redirect_test/http_redirect_test.rb', line 15

def permanent?
  !!@permanent
end

.set_domain(domain) ⇒ Object



7
8
9
# File 'lib/http_redirect_test/http_redirect_test.rb', line 7

def set_domain(domain)
  @domain = domain
end

.treat_all_redirects_as_permanentObject



11
12
13
# File 'lib/http_redirect_test/http_redirect_test.rb', line 11

def treat_all_redirects_as_permanent
  @permanent = true
end

Instance Method Details

#override_domain_with(domain, &block) ⇒ Object



55
56
57
58
59
60
# File 'lib/http_redirect_test/http_redirect_test.rb', line 55

def override_domain_with(domain, &block)
  @domain = domain
  block.call
ensure
  @domain = nil
end

#should_be_gone(path) ⇒ Object



42
43
44
# File 'lib/http_redirect_test/http_redirect_test.rb', line 42

def should_be_gone(path)
  assert check_for(path).gone?
end

#should_have_header(path, header, options) ⇒ Object



50
51
52
53
# File 'lib/http_redirect_test/http_redirect_test.rb', line 50

def should_have_header(path, header, options)
  value = options[:with_value]
  assert_equal value, check_for(path).header(header)
end

#should_not_be_found(path) ⇒ Object



46
47
48
# File 'lib/http_redirect_test/http_redirect_test.rb', line 46

def should_not_be_found(path)
  assert check_for(path).not_found?
end

#should_not_redirect(path) ⇒ Object



20
21
22
23
# File 'lib/http_redirect_test/http_redirect_test.rb', line 20

def should_not_redirect(path)
  assert_equal false, check_for(path).redirected?, "#{path} is redirecting"
  assert_equal true, check_for(path).success?, "#{path} is not a success response"
end

#should_redirect(source, options) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/http_redirect_test/http_redirect_test.rb', line 25

def should_redirect(source, options)
  source_path = ResourcePath.new(source, :param => 'subdir').to_s
  destination_path = ResourcePath.new(options[:to], :param => 'subdir').to_s

  redirection = check_for(source_path, destination_path)
  assert_equal true, redirection.redirected?, "'#{source_path}' is not redirecting"
  assert_equal destination_path, redirection.redirected_path,
               "'#{source_path}' is not redirecting to '#{destination_path}'"

  return if options[:permanent] == false

  if permanent? || options[:permanent] == true
    assert_equal true, redirection.permanent_redirect?,
                 "The redirection from '#{source_path}' to '#{destination_path}' doesn't appear to be a permanent redirect"
  end
end