Class: ApiBomb::Path::Single
- Inherits:
-
Object
- Object
- ApiBomb::Path::Single
- Defined in:
- lib/api_bomb/path.rb
Constant Summary collapse
- HTTP_METHODS =
[:get, :post, :put, :patch, :delete, :head].freeze
Instance Method Summary collapse
- #action ⇒ Object
-
#initialize(path:, action: :get, options: {}) ⇒ Single
constructor
A new instance of Single.
- #options ⇒ Object
- #params_report ⇒ Object
- #path ⇒ Object
- #path_report(base_url = '') ⇒ Object
- #pick ⇒ Object
- #report(base_url) ⇒ Object
Constructor Details
#initialize(path:, action: :get, options: {}) ⇒ Single
Returns a new instance of Single.
20 21 22 23 24 25 |
# File 'lib/api_bomb/path.rb', line 20 def initialize(path:, action: :get, options: {}) @path = path @action = action @action = :get if not HTTP_METHODS.include?(action.downcase.to_sym) @options = ApiBomb::LambdaHash.new() end |
Instance Method Details
#action ⇒ Object
60 61 62 63 |
# File 'lib/api_bomb/path.rb', line 60 def action return @action.call if @action.respond_to? :call return @action end |
#options ⇒ Object
65 66 67 |
# File 'lib/api_bomb/path.rb', line 65 def @options end |
#params_report ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/api_bomb/path.rb', line 45 def params_report return '' unless [:params] if .is_lambda? " with random params like: #{ApiBomb::LambdaHash.hasharize()[:params]}" else " with params: #{[:params]}" end end |
#path ⇒ Object
55 56 57 58 |
# File 'lib/api_bomb/path.rb', line 55 def path return @path.call if @path.respond_to? :call return @path end |
#path_report(base_url = '') ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/api_bomb/path.rb', line 35 def path_report(base_url = '') base_url = [:base_url] if [:base_url] if @path.respond_to? :call "testing random paths like #{action.to_s.upcase} #{URI::join(base_url, path)}" else "testing path #{action.to_s.upcase} #{URI::join(base_url, path)}" end end |
#pick ⇒ Object
27 28 29 |
# File 'lib/api_bomb/path.rb', line 27 def pick return self end |
#report(base_url) ⇒ Object
31 32 33 |
# File 'lib/api_bomb/path.rb', line 31 def report(base_url) path_report(base_url) + params_report end |