Sha256: bd8e0358b44aca292a99b44c89c2657a68c5525fd04734bf13747058f5f6cfbc

Contents?: true

Size: 1.52 KB

Versions: 8

Compression:

Stored size: 1.52 KB

Contents

require 'fitting/version'
require 'fitting/configuration'
require 'fitting/matchers/response_matcher'
require 'fitting/documentation'
require 'fitting/storage/responses'
require 'fitting/railtie' if defined?(Rails)

module Fitting
  class << self
    def configure
      yield configuration
    end

    def configuration
      @configuration ||= Configuration.craft
    end

    def statistics
      puts 'DEPRECATED: deprecated method statistics, use new method save_test_data'
      responses = Fitting::Storage::Responses.new

      RSpec.configure do |config|
        config.after(:each, type: :controller) do
          responses.add(response, inspect)
        end

        config.after(:suite) do
          responses.statistics.save
        end
      end
    end

    def save_test_data
      responses = Fitting::Storage::Responses.new

      FileUtils.rm_r Dir.glob("fitting_tests/*"), :force => true

      RSpec.configure do |config|
        config.after(:each, type: :request) do
          responses.add(response, inspect)
        end

        config.after(:each, type: :controller) do
          responses.add(response, inspect)
        end

        config.after(:suite) do
          responses.tests.save
        end
      end
    end
  end

  def self.loaded_tasks=(val)
    @loaded_tasks = val
  end

  def self.loaded_tasks
    @loaded_tasks
  end

  def self.load_tasks
    return if loaded_tasks
    self.loaded_tasks = true

    Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each do |rake|
      load rake
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fitting-2.17.0 lib/fitting.rb
fitting-2.16.1 lib/fitting.rb
fitting-2.16.0 lib/fitting.rb
fitting-2.15.0 lib/fitting.rb
fitting-2.14.1 lib/fitting.rb
fitting-2.14.0 lib/fitting.rb
fitting-2.13.1 lib/fitting.rb
fitting-2.13.0 lib/fitting.rb