Sha256: 85cdb1b4172e818f4f57e903dcab221106ba6cb99d93e4d265fb125f9ff02f7d

Contents?: true

Size: 1.31 KB

Versions: 20

Compression:

Stored size: 1.31 KB

Contents

require 'tomograph/path'
require 'fitting/records/tested/response'
require 'fitting/records/spherical/request'

module Fitting
  class Records
    class Tested
      class Request
        def initialize(env_response, test_title)
          @env_response = env_response
          @test_title = test_title
        end

        def method
          @method ||= @env_response.request.request_method
        end

        def path
          @path ||= Tomograph::Path.new(@env_response.request.env['PATH_INFO'] || @env_response.request.fullpath)
        end

        def body
          @body ||= @env_response.request.env['action_dispatch.request.request_parameters']
        end

        def response
          @response ||= Fitting::Records::Tested::Response.new(@env_response)
        end

        def test_path
          @test_path ||= @test_title[/#{'\(\.'}(.*?)#{'\)'}/m, 1] || @test_title[/#{'\.'}(.*?)#{'\"'}/m, 1]
        end

        def test_file_path
          @test_file_path ||= test_path.split(':').first
        end

        def to_spherical
          Fitting::Records::Spherical::Request.new(
            method: method,
            path: path,
            body: body,
            response: response.to_spherical,
            title: test_path,
            group: test_file_path
          )
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
fitting-2.17.0 lib/fitting/records/tested/request.rb
fitting-2.16.1 lib/fitting/records/tested/request.rb
fitting-2.16.0 lib/fitting/records/tested/request.rb
fitting-2.15.0 lib/fitting/records/tested/request.rb
fitting-2.14.1 lib/fitting/records/tested/request.rb
fitting-2.14.0 lib/fitting/records/tested/request.rb
fitting-2.13.1 lib/fitting/records/tested/request.rb
fitting-2.13.0 lib/fitting/records/tested/request.rb
fitting-2.12.1 lib/fitting/records/tested/request.rb
fitting-2.12.0 lib/fitting/records/tested/request.rb
fitting-2.11.0 lib/fitting/records/tested/request.rb
fitting-2.10.0 lib/fitting/records/tested/request.rb
fitting-2.9.1 lib/fitting/records/tested/request.rb
fitting-2.9.0 lib/fitting/records/tested/request.rb
fitting-2.8.1 lib/fitting/records/tested/request.rb
fitting-2.8.0 lib/fitting/records/tested/request.rb
fitting-2.7.2 lib/fitting/records/tested/request.rb
fitting-2.7.1 lib/fitting/records/tested/request.rb
fitting-2.7.0 lib/fitting/records/tested/request.rb
fitting-2.6.0 lib/fitting/records/tested/request.rb