Module: RSpec::Core::DSL
- Defined in:
- lib/rspec/core/dsl.rb
Overview
DSL defines methods to group examples, most notably describe
,
and exposes them as class methods of RSpec. They can also be
exposed globally (on main
and instances of Module
) through
the Configuration option expose_dsl_globally
.
By default the methods describe
, context
and example_group
are exposed. These methods define a named context for one or
more examples. The given block is evaluated in the context of
a generated subclass of ExampleGroup.
Examples:
RSpec.describe "something" do
context "when something is a certain way" do
it "does something" do
# example code goes here
end
end
end
Class Method Summary collapse
-
.expose_globally! ⇒ void
private
Adds the describe method to Module and the top level binding.
-
.remove_globally! ⇒ void
private
Removes the describe method from Module and the top level binding.
Class Method Details
.expose_globally! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds the describe method to Module and the top level binding.
58 59 60 61 62 63 64 65 66 |
# File 'lib/rspec/core/dsl.rb', line 58 def self.expose_globally! return if exposed_globally? example_group_aliases.each do |method_name| expose_example_group_alias_globally(method_name) end @exposed_globally = true end |
.remove_globally! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes the describe method from Module and the top level binding.
70 71 72 73 74 75 76 77 78 |
# File 'lib/rspec/core/dsl.rb', line 70 def self.remove_globally! return unless exposed_globally? example_group_aliases.each do |method_name| change_global_dsl { undef_method method_name } end @exposed_globally = false end |