Module: MiniTest::Spec::Magic::Context
- Included in:
- Test::Unit::TestCase
- Defined in:
- lib/minitest/spec/magic/context.rb
Instance Method Summary collapse
-
#described_type ⇒ Class
Returns the test context.
Instance Method Details
#described_type ⇒ Class
Returns the test context. Example:
class UserTest < ActiveSupport::TestCase
self.described_type # => User
describe "something" do
self.described_type # => User, here too
end
end
14 15 16 17 18 19 20 |
# File 'lib/minitest/spec/magic/context.rb', line 14 def described_type @described_type ||= begin klass = self klass = klass.superclass while klass && klass.name !~ /Test$/ klass.name.sub(/Test$/, '').constantize if klass end end |