Class: Test::Spec::Rails::Macros::Should
- Defined in:
- lib/test/spec/rails/macros.rb,
lib/test/spec/rails/macros/response.rb,
lib/test/spec/rails/macros/authorization.rb
Overview
Macros define methods on the Should class if they want to be called from the test case.
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
-
#allow ⇒ Object
Generates a test which tests authorization code.
-
#disallow ⇒ Object
Generates a test which tests authorization code.
- #not_find ⇒ Object
-
#require_login ⇒ Object
Generates a test which tests authorization code.
Methods inherited from Proxy
Constructor Details
This class inherits a constructor from Test::Spec::Rails::Macros::Proxy
Instance Method Details
#allow ⇒ Object
Generates a test which tests authorization code. It assumes a method called access_denied?
on the test case. The access_denied?
method should return true when access is denied (ie. a 403 status code) and false in other cases.
Example:
should.allow.get :index
23 24 25 26 27 28 |
# File 'lib/test/spec/rails/macros/authorization.rb', line 23 def allow Test::Spec::Rails::Macros::Authorization::TestGenerator.new(test_case, :access_denied?, false, 'Expected access to be allowed' ) end |
#disallow ⇒ Object
Generates a test which tests authorization code. It assumes a method called access_denied?
on the test case. The access_denied?
method should return true when access is denied (ie. a 403 status code) and false in other cases.
Example:
should.disallow.get :index
10 11 12 13 14 15 |
# File 'lib/test/spec/rails/macros/authorization.rb', line 10 def disallow Test::Spec::Rails::Macros::Authorization::TestGenerator.new(test_case, :access_denied?, true, 'Expected access to be denied' ) end |
#not_find ⇒ Object
4 5 6 7 8 9 |
# File 'lib/test/spec/rails/macros/response.rb', line 4 def not_find Test::Spec::Rails::Macros::Response::TestGenerator.new(test_case, :not_found, 'Expected to not find a resource' ) end |
#require_login ⇒ Object
Generates a test which tests authorization code. It assumes a method called access_denied?
on the test case. The login_required?
method should return true when the visitor was asked for credentials (ie. a 401 status code or a redirect to a login page) and false in other cases.
Example:
should.require_login.get :index
36 37 38 39 40 41 |
# File 'lib/test/spec/rails/macros/authorization.rb', line 36 def require_login Test::Spec::Rails::Macros::Authorization::TestGenerator.new(test_case, :login_required?, true, 'Expected login to be required' ) end |