lib/rspec/apib.rb in rspec-apib-0.4.0 vs lib/rspec/apib.rb in rspec-apib-0.5.0

- old
+ new

@@ -1,8 +1,9 @@ require 'rails' require 'rspec/apib/version' require 'rspec/apib/configuration' +require 'rspec/apib/comments_parser' require 'rspec/apib/recorder' require 'rspec/apib/writer' module RSpec module Apib @@ -20,15 +21,13 @@ def connection Connection.instance end def start - types = config.record_types RSpec.configure do |config| config.after :each do |example| - if types.include?(example.metadata[:type]) && - !(example.metadata[:apib] === false) + if RSpec::Apib.record?(example) RSpec::Apib.record(example, request, response, @routes) end end config.after :all do |example| @@ -44,9 +43,18 @@ end def write writer = Writer.new(@_doc || {}) writer.write + end + + def record?(example) + default_recording_policy = config.default_recording_policy + config.record_types.include?(example.metadata[:type]) && + ( + default_recording_policy && !(example.metadata[:apib] === false) || + !default_recording_policy && (example.metadata[:apib] === true) + ) end end end end