Module: Spec::Example::BeforeAndAfterHooks

Included in:
ExampleGroupMethods
Defined in:
lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.after_suite_partsObject



9
10
11
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 9

def after_suite_parts
  @after_suite_parts ||= []
end

.before_suite_partsObject



5
6
7
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 5

def before_suite_parts
  @before_suite_parts ||= []
end

Instance Method Details

#after_all_partsObject

:nodoc:



59
60
61
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 59

def after_all_parts # :nodoc:
  @after_all_parts ||= []
end

#after_each_partsObject

:nodoc:



67
68
69
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 67

def after_each_parts # :nodoc:
  @after_each_parts ||= []
end

#after_suite_partsObject



75
76
77
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 75

def after_suite_parts
  BeforeAndAfterHooks.after_suite_parts
end

#append_after(*args, &block) ⇒ Object

Registers a block to be executed after each example. This method appends block to existing after blocks.



36
37
38
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 36

def append_after(*args, &block)
  after_parts(*args) << block
end

#append_before(*args, &block) ⇒ Object Also known as: before

Registers a block to be executed before each example. This method appends block to existing before blocks.



22
23
24
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 22

def append_before(*args, &block)
  before_parts(*args) << block
end

#before_all_partsObject

:nodoc:



55
56
57
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 55

def before_all_parts # :nodoc:
  @before_all_parts ||= []
end

#before_each_partsObject

:nodoc:



63
64
65
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 63

def before_each_parts # :nodoc:
  @before_each_parts ||= []
end

#before_suite_partsObject



71
72
73
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 71

def before_suite_parts
  BeforeAndAfterHooks.before_suite_parts
end

#prepend_after(*args, &block) ⇒ Object Also known as: after

Registers a block to be executed after each example. This method prepends block to existing after blocks.



29
30
31
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 29

def prepend_after(*args, &block)
  after_parts(*args).unshift(block)
end

#prepend_before(*args, &block) ⇒ Object

Registers a block to be executed before each example. This method prepends block to existing before blocks.



16
17
18
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 16

def prepend_before(*args, &block)
  before_parts(*args).unshift(block)
end

#remove_after(scope, &block) ⇒ Object

TODO - deprecate this unless there is a reason why it exists



41
42
43
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 41

def remove_after(scope, &block) # :nodoc:
  after_each_parts.delete(block)
end

#setup(&block) ⇒ Object

Deprecated. Use before(:each)



46
47
48
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 46

def setup(&block)
  before(:each, &block)
end

#teardown(&block) ⇒ Object

Deprecated. Use after(:each)



51
52
53
# File 'lib/gems/rspec-1.1.12/lib/spec/example/before_and_after_hooks.rb', line 51

def teardown(&block)
  after(:each, &block)
end