Sha256: 2ec77c8998c38cc21e110f7e8d2caf63d88389a97463a186f2e3763a5758e47f
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'tomograph/path' module Tomograph class Tomogram class Action attr_reader :path, :method, :request, :responses def initialize(path:, method:, request:, responses:) @path ||= Tomograph::Path.new(path) @method ||= method @request ||= request @responses ||= responses end def self.merge(actions) actions.group_by { |action| "#{action.method} #{action.path}" }.map do |_key, related_actions| new( path: related_actions.first.path.to_s, method: related_actions.first.method, request: related_actions.first.request, responses: related_actions.map(&:responses).flatten ) end.flatten end def add_prefix(prefix) @path = Tomograph::Path.new("#{prefix}#{path}") self end def find_responses(status:) to_hash['responses'].find_all do |response| response['status'] == status.to_s end end def to_hash @action ||= { 'path' => path, 'method' => method, 'request' => request, 'responses' => responses } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tomograph-1.0.0 | lib/tomograph/tomogram/action.rb |