Class: Zena::View::TestCase
- Inherits:
-
ActionView::TestCase
- Object
- ActionView::TestCase
- Zena::View::TestCase
- Includes:
- Authlogic::TestCase, Acts::Secure, Use::Fixtures, Use::TestHelper
- Defined in:
- lib/zena/view/test_case.rb
Constant Summary
Constants included from Use::Fixtures
Use::Fixtures::FILE_FIXTURES_PATH, Use::Fixtures::FIXTURE_PATH
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#flash ⇒ Object
Returns the value of attribute flash.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #assert_match(match, target) ⇒ Object
- #assert_no_match(match, target) ⇒ Object
- #session ⇒ Object
- #visiting(node_name) ⇒ Object
Methods included from Acts::Secure
#secure_scope, #secure_write_scope, #visitor=
Methods included from Acts::Secure::SecureResult
#construct_id_map, #secure_result
Methods included from Use::TestHelper
#err, #execute_after_commit!, #file_path, #login, #preserving_files, #set_date, #uploaded_archive, #uploaded_fixture, #uploaded_jpg, #uploaded_pdf, #uploaded_png, #uploaded_text, #uploaded_zip, #with_caching, #without_files
Methods included from Use::Fixtures
dest_filepath, included, #load_fixtures, load_fixtures, reset_data_folder, reset_public_folder, #test_site
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
4 5 6 |
# File 'lib/zena/view/test_case.rb', line 4 def controller @controller end |
#flash ⇒ Object
Returns the value of attribute flash.
4 5 6 |
# File 'lib/zena/view/test_case.rb', line 4 def flash @flash end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/zena/view/test_case.rb', line 4 def params @params end |
Instance Method Details
#assert_match(match, target) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/zena/view/test_case.rb', line 18 def assert_match(match, target) return super if match.kind_of?(Regexp) target = Hpricot(target) assert !target.search(match).empty?, "expected tag, but no tag found matching #{match.inspect} in:\n#{target.inspect}" end |
#assert_no_match(match, target) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/zena/view/test_case.rb', line 25 def assert_no_match(match, target) return super if match.kind_of?(Regexp) target = Hpricot(target) assert target.search(match).empty?, "expected not tag, but tag found matching #{match.inspect} in:\n#{target.inspect}" end |
#session ⇒ Object
32 33 34 |
# File 'lib/zena/view/test_case.rb', line 32 def session @controller.session end |
#visiting(node_name) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/zena/view/test_case.rb', line 38 def visiting(node_name) # We use ApplicationController because it has all helper modules @controller = ApplicationController.new #ActionView::TestCase::TestController.new # Same type of initialization as TestController @controller.instance_eval do self.request = ActionController::TestRequest.new self.response = ActionController::TestResponse.new self.params = {} self.session = {} @template = self.response.template = ::ActionView::Base.new(self.class.view_paths, {}, self) @template.helpers.send :include, self.class.master_helper_module initialize_current_url end @node = secure!(Node) { nodes(node_name) } @controller.instance_variable_set(:@node, @node) # Dummy request @controller.request.tap do |request| request.path_parameters = { 'controller' => 'nodes', 'action' => 'show', 'path' => zen_path(nodes(node_name)).split('/')[2..-1], 'prefix' => visitor.is_anon? ? visitor.lang : AUTHENTICATED_PREFIX, } request.symbolized_path_parameters @params = request.params @request = request end @flash = {} class << @flash def discard clear end end @node end |