Sha256: e925250cbe3c1ad82955ca1eb5d57f97770c458121f02a4cb5d3927473d8b655

Contents?: true

Size: 507 Bytes

Versions: 1

Compression:

Stored size: 507 Bytes

Contents

module Rack
  module MockJson
    class Mock
      def initialize(config_file_path)
        @config = YAML.load_file(config_file_path)
      end

      def mock_element(path)
        element = @config.find { |e| path.match(/#{e["request_path"]}/).present? }
        return nil if element.blank?

        Element.new(
          request_path: element['request_path'],
          contents: element['contents'],
          status: element['status'] ? element['status'] : 200
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-mock_json-0.0.3 lib/rack/mock_json/mock.rb