类: RSpec::Core::SharedExampleGroupModule
- 继承
-
模块
- 对象
- 模块
- RSpec::Core::SharedExampleGroupModule
- 定义于
- lib/rspec/core/shared_example_group.rb
概述
表示一些与多个示例组共享的功能。此功能由提供的代码块定义,该代码块在将 SharedExampleGroupModule
实例包含在示例组中时会延迟求值。
实例方法摘要 折叠
-
#included(klass) ⇒ void
当模块包含在另一个模块或类中时,Ruby 的回调。
-
#initialize(description, definition, metadata) ⇒ SharedExampleGroupModule 构造函数
SharedExampleGroupModule 的新实例。
-
#inspect ⇒ void (also: #to_s)
提供此模块的可读表示形式。
构造函数详情
#initialize(description, definition, metadata) ⇒SharedExampleGroupModule
返回一个新的 SharedExampleGroupModule 实例。
13 14 15 16 17 |
# File 'lib/rspec/core/shared_example_group.rb', line 13 def initialize(description, definition, ) @description = description @definition = definition @metadata = end |
实例方法详情
#included(klass) ⇒void
当模块包含在另一个模块或类中时,Ruby 的回调。我们的定义在包含示例组的上下文中评估共享组代码块。
28 29 30 31 |
# File 'lib/rspec/core/shared_example_group.rb', line 28 def included(klass) inclusion_line = klass.[:location] include_in klass, inclusion_line, [], nil end |
#inspect ⇒void 也称为: to_s
提供此模块的可读表示形式。
20 21 22 |
# File 'lib/rspec/core/shared_example_group.rb', line 20 def inspect "#<#{self.class.name} #{@description.inspect}>" end |