Class: RSpec::Steps::Describer
- Inherits:
-
Object
- Object
- RSpec::Steps::Describer
- Defined in:
- lib/rspec-steps/describer.rb
Instance Attribute Summary collapse
-
#group_args ⇒ Object
readonly
Returns the value of attribute group_args.
-
#hooks ⇒ Object
readonly
Returns the value of attribute hooks.
-
#let_list ⇒ Object
readonly
Returns the value of attribute let_list.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
-
#step_list ⇒ Object
readonly
Returns the value of attribute step_list.
Instance Method Summary collapse
- #after(kind = :all, &callback) ⇒ Object
- #around(kind = :all, &callback) ⇒ Object
- #before(kind = :all, &callback) ⇒ Object
- #extend(mod) ⇒ Object
- #include(mod) ⇒ Object
-
#initialize(args, metadata, &block) ⇒ Describer
constructor
A new instance of Describer.
- #let(name, &block) ⇒ Object
- #let!(name, &block) ⇒ Object
- #perform_steps(name) ⇒ Object
- #shared_steps(*args, &block) ⇒ Object
- #skip(*args) ⇒ Object
- #step(*args, &action) ⇒ Object (also: #when, #then, #next, #it)
Constructor Details
#initialize(args, metadata, &block) ⇒ Describer
Returns a new instance of Describer.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rspec-steps/describer.rb', line 10 def initialize(args, , &block) @group_args = args @metadata = {} if @group_args.last.is_a? Hash @metadata = @group_args.pop end @metadata = .merge(@metadata) @step_list = StepList.new @hooks = [] @let_list = [] @modules = [] instance_eval(&block) end |
Instance Attribute Details
#group_args ⇒ Object (readonly)
Returns the value of attribute group_args.
23 24 25 |
# File 'lib/rspec-steps/describer.rb', line 23 def group_args @group_args end |
#hooks ⇒ Object (readonly)
Returns the value of attribute hooks.
23 24 25 |
# File 'lib/rspec-steps/describer.rb', line 23 def hooks @hooks end |
#let_list ⇒ Object (readonly)
Returns the value of attribute let_list.
23 24 25 |
# File 'lib/rspec-steps/describer.rb', line 23 def let_list @let_list end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
23 24 25 |
# File 'lib/rspec-steps/describer.rb', line 23 def @metadata end |
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
23 24 25 |
# File 'lib/rspec-steps/describer.rb', line 23 def modules @modules end |
#step_list ⇒ Object (readonly)
Returns the value of attribute step_list.
23 24 25 |
# File 'lib/rspec-steps/describer.rb', line 23 def step_list @step_list end |
Instance Method Details
#after(kind = :all, &callback) ⇒ Object
81 82 83 |
# File 'lib/rspec-steps/describer.rb', line 81 def after(kind = :all, &callback) @hooks << Hook.new(:after, kind, callback) end |
#around(kind = :all, &callback) ⇒ Object
85 86 87 |
# File 'lib/rspec-steps/describer.rb', line 85 def around(kind = :all, &callback) @hooks << Hook.new(:around, kind, callback) end |
#before(kind = :all, &callback) ⇒ Object
77 78 79 |
# File 'lib/rspec-steps/describer.rb', line 77 def before(kind = :all, &callback) @hooks << Hook.new(:before, kind, callback) end |
#extend(mod) ⇒ Object
53 54 55 |
# File 'lib/rspec-steps/describer.rb', line 53 def extend(mod) @modules << ModuleExtension.new(mod) end |
#include(mod) ⇒ Object
49 50 51 |
# File 'lib/rspec-steps/describer.rb', line 49 def include(mod) @modules << ModuleInclusion.new(mod) end |
#let(name, &block) ⇒ Object
65 66 67 |
# File 'lib/rspec-steps/describer.rb', line 65 def let(name, &block) @let_list << Let.new(name, block) end |
#let!(name, &block) ⇒ Object
69 70 71 |
# File 'lib/rspec-steps/describer.rb', line 69 def let!(name, &block) @let_list << LetBang.new(name, block) end |
#perform_steps(name) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/rspec-steps/describer.rb', line 57 def perform_steps(name) describer = SharedSteps.fetch(name) @modules += describer.modules @let_list += describer.let_list @hooks += describer.hooks @step_list += describer.step_list end |
#shared_steps(*args, &block) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/rspec-steps/describer.rb', line 42 def shared_steps(*args, &block) name = args.first raise "shared step lists need a String for a name" unless name.is_a? String raise "there is already a step list named #{name}" if SharedSteps.has_key?(name) SharedSteps[name] = Describer.new(args, {:caller => caller}, &block) end |
#skip(*args) ⇒ Object
73 74 75 |
# File 'lib/rspec-steps/describer.rb', line 73 def skip(*args) #noop end |