7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rspec/versioned.rb', line 7
def self.apply
RSpec.configure do |config|
config.add_setting :notify_version_number, :default => false
config.add_setting :clear_lets_on_failure, :default => true
fetch_current_example = RSpec.respond_to?(:current_example) ?
proc { RSpec.current_example } : proc { |context| context.example }
config.around(:each) do |p| notify_version_number = p.metadata[:notify_version_number] || RSpec.configuration.notify_version_number
run_example = Proc.new do |v, uri|
current_example = fetch_current_example.call(self)
current_example.clear_exceptions
p.metadata[:versioned] = {number:v, uri:uri}
p.run
RSpec.configuration.reporter.message("RSpec::Versioned testing /v#{v}") if notify_version_number
end
if p.metadata.has_key?(:versions)
if p.metadata[:versions][:base_uri] || (VersionedBlocks.base_uri && VersionedBlocks.base_uri!='') versioned_block(p.metadata[:versions]) do |v, uri|
run_example.call v,uri
end
else versioned_block(p.metadata[:versions]) do |v|
run_example.call v
end
end
else p.run
end
self.clear_lets if clear_lets
end
end
end
|