Sha256: c7ca4c2ce06f0134f88048c3de98b809b28e432fe05ad3b60174d46d9a611104

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

require 'fitting/report/responses'

module Fitting
  module Report
    class Action
      def initialize(action)
        @action = action
        @tests = Fitting::Report::Tests.new([])
        @responses = Fitting::Report::Responses.new(@action.responses)
      end

      def method
        @action.method
      end

      def path
        @action.path.to_s
      end

      attr_reader :responses, :tests

      def add_test(test)
        @tests.push(test)
      end

      def path_match(find_path)
        regexp =~ find_path
      end

      def regexp
        return @regexp if @regexp

        str = Regexp.escape(path)
        str = str.gsub(/\\{\w+\\}/, '[^&=\/]+')
        str = "\\A#{str}\\z"
        @regexp = Regexp.new(str)
      end

      def details
        {
          tests_without_responses: @tests.without_responses,
          responses_details: @responses.to_a.map do |r|
                               { method: r.status, tests_size: r.tests.size, json_schema: r.id,
                                 combinations: r.details }
                             end
        }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fitting-3.0.2 lib/fitting/report/action.rb
fitting-3.0.1 lib/fitting/report/action.rb
fitting-3.0.0 lib/fitting/report/action.rb
fitting-2.18.3 lib/fitting/report/action.rb
fitting-2.18.2 lib/fitting/report/action.rb
fitting-2.18.1 lib/fitting/report/action.rb
fitting-2.18.0 lib/fitting/report/action.rb