module Test::Unit::Context::Shared
Public Instance Methods
like(shared_name)
click to toggle source
Pull in behavior shared by shared
or a module.
Examples¶ ↑
shared "awesome things" do test "does some thing" do # some-thing is awesome end end like "awesome things" module AwesomeThings # ... end uses AwesomeThings
# File lib/test/unit/context/shared.rb, line 82 def like(shared_name) case shared_name when String, Symbol const_name = Helpers.to_const_name(shared_name.to_s) if Behavior.const_defined?(const_name) const = Behavior.const_get(const_name) if Behavior === const include const else raise "#{shared_name.inspect} does not resolve into a shared " << "behavior instance but to a #{const.inspect}" end else raise "shared behavior with name #{shared_name.inspect} not defined" end when Behavior, Module include shared_name else raise ArgumentError, "pass a String or Symbol as the name e.g. " + "`like #{shared_name.to_s.inspect} do ...`" end end
Also aliased as: m