scope 0.1.2 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/scope.rb +5 -5
  2. data/scope.gemspec +1 -1
  3. metadata +2 -3
data/lib/scope.rb CHANGED
@@ -103,8 +103,8 @@ module Scope
103
103
  # the actual test method), and then completes the teardown work.
104
104
  def run_setup_and_teardown(test_case_instance, test_name)
105
105
  contexts = ([self] + ancestor_contexts).reverse
106
- contexts.each { |context| context.setup_once.call if context.setup_once }
107
106
  # We're using instance_eval so that instance vars set by the block are created on the test_case_instance
107
+ contexts.each { |context| test_case_instance.instance_eval(&context.setup_once) if context.setup_once }
108
108
  contexts.each { |context| test_case_instance.instance_eval(&context.setup) if context.setup }
109
109
  yield
110
110
  contexts.reverse!
@@ -112,11 +112,11 @@ module Scope
112
112
 
113
113
  # If this is the last context being run in any parent contexts, run their teardown_once blocks.
114
114
  if tests_and_subcontexts.last == test_name
115
- teardown_once.call if teardown_once
115
+ test_case_instance.instance_eval(&teardown_once) if teardown_once
116
116
  descendant_context = self
117
117
  ancestor_contexts.each do |ancestor|
118
118
  break unless ancestor.tests_and_subcontexts.last == descendant_context
119
- ancestor.teardown_once.call if ancestor.teardown_once
119
+ test_case_instance.instance_eval(&ancestor.teardown_once) if ancestor.teardown_once
120
120
  descendant_context = ancestor
121
121
  end
122
122
  end
@@ -135,7 +135,7 @@ module Scope
135
135
  private
136
136
  def run_only_once(block)
137
137
  has_run = false
138
- Proc.new { block.call unless has_run; has_run = true }
138
+ Proc.new { instance_eval(&block) unless has_run; has_run = true }
139
139
  end
140
140
  end
141
- end
141
+ end
data/scope.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "scope"
3
- s.version = "0.1.2"
3
+ s.version = "0.2"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">=0") if s.respond_to? :required_rubygems_version=
6
6
  s.specification_version = 2 if s.respond_to? :specification_version=
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scope
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.1.2
9
+ version: "0.2"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Phil Crosby