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

#hooksObject (readonly)

Returns the value of attribute hooks.



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

def hooks
  @hooks
end

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

#metadataObject (readonly)

Returns the value of attribute metadata.



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

def 
  @metadata
end

#modulesObject (readonly)

Returns the value of attribute modules.



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

def modules
  @modules
end

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

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



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

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

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

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