Sha256: 17b398b6839ab13ccfefb2468f623b0cc607581530940fade2e66a00a7beed74

Contents?: true

Size: 925 Bytes

Versions: 3

Compression:

Stored size: 925 Bytes

Contents

require 'rspec/core/formatters/base_formatter'
require 'yaml'
require 'fitting/storage/yaml_file'
require 'fitting/report/response/macro'

module Fitting
  module Formatter
    module Response
      class MacroYaml < RSpec::Core::Formatters::BaseFormatter
        RSpec::Core::Formatters.register self, :start, :stop

        def start(_notification)
          Fitting::Storage::YamlFile.craft
        end

        def stop(_notification)
          tests = Fitting::Storage::YamlFile.load
          Fitting::Storage::YamlFile.destroy

          if tests
            report = Report::Response::Macro.new(tests).to_hash
          else
            report = 'no tests controllers'
          end
          craft_json(report)
        end

        def craft_json(report)
          File.open('report_response_macro.yaml', 'w') do |file|
            file.write(YAML.dump(report))
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fitting-0.4.2 lib/fitting/formatter/response/macro_yaml.rb
fitting-0.4.1 lib/fitting/formatter/response/macro_yaml.rb
fitting-0.3.0 lib/fitting/formatter/response/macro_yaml.rb