Sha256: 7ef11679fea540a59f152eb5be6756d4bf69f9aec79ab3622c9cff57727cee86

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

module Zena
  module Controller
    class TestCase < ActionController::TestCase
      include Zena::Use::Fixtures
      include Zena::Use::TestHelper
      include Zena::Acts::Secure
      include ::Authlogic::TestCase

      def setup
        activate_authlogic
      end

      def login(fixture, site_name = nil)
        super
        if defined?(@controller)
          @controller.class_eval do
            def set_visitor
              # do nothing
            end
          end
        end
      end

      %w{get post put delete}.each do |method|
        class_eval <<-END_TXT
          def #{method}_subject
            without_files('test.host/zafu') do
              #{method} subject.delete(:action), subject
              if block_given?
                yield
              end
            end
          end
        END_TXT
      end

      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

      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

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zena-1.2.8 lib/zena/controller/test_case.rb
zena-1.2.7 lib/zena/controller/test_case.rb
zena-1.2.6 lib/zena/controller/test_case.rb