apirunner 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
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.1.4"
8
+ s.version = "0.1.5"
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"]
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "apirunner.gemspec",
29
+ "changelog.txt",
29
30
  "examples/config/api_runner.yml",
30
31
  "examples/test/api_runner/001_create_ressource.yml",
31
32
  "examples/test/api_runner/999_delete_ressource.yml",
data/changelog.txt ADDED
@@ -0,0 +1,7 @@
1
+ plan version 0.2.0
2
+ run without rails environment
3
+ fix pending specs
4
+ body should be evaluateable as nil
5
+ body tags should be evaluateable as nil too
6
+ create separate classes for TestCase and TestExpectation as well as strip
7
+ down ExpectationMatcher
data/lib/api_runner.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  class ApiRunner
2
2
  require 'yaml'
3
+ require 'JSON'
3
4
  require 'expectation_matcher'
4
5
  require 'http_client'
5
6
 
6
-
7
7
  CONFIG_FILE = "config/api_runner.yml"
8
8
  SPEC_PATH = "test/api_runner/"
9
9
  EXCLUDES_FILE = "test/api_runner/excludes.yml"
@@ -24,9 +24,9 @@ class ApiRunner
24
24
  def run
25
25
  if server_is_available?
26
26
  run_tests
27
- @errors.try(:each_with_index) do |error, index|
27
+ @errors.each_with_index do |error, index|
28
28
  puts("\n\nError (#{index+1}): #{error}")
29
- end
29
+ end unless @errors.empty?
30
30
  else
31
31
  puts("Server #{@host} seems to be unavailable!")
32
32
  end
@@ -46,8 +46,7 @@ class ExpectationMatcher
46
46
  result_struct = Struct.new(:succeeded, :error)
47
47
  results = result_struct.new(:succeeded => true, :error => nil)
48
48
 
49
- debugger
50
- testcase['response_expectation']['headers'].try(:each_pair) do |header_name, header_value|
49
+ testcase['response_expectation']['headers'].each_pair do |header_name, header_value|
51
50
  if is_regex?(header_value)
52
51
  if not (excluded?(header_name) or regex_matches?(header_value, response.headers[header_name]))
53
52
  results.succeeded = false
@@ -59,7 +58,7 @@ class ExpectationMatcher
59
58
  results.error = "testcase '#{testcase['name']}'\n expected header identifier --#{header_name}-- to match --#{header_value}--\n got --#{response.headers[header_name]}--"
60
59
  end
61
60
  end
62
- end
61
+ end unless (testcase['response_expectation']['headers'].nil? or testcase['response_expectation']['headers'].empty?)
63
62
  return results
64
63
  end
65
64
 
@@ -34,9 +34,14 @@ describe 'apirunner' do
34
34
 
35
35
  describe 'run_tests' do
36
36
  it 'should send a request for every given testcase' do
37
- pending "Rails context missing"
37
+ response_struct = Struct.new(:code, :message, :headers, :body)
38
+ response = response_struct.new
39
+ response.code = 404
40
+ response.message = "Ok"
41
+ response.body = {}
42
+ response.headers = {}
38
43
  @a.should_receive(:server_is_available?).and_return true
39
- @a.should_receive(:send_request).exactly(@a.instance_variable_get(:@spec).size).times
44
+ @a.should_receive(:send_request).exactly(@a.instance_variable_get(:@spec).size).times.and_return(response)
40
45
  @a.run
41
46
  end
42
47
  it 'should run a test for every test_type'
@@ -99,7 +99,6 @@ describe 'ExpectationMatcher' do
99
99
  @response = response_struct.new
100
100
  end
101
101
  it 'should return a struct representing success, if one certain expected header value matches the response header' do
102
- pending "Rails context is missing"
103
102
  @response.headers = {"content-type"=>["text/html; charset=utf-8"], "cache-control"=>["no-cache"], "x-runtime"=>["0.340116"], "server"=>["WEBrick/1.3.1 (Ruby/1.9.2/2010-08-18)"], "date"=>["Tue, 21 Sep 2010 11:33:05 GMT"], "content-length"=>["149"], "connection"=>["close"], "Last-Modified" => "2010-10-01 23:23:23"}
104
103
  testcase = { 'response_expectation' => { 'headers' => {"Last-Modified"=>"/.*/"} } }
105
104
  @em.send(:response_headers, @response, testcase).should be_a(Struct)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - jan@moviepilot.com
@@ -230,6 +230,7 @@ files:
230
230
  - Rakefile
231
231
  - VERSION
232
232
  - apirunner.gemspec
233
+ - changelog.txt
233
234
  - examples/config/api_runner.yml
234
235
  - examples/test/api_runner/001_create_ressource.yml
235
236
  - examples/test/api_runner/999_delete_ressource.yml
@@ -262,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
263
  requirements:
263
264
  - - ">="
264
265
  - !ruby/object:Gem::Version
265
- hash: -2675700175658128746
266
+ hash: -2331822948028323562
266
267
  segments:
267
268
  - 0
268
269
  version: "0"