Class: UmtsCustomMatchers::RedirectBack
- Inherits:
-
Object
- Object
- UmtsCustomMatchers::RedirectBack
- Defined in:
- lib/umts-custom-matchers/redirect_back.rb
Constant Summary collapse
- MATCHER_MODULE =
RSpec::Rails::Matchers
- STATUS_CODE_MATCHER =
MATCHER_MODULE::HaveHttpStatus::GenericStatus
- REDIRECT_PATH_MATCHER =
MATCHER_MODULE::RedirectTo::RedirectTo
Instance Method Summary collapse
-
#initialize(scope) ⇒ RedirectBack
constructor
A new instance of RedirectBack.
- #matches?(code) ⇒ Boolean
- #supports_block_expectations? ⇒ Boolean
Constructor Details
#initialize(scope) ⇒ RedirectBack
Returns a new instance of RedirectBack.
9 10 11 |
# File 'lib/umts-custom-matchers/redirect_back.rb', line 9 def initialize(scope) @scope = scope end |
Instance Method Details
#matches?(code) ⇒ Boolean
13 14 15 16 17 18 19 20 |
# File 'lib/umts-custom-matchers/redirect_back.rb', line 13 def matches?(code) path = 'http://test.host/redirect' @scope.request.env['HTTP_REFERER'] = path return false unless code.is_a? Proc code.call STATUS_CODE_MATCHER.new(:redirect).matches?(@scope.response) && REDIRECT_PATH_MATCHER.new(@scope, path).matches?(true) end |
#supports_block_expectations? ⇒ Boolean
22 23 24 |
# File 'lib/umts-custom-matchers/redirect_back.rb', line 22 def supports_block_expectations? true end |