apirunner 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.6
1
+ 0.3.7
data/apirunner.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{apirunner}
8
- s.version = "0.3.6"
8
+ s.version = "0.3.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jan@moviepilot.com"]
@@ -51,6 +51,7 @@ Gem::Specification.new do |s|
51
51
  "lib/plugins/plug02_response_code_checker.rb",
52
52
  "lib/plugins/plug03_response_header_checker.rb",
53
53
  "lib/plugins/plug04_response_body_checker.rb",
54
+ "lib/plugins/plug05_response_time_checker.rb",
54
55
  "lib/result.rb",
55
56
  "lib/string_ext.rb",
56
57
  "lib/tasks/api.rake",
data/lib/http_client.rb CHANGED
@@ -21,7 +21,6 @@ class HttpClient
21
21
  # returns struct containing response.code, headers, body and message
22
22
  # this is only for easily interfaceing another http client
23
23
  def build_response(raw_response, runtime, method, resource, params)
24
- end_time = Time.now.usec
25
24
  response_struct = Struct.new(:code, :message, :headers, :body, :runtime, :fully_qualified_path)
26
25
  response = response_struct.new
27
26
  response.code = raw_response.code
@@ -0,0 +1,19 @@
1
+ class ResponseTimeChecker < Checker
2
+
3
+ # checks if the request response cycle exceeded the maximum expected time
4
+ def check
5
+ result = Result.new(@testcase, @response)
6
+ begin
7
+ if not (@testcase.response_expectation['runtime'].nil? || @response.runtime.to_f <= @testcase.response_expectation['runtime'].to_f)
8
+ result.succeeded = false
9
+ result.error_message = " expected request->response runtime was #{@testcase.response_expectation['runtime']}, real runtime was #{@response.runtime}"
10
+ end
11
+ rescue Exception => e
12
+ result.succeeded = false
13
+ result.error_message = " unexpected error while parsing testcase/response. Check your testcase format!"
14
+ result.error_message = "\n\nException occured: #{e}"
15
+ end
16
+ result
17
+ end
18
+
19
+ end
@@ -30,16 +30,18 @@ describe 'http_client' do
30
30
  end
31
31
  describe 'build_response' do
32
32
  it 'should return a struct consisting of 4 symbols: :code, :message, :headers and :body with right types' do
33
- raw_response_struct = Struct.new(:code, :message, :headers, :body)
33
+ raw_response_struct = Struct.new(:code, :message, :headers, :body, :runtime, :fully_qualified_path)
34
34
  response = raw_response_struct.new
35
35
  response.code = 404
36
36
  response.message = "Hi Duffy Duck"
37
37
  response.headers = { :daisy => "duck" }
38
38
  response.body = { :duffy => "duck" }
39
- @http_client.send(:build_response, response).code.should_not be_nil
40
- @http_client.send(:build_response, response).message.should_not be_nil
41
- @http_client.send(:build_response, response).body.should == {:duffy => "duck"}
42
- @http_client.send(:build_response, response).headers.should == {"daisy" => "duck"}
39
+ response.runtime = 0.123456789
40
+ response.fully_qualified_path = "/path/to/resource"
41
+ @http_client.send(:build_response, response, 0.0, "GET", "resource", {}).code.should_not be_nil
42
+ @http_client.send(:build_response, response, 0.0, "GET", "resource", {}).message.should_not be_nil
43
+ @http_client.send(:build_response, response, 0.0, "GET", "resource", {}).body.should == {:duffy => "duck"}
44
+ @http_client.send(:build_response, response, 0.0, "GET", "resource", {}).headers.should == {"daisy" => "duck"}
43
45
  end
44
46
  end
45
47
  describe "resource_path" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 6
9
- version: 0.3.6
8
+ - 7
9
+ version: 0.3.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - jan@moviepilot.com
@@ -240,6 +240,7 @@ files:
240
240
  - lib/plugins/plug02_response_code_checker.rb
241
241
  - lib/plugins/plug03_response_header_checker.rb
242
242
  - lib/plugins/plug04_response_body_checker.rb
243
+ - lib/plugins/plug05_response_time_checker.rb
243
244
  - lib/result.rb
244
245
  - lib/string_ext.rb
245
246
  - lib/tasks/api.rake
@@ -266,7 +267,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
266
267
  requirements:
267
268
  - - ">="
268
269
  - !ruby/object:Gem::Version
269
- hash: 2715016286846955498
270
+ hash: 3590479262244463849
270
271
  segments:
271
272
  - 0
272
273
  version: "0"