scope 0.1.2 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/scope.rb +5 -5
- data/scope.gemspec +1 -1
- 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
|
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
|
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
|
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.
|
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