Class: RSpec::Steps::Describer

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec-steps/describer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_argsObject (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

#hooksObject (readonly)

Returns the value of attribute hooks.



22
23
24
# File 'lib/rspec-steps/describer.rb', line 22

def hooks
  @hooks
end

#let_listObject (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

#metadataObject (readonly)

Returns the value of attribute metadata.



22
23
24
# File 'lib/rspec-steps/describer.rb', line 22

def 
  @metadata
end

#step_listObject (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

#step(*args, &action) ⇒ Object Also known as: when, then, next, it



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rspec-steps/describer.rb', line 24

def step(*args, &action)
   = {}
  if args.last.is_a? Hash
     = args.pop
  end

   = {
    :caller => caller
  }.merge()

  @step_list << Step.new(, args, action)
end