apirunner 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
 - data/apirunner.gemspec +4 -2
 - data/lib/api_runner.rb +1 -0
 - data/lib/http_client.rb +2 -2
 - data/lib/plugins/plug04_response_body_checker.rb +1 -1
 - data/spec/checker_spec.rb +8 -18
 - data/spec/response_body_checker_spec.rb +22 -0
 - metadata +6 -4
 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.3. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.3.10
         
     | 
    
        data/apirunner.gemspec
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = %q{apirunner}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.3. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.3.10"
         
     | 
| 
       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"]
         
     | 
| 
       12 
     | 
    
         
            -
              s.date = %q{2010-10- 
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2010-10-14}
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.description = %q{apirunner is a testsuite to query your RESTful JSON API and match response with your defined expectations}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.email = %q{developers@moviepilot.com}
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.extra_rdoc_files = [
         
     | 
| 
         @@ -62,6 +62,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       62 
62 
     | 
    
         
             
                "spec/checker_spec.rb",
         
     | 
| 
       63 
63 
     | 
    
         
             
                "spec/expectation_matcher_spec.rb",
         
     | 
| 
       64 
64 
     | 
    
         
             
                "spec/http_client_spec.rb",
         
     | 
| 
      
 65 
     | 
    
         
            +
                "spec/response_body_checker_spec.rb",
         
     | 
| 
       65 
66 
     | 
    
         
             
                "spec/result_spec.rb",
         
     | 
| 
       66 
67 
     | 
    
         
             
                "spec/spec_helper.rb"
         
     | 
| 
       67 
68 
     | 
    
         
             
              ]
         
     | 
| 
         @@ -75,6 +76,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       75 
76 
     | 
    
         
             
                "spec/checker_spec.rb",
         
     | 
| 
       76 
77 
     | 
    
         
             
                "spec/expectation_matcher_spec.rb",
         
     | 
| 
       77 
78 
     | 
    
         
             
                "spec/http_client_spec.rb",
         
     | 
| 
      
 79 
     | 
    
         
            +
                "spec/response_body_checker_spec.rb",
         
     | 
| 
       78 
80 
     | 
    
         
             
                "spec/result_spec.rb",
         
     | 
| 
       79 
81 
     | 
    
         
             
                "spec/spec_helper.rb"
         
     | 
| 
       80 
82 
     | 
    
         
             
              ]
         
     | 
    
        data/lib/api_runner.rb
    CHANGED
    
    | 
         @@ -37,6 +37,7 @@ class ApiRunner 
     | 
|
| 
       37 
37 
     | 
    
         
             
                  puts("Server #{@configuration.host} seems to be unavailable!")
         
     | 
| 
       38 
38 
     | 
    
         
             
                end
         
     | 
| 
       39 
39 
     | 
    
         
             
                error_count = @results.select{ |r| !r.succeeded }.count
         
     | 
| 
      
 40 
     | 
    
         
            +
                puts "\n\nResults: I greatfully ran #{ @spec.size } test(s), \033[32m#{ @spec.size - error_count }\033[0m succeeded, \033[31m#{ error_count }\033[0m failed."
         
     | 
| 
       40 
41 
     | 
    
         
             
                exit(error_count)
         
     | 
| 
       41 
42 
     | 
    
         
             
              end
         
     | 
| 
       42 
43 
     | 
    
         | 
    
        data/lib/http_client.rb
    CHANGED
    
    | 
         @@ -42,7 +42,7 @@ class HttpClient 
     | 
|
| 
       42 
42 
     | 
    
         
             
              def put(headers, resource, data, params)
         
     | 
| 
       43 
43 
     | 
    
         
             
                request = Net::HTTP::Put.new(resource_path(resource), initheader = headers)
         
     | 
| 
       44 
44 
     | 
    
         
             
                request.body = data.to_json
         
     | 
| 
       45 
     | 
    
         
            -
                return Benchmark.realtime 
     | 
| 
      
 45 
     | 
    
         
            +
                return Benchmark.realtime{ @response = @http.request(request) }, @response
         
     | 
| 
       46 
46 
     | 
    
         
             
              end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
              # sends POST request and returns response
         
     | 
| 
         @@ -69,7 +69,7 @@ class HttpClient 
     | 
|
| 
       69 
69 
     | 
    
         
             
                uri.scheme = @protocol
         
     | 
| 
       70 
70 
     | 
    
         
             
                uri.host = @host
         
     | 
| 
       71 
71 
     | 
    
         
             
                uri.port = @port
         
     | 
| 
       72 
     | 
    
         
            -
                uri.query =  
     | 
| 
      
 72 
     | 
    
         
            +
                uri.query = params.collect{ |k,v| "#{k}=#{CGI::escape(v.to_s)}" }.reverse.join('&') if not params.nil?
         
     | 
| 
       73 
73 
     | 
    
         
             
                uri.path = resource_path(resource)
         
     | 
| 
       74 
74 
     | 
    
         
             
                uri
         
     | 
| 
       75 
75 
     | 
    
         
             
              end
         
     | 
| 
         @@ -86,6 +86,6 @@ class ResponseBodyChecker < Checker 
     | 
|
| 
       86 
86 
     | 
    
         
             
              # returns relative path for matching the target tree of the response body
         
     | 
| 
       87 
87 
     | 
    
         
             
              # explicit array adressing is replaced by *
         
     | 
| 
       88 
88 
     | 
    
         
             
              def relative_path(path)
         
     | 
| 
       89 
     | 
    
         
            -
                path.gsub(/\/([^\/]+)\[\d+\] 
     | 
| 
      
 89 
     | 
    
         
            +
                path.gsub(/\/([^\/]+)\[\d+\]/i,"/*")
         
     | 
| 
       90 
90 
     | 
    
         
             
              end
         
     | 
| 
       91 
91 
     | 
    
         
             
            end
         
     | 
    
        data/spec/checker_spec.rb
    CHANGED
    
    | 
         @@ -9,27 +9,17 @@ describe "Checker" do 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  Checker.available_plugins.size.should_not == 0
         
     | 
| 
       10 
10 
     | 
    
         
             
                end
         
     | 
| 
       11 
11 
     | 
    
         
             
              end
         
     | 
| 
       12 
     | 
    
         
            -
              describe " 
     | 
| 
       13 
     | 
    
         
            -
                it  
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
                it 'should substitute more than one absolute adressing in a given path' do
         
     | 
| 
       19 
     | 
    
         
            -
                  pending "Move me"
         
     | 
| 
       20 
     | 
    
         
            -
                  path = "/bla/foo/values[6]/duffy/friends[1]/duck"
         
     | 
| 
       21 
     | 
    
         
            -
                  Checker.new({},{}).send(:relative_path, path).should eql "/bla/foo/*/duffy/*/duck"
         
     | 
| 
      
 12 
     | 
    
         
            +
              describe "excluded?" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                it "should return true if a given item is not part of the instances exludes" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  c = Checker.new({}, {}, ["exclude_1", "exclude_2"])
         
     | 
| 
      
 15 
     | 
    
         
            +
                  c.send(:excluded?, "exclude_1").should be_true
         
     | 
| 
      
 16 
     | 
    
         
            +
                  c.send(:excluded?, "exclude_2").should be_true
         
     | 
| 
       22 
17 
     | 
    
         
             
                end
         
     | 
| 
       23 
     | 
    
         
            -
                it  
     | 
| 
       24 
     | 
    
         
            -
                   
     | 
| 
       25 
     | 
    
         
            -
                   
     | 
| 
       26 
     | 
    
         
            -
                  Checker.new({},{}).send(:relative_path, path).should be_a(String)
         
     | 
| 
      
 18 
     | 
    
         
            +
                it "should return false if a given item is part of the instances excludes" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  c = Checker.new({}, {}, ["exclude_1", "exclude_2"])
         
     | 
| 
      
 20 
     | 
    
         
            +
                  c.send(:excluded?, "no_exclude").should be_false
         
     | 
| 
       27 
21 
     | 
    
         
             
                end
         
     | 
| 
       28 
22 
     | 
    
         
             
              end
         
     | 
| 
       29 
     | 
    
         
            -
              describe "excluded?" do
         
     | 
| 
       30 
     | 
    
         
            -
                it "should return true if a given item is not part of the instances exludes"
         
     | 
| 
       31 
     | 
    
         
            -
                it "should return false if a given item is part of the instances excludes"
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
23 
     | 
    
         
             
              describe "is_regex?" do
         
     | 
| 
       34 
24 
     | 
    
         
             
                it 'should return true if the given string seems to be a regular expression' do
         
     | 
| 
       35 
25 
     | 
    
         
             
                  string = "/^\d{3}$/"
         
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "ResponseBodyChecker" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "relative_path" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                it 'should substitute an absolute addressing in a given path' do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  path = "/bla/foo/values[6]/duffy/duck"
         
     | 
| 
      
 7 
     | 
    
         
            +
                  ResponseBodyChecker.new({},{}).send(:relative_path, path).should eql "/bla/foo/*/duffy/duck"
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
                it 'should substitute more than one absolute adressing in a given path' do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  path = "/bla/foo/values[6]/duffy/friends[1]/duck"
         
     | 
| 
      
 11 
     | 
    
         
            +
                  ResponseBodyChecker.new({},{}).send(:relative_path, path).should eql "/bla/foo/*/duffy/*/duck"
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
                it "should substiiture at the end of the path too" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  path = "/bla/foo/values[6]/duffy/friends[1]/duck/ibizas[7]"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  ResponseBodyChecker.new({}, {}).send(:relative_path, path).should eql "/bla/foo/*/duffy/*/duck/*"
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
                it 'should return a string' do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  path = "/bla/foo/values[6]/duffy/friends[1]/duck"
         
     | 
| 
      
 19 
     | 
    
         
            +
                 ResponseBodyChecker.new({},{}).send(:relative_path, path).should be_a(String)
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 3
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              version: 0.3. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 10
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.3.10
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - jan@moviepilot.com
         
     | 
| 
         @@ -14,7 +14,7 @@ autorequire: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       15 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            date: 2010-10- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-10-14 00:00:00 +02:00
         
     | 
| 
       18 
18 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       19 
19 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -251,6 +251,7 @@ files: 
     | 
|
| 
       251 
251 
     | 
    
         
             
            - spec/checker_spec.rb
         
     | 
| 
       252 
252 
     | 
    
         
             
            - spec/expectation_matcher_spec.rb
         
     | 
| 
       253 
253 
     | 
    
         
             
            - spec/http_client_spec.rb
         
     | 
| 
      
 254 
     | 
    
         
            +
            - spec/response_body_checker_spec.rb
         
     | 
| 
       254 
255 
     | 
    
         
             
            - spec/result_spec.rb
         
     | 
| 
       255 
256 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       256 
257 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
         @@ -267,7 +268,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       267 
268 
     | 
    
         
             
              requirements: 
         
     | 
| 
       268 
269 
     | 
    
         
             
              - - ">="
         
     | 
| 
       269 
270 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
       270 
     | 
    
         
            -
                  hash: - 
     | 
| 
      
 271 
     | 
    
         
            +
                  hash: -568682113681026828
         
     | 
| 
       271 
272 
     | 
    
         
             
                  segments: 
         
     | 
| 
       272 
273 
     | 
    
         
             
                  - 0
         
     | 
| 
       273 
274 
     | 
    
         
             
                  version: "0"
         
     | 
| 
         @@ -292,5 +293,6 @@ test_files: 
     | 
|
| 
       292 
293 
     | 
    
         
             
            - spec/checker_spec.rb
         
     | 
| 
       293 
294 
     | 
    
         
             
            - spec/expectation_matcher_spec.rb
         
     | 
| 
       294 
295 
     | 
    
         
             
            - spec/http_client_spec.rb
         
     | 
| 
      
 296 
     | 
    
         
            +
            - spec/response_body_checker_spec.rb
         
     | 
| 
       295 
297 
     | 
    
         
             
            - spec/result_spec.rb
         
     | 
| 
       296 
298 
     | 
    
         
             
            - spec/spec_helper.rb
         
     |