Module: RSpec::Apib
- Defined in:
- lib/rspec/apib.rb,
lib/rspec/apib/writer.rb,
lib/rspec/apib/version.rb,
lib/rspec/apib/recorder.rb,
lib/rspec/apib/configuration.rb
Defined Under Namespace
Classes: Configuration, Recorder, Writer
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
16
17
18
|
# File 'lib/rspec/apib.rb', line 16
def config
@config || configure
end
|
10
11
12
13
14
|
# File 'lib/rspec/apib.rb', line 10
def configure
@config = Configuration.new
yield(@config) if block_given?
@config
end
|
.connection ⇒ Object
20
21
22
|
# File 'lib/rspec/apib.rb', line 20
def connection
Connection.instance
end
|
.record(example, request, response, routes) ⇒ Object
39
40
41
42
43
|
# File 'lib/rspec/apib.rb', line 39
def record(example, request, response, routes)
@_doc ||= {}
recorder = Recorder.new(example, request, response, routes, @_doc)
recorder.run
end
|
.start ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/rspec/apib.rb', line 24
def start
types = config.record_types
RSpec.configure do |config|
config.after :each do |example|
if types.include?(example.metadata[:type])
RSpec::Apib.record(example, request, response, @routes)
end
end
config.after :all do |example|
RSpec::Apib.write
end
end
end
|
.write ⇒ Object
45
46
47
48
|
# File 'lib/rspec/apib.rb', line 45
def write
writer = Writer.new(@_doc || {})
writer.write
end
|