Skip to content

Commit

Permalink
Merge pull request #1090 from rspec/refactor_pending
Browse files Browse the repository at this point in the history
Refactor: store current_example in a local.
  • Loading branch information
JonRowe committed Oct 1, 2013
2 parents 869d2e5 + 4cd8a41 commit ad3b428
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/rspec/core/pending.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def pending_fixed?; true; end
# # ...
# end
def pending(*args)
return self.class.before(:each) { pending(*args) } unless RSpec.current_example
current_example = RSpec.current_example

return self.class.before(:each) { pending(*args) } unless current_example

options = args.last.is_a?(Hash) ? args.pop : {}
message = args.first || NO_REASON_GIVEN
Expand All @@ -85,17 +87,17 @@ def pending(*args)
return block_given? ? yield : nil
end

RSpec.current_example.metadata[:pending] = true
RSpec.current_example.metadata[:execution_result][:pending_message] = message
current_example.metadata[:pending] = true
current_example.metadata[:execution_result][:pending_message] = message
if block_given?
begin
result = begin
yield
RSpec.current_example.example_group_instance.instance_eval { verify_mocks_for_rspec }
current_example.example_group_instance.instance_eval { verify_mocks_for_rspec }
end
RSpec.current_example.metadata[:pending] = false
current_example.metadata[:pending] = false
rescue Exception => e
RSpec.current_example.execution_result[:exception] = e
current_example.execution_result[:exception] = e
ensure
teardown_mocks_for_rspec
end
Expand Down

0 comments on commit ad3b428

Please sign in to comment.