Module: RSpec::ExampleSteps::ExampleGroup

Defined in:
lib/rspec/example_steps/example_group.rb

Instance Method Summary collapse

Instance Method Details

#And(message, options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rspec/example_steps/example_group.rb', line 56

def And(message, options = {})
  RSpec.world.reporter.example_step_started(self, :and, message, options)
  if block_given? && !options[:pending]
    begin
      yield
    rescue Exception => e
      RSpec.world.reporter.example_step_failed(self, :and, message, options)
      raise e
    end
    RSpec.world.reporter.example_step_passed(self, :and, message, options)
  else
    RSpec.world.reporter.example_step_pending(self, :and, message, options)
  end
end

#But(message, options = {}) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rspec/example_steps/example_group.rb', line 71

def But(message, options = {})
  RSpec.world.reporter.example_step_started(self, :but, message, options)
  if block_given? && !options[:pending]
    begin
      yield
    rescue Exception => e
      RSpec.world.reporter.example_step_failed(self, :but, message, options)
      raise e
    end
    RSpec.world.reporter.example_step_passed(self, :but, message, options)
  else
    RSpec.world.reporter.example_step_pending(self, :but, message, options)
  end
end

#Given(message, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rspec/example_steps/example_group.rb', line 11

def Given(message, options = {})
  RSpec.world.reporter.example_step_started(self, :given, message, options)
  if block_given? && !options[:pending]
    begin
      yield
    rescue Exception => e
      RSpec.world.reporter.example_step_failed(self, :given, message, options)
      raise e
    end
    RSpec.world.reporter.example_step_passed(self, :given, message, options)
  else
    RSpec.world.reporter.example_step_pending(self, :given, message, options)
  end
end

#include_steps(*args) ⇒ Object



4
5
6
7
8
9
# File 'lib/rspec/example_steps/example_group.rb', line 4

def include_steps(*args)
  name = args.shift 
  shared_block = RSpec.world.shared_example_steps[name]
  shared_block or raise ArgumentError, "Could not find shared steps #{name.inspect}"
  instance_eval_with_args(*args, &shared_block)
end

#Then(message, options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rspec/example_steps/example_group.rb', line 41

def Then(message, options = {})
  RSpec.world.reporter.example_step_started(self, :then, message, options)
  if block_given? && !options[:pending]
    begin
      yield
    rescue Exception => e
      RSpec.world.reporter.example_step_failed(self, :then, message, options)
      raise e
    end
    RSpec.world.reporter.example_step_passed(self, :then, message, options)
  else
    RSpec.world.reporter.example_step_pending(self, :then, message, options)
  end
end

#When(message, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rspec/example_steps/example_group.rb', line 26

def When(message, options = {})
  RSpec.world.reporter.example_step_started(self, :when, message, options)
  if block_given? && !options[:pending]
    begin
      yield
    rescue Exception => e
      RSpec.world.reporter.example_step_failed(self, :when, message, options)
      raise e
    end
    RSpec.world.reporter.example_step_passed(self, :when, message, options)
  else
    RSpec.world.reporter.example_step_pending(self, :when, message, options)
  end
end