Sha256: 2016c6f419f1be6449d4830b1e8223d312c12ea54ba9fc3c5d75be19dd187342
Contents?: true
Size: 1005 Bytes
Versions: 6
Compression:
Stored size: 1005 Bytes
Contents
module Hermes # Add context support to AS::TestCase. module Context def context_list @@context_list ||= [] end def context_buffer @context_buffer ||= [] end def test(name) super("#{self.context_buffer.join(" ")} #{name}".strip) end def context(name, &block) klass = Class.new(self) klass.context_buffer.concat self.context_buffer klass.context_buffer << name # Care about Rails tests in nested contexts # Extracted this from github.com/jm/context klass.tests($1.constantize) if self < ActiveSupport::TestCase && self.name =~ /^(.*(Controller|Helper|Mailer))Test/ # Undefine parent methods so they don't get executed twice klass.instance_methods.grep(/^test_/).each { |m| klass.send(:undef_method, m) } klass.class_eval(&block) self.context_list << klass Object.const_set("TestContext#{name.camelize.gsub(/\W/,'')}#{klass.object_id.abs}", klass) klass end end end
Version data entries
6 entries across 6 versions & 1 rubygems