Class: RSpec::Clone::Dsl Private
- Inherits:
-
Object
- Object
- RSpec::Clone::Dsl
- Defined in:
- lib/r_spec/clone/dsl.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Abstract class for handling the domain-specific language.
Class Method Summary collapse
-
.after(&block) ⇒ Object
Executes the given block after each spec in the current context runs.
-
.before(&block) ⇒ Object
Executes the given block before each spec in the current context runs.
-
.context(_description, &block) ⇒ Object
Defines an example group that establishes a specific context, like _empty array_ versus _array with elements_.
-
.describe(const, &block) ⇒ Object
Defines an example group that describes a unit to be tested.
-
.it(_name = nil, &block) ⇒ nil
Defines a concrete test case.
-
.its(attribute, *args, **kwargs, &block) ⇒ nil
Defines a single concrete test case that specifies the actual value of an attribute of the subject using ExpectationHelper::Its#is_expected.
-
.let(name, *args, **kwargs, &block) ⇒ Symbol
Sets a user-defined property.
-
.pending(message) ⇒ nil
Defines a pending test case.
-
.subject(&block) ⇒ Symbol
Sets a user-defined property named #subject.
Class Method Details
.after(&block) ⇒ Object
Executes the given block after each spec in the current context runs.
76 77 78 79 80 81 82 83 |
# File 'lib/r_spec/clone/dsl.rb', line 76 def self.after(&block) define_method(AFTER_METHOD) do instance_exec(&block) super() end private AFTER_METHOD end |
.before(&block) ⇒ Object
Executes the given block before each spec in the current context runs.
47 48 49 50 51 52 53 54 |
# File 'lib/r_spec/clone/dsl.rb', line 47 def self.before(&block) define_method(BEFORE_METHOD) do super() instance_eval(&block) end private BEFORE_METHOD end |
.context(_description, &block) ⇒ Object
Defines an example group that establishes a specific context, like _empty array_ versus _array with elements_.
201 202 203 204 |
# File 'lib/r_spec/clone/dsl.rb', line 201 def self.context(_description, &block) desc = ::Class.new(self) desc.instance_eval(&block) end |
.describe(const, &block) ⇒ Object
Defines an example group that describes a unit to be tested.
168 169 170 171 172 |
# File 'lib/r_spec/clone/dsl.rb', line 168 def self.describe(const, &block) desc = ::Class.new(self) desc.let(:described_class) { const } if const.is_a?(::Module) desc.instance_eval(&block) end |
.it(_name = nil, &block) ⇒ nil
248 249 250 |
# File 'lib/r_spec/clone/dsl.rb', line 248 def self.it(_name = nil, &block) exit false unless ::Aw.fork? { run(example_without_attribute.new, &block) } end |
.its(attribute, *args, **kwargs, &block) ⇒ nil
Defines a single concrete test case that specifies the actual value of an attribute of the subject using ExpectationHelper::Its#is_expected.
300 301 302 |
# File 'lib/r_spec/clone/dsl.rb', line 300 def self.its(attribute, *args, **kwargs, &block) exit false unless ::Aw.fork? { run(example_with_attribute(attribute, *args, **kwargs).new, &block) } end |
.let(name, *args, **kwargs, &block) ⇒ Symbol
Sets a user-defined property.
112 113 114 115 116 |
# File 'lib/r_spec/clone/dsl.rb', line 112 def self.let(name, *args, **kwargs, &block) raise Error::ReservedMethod if [BEFORE_METHOD, AFTER_METHOD].include?(name.to_sym) private define_method(name, *args, **kwargs, &block) end |
.pending(message) ⇒ nil
Defines a pending test case.
`&block` is never evaluated. It can be used to describe behaviour that is not yet implemented.
331 332 333 |
# File 'lib/r_spec/clone/dsl.rb', line 331 def self.pending() Console.passed_spec Error::PendingExpectation.result() end |
.subject(&block) ⇒ Symbol
Sets a user-defined property named #subject.
146 147 148 |
# File 'lib/r_spec/clone/dsl.rb', line 146 def self.subject(&block) let(__method__, &block) end |