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.
-
#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
-
#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 |
# 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 = [] instance_eval(&block) end |
Instance Attribute Details
#group_args ⇒ Object (readonly)
Returns the value of attribute group_args.
22 23 24 |
# File 'lib/rspec-steps/describer.rb', line 22 def group_args @group_args end |
#hooks ⇒ Object (readonly)
Returns the value of attribute hooks.
22 23 24 |
# File 'lib/rspec-steps/describer.rb', line 22 def hooks @hooks end |
#let_list ⇒ Object (readonly)
Returns the value of attribute let_list.
22 23 24 |
# File 'lib/rspec-steps/describer.rb', line 22 def let_list @let_list end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
22 23 24 |
# File 'lib/rspec-steps/describer.rb', line 22 def @metadata end |
#step_list ⇒ Object (readonly)
Returns the value of attribute step_list.
22 23 24 |
# File 'lib/rspec-steps/describer.rb', line 22 def step_list @step_list end |
Instance Method Details
#after(kind = :all, &callback) ⇒ Object
70 71 72 |
# File 'lib/rspec-steps/describer.rb', line 70 def after(kind = :all, &callback) @hooks << Hook.new(:after, kind, callback) end |
#around(kind = :all, &callback) ⇒ Object
74 75 76 |
# File 'lib/rspec-steps/describer.rb', line 74 def around(kind = :all, &callback) @hooks << Hook.new(:around, kind, callback) end |
#before(kind = :all, &callback) ⇒ Object
66 67 68 |
# File 'lib/rspec-steps/describer.rb', line 66 def before(kind = :all, &callback) @hooks << Hook.new(:before, kind, callback) end |
#let(name, &block) ⇒ Object
54 55 56 |
# File 'lib/rspec-steps/describer.rb', line 54 def let(name, &block) @let_list << Let.new(name, block) end |
#let!(name, &block) ⇒ Object
58 59 60 |
# File 'lib/rspec-steps/describer.rb', line 58 def let!(name, &block) @let_list << LetBang.new(name, block) end |
#perform_steps(name) ⇒ Object
48 49 50 51 52 |
# File 'lib/rspec-steps/describer.rb', line 48 def perform_steps(name) describer = SharedSteps.fetch(name) @hooks += describer.hooks @step_list += describer.step_list end |
#shared_steps(*args, &block) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/rspec-steps/describer.rb', line 41 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
62 63 64 |
# File 'lib/rspec-steps/describer.rb', line 62 def skip(*args) #noop end |