apirunner 0.3.10 → 0.4.0
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 +2 -2
- data/lib/api_runner.rb +17 -2
- data/spec/api_runner_spec.rb +12 -0
- metadata +5 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
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.
|
8
|
+
s.version = "0.4.0"
|
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-20}
|
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 = [
|
data/lib/api_runner.rb
CHANGED
@@ -6,8 +6,7 @@ class ApiRunner
|
|
6
6
|
require 'api_configuration'
|
7
7
|
require 'testcase'
|
8
8
|
require 'string_ext'
|
9
|
-
|
10
|
-
# require 'JSON'
|
9
|
+
require 'JSON'
|
11
10
|
|
12
11
|
CONFIG_FILE = "config/api_runner.yml"
|
13
12
|
SPEC_PATH = "test/api_runner/"
|
@@ -88,9 +87,25 @@ class ApiRunner
|
|
88
87
|
Dir.new(path).entries.sort.each do |dir_entry|
|
89
88
|
specs.push *YAML.load_file(path+dir_entry) if not (File.directory? dir_entry or dir_entry.match(/^\./) or dir_entry.match(/excludes/))
|
90
89
|
end
|
90
|
+
specs = explode_iterations(specs)
|
91
91
|
@spec = objectize(priorize(partition(specs)))
|
92
92
|
end
|
93
93
|
|
94
|
+
def explode_iterations(specs)
|
95
|
+
return specs unless specs.detect{ |s| s['iterations']}
|
96
|
+
exploded_specs = []
|
97
|
+
specs.each do |spec|
|
98
|
+
if spec['iterations'].nil?
|
99
|
+
exploded_specs << spec
|
100
|
+
else
|
101
|
+
1.upto(spec['iterations'].to_i) do |i|
|
102
|
+
exploded_specs << JSON.parse(spec.to_json.gsub(/@@/, "%07d" % i.to_s))
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
return exploded_specs
|
107
|
+
end
|
108
|
+
|
94
109
|
# converts the given array of raw testcases to an array of testcase objects
|
95
110
|
def objectize(raw_specs)
|
96
111
|
specs = []
|
data/spec/api_runner_spec.rb
CHANGED
@@ -75,4 +75,16 @@ describe 'apirunner' do
|
|
75
75
|
it 'should return false if the given server is not available'
|
76
76
|
end
|
77
77
|
|
78
|
+
describe 'explode_iterations' do
|
79
|
+
it 'should explode iterations if iterations is set to a proper value' do
|
80
|
+
yaml_fixture = [{"name"=>"Create new User", "iterations" => "10", "request"=>{"headers"=>{"Content-Type"=>"application/json"}, "path"=>"/users/duffyduck@@", "method"=>"PUT", "body"=>{"username"=>"duffyduck", "watchlist"=>["m1035", "m2087"], "blacklist"=>["m1554", "m2981"], "skiplist"=>["m1590", "m1056"], "ratings"=>{"m12493"=>4.0, "m1875"=>2.5, "m7258"=>3.0, "m7339"=>4.0, "m3642"=>5.0}, "expires_at"=>"2011-09-10 00:41:50 +0200"}}, "response_expectation"=>{"status_code"=>201, "headers"=>{"Last-Modified"=>"/.*/"}, "body"=>{"username"=>"duffyduck", "watchlist"=>["m1035", "m2087"], "blacklist"=>["m1554", "m2981"], "skiplist"=>["m1590", "m1056"], "ratings"=>{"m12493"=>4.0, "m1875"=>2.5, "m7258"=>3.0, "m7339"=>4.0, "m3642"=>5.0}, "fsk"=>"18"}}}]
|
81
|
+
@a.send(:explode_iterations,yaml_fixture).size.should == 10
|
82
|
+
@a.send(:explode_iterations,yaml_fixture).map{ |x| x['request']['path']}.sort.should == ["/users/duffyduck0000001","/users/duffyduck0000002","/users/duffyduck0000003","/users/duffyduck0000004","/users/duffyduck0000005","/users/duffyduck0000006","/users/duffyduck0000007","/users/duffyduck0000008","/users/duffyduck0000009","/users/duffyduck0000010",]
|
83
|
+
end
|
84
|
+
it 'should not explode iterations if iterations is not set' do
|
85
|
+
yaml_fixture = [{"name"=>"Create new User", "request"=>{"headers"=>{"Content-Type"=>"application/json"}, "path"=>"/users/duffyduck@@", "method"=>"PUT", "body"=>{"username"=>"duffyduck", "watchlist"=>["m1035", "m2087"], "blacklist"=>["m1554", "m2981"], "skiplist"=>["m1590", "m1056"], "ratings"=>{"m12493"=>4.0, "m1875"=>2.5, "m7258"=>3.0, "m7339"=>4.0, "m3642"=>5.0}, "expires_at"=>"2011-09-10 00:41:50 +0200"}}, "response_expectation"=>{"status_code"=>201, "headers"=>{"Last-Modified"=>"/.*/"}, "body"=>{"username"=>"duffyduck", "watchlist"=>["m1035", "m2087"], "blacklist"=>["m1554", "m2981"], "skiplist"=>["m1590", "m1056"], "ratings"=>{"m12493"=>4.0, "m1875"=>2.5, "m7258"=>3.0, "m7339"=>4.0, "m3642"=>5.0}, "fsk"=>"18"}}}]
|
86
|
+
@a.send(:explode_iterations, yaml_fixture).size.should == 1
|
87
|
+
@a.send(:explode_iterations, yaml_fixture).should eql yaml_fixture
|
88
|
+
end
|
89
|
+
end
|
78
90
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
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-20 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -268,7 +268,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
268
268
|
requirements:
|
269
269
|
- - ">="
|
270
270
|
- !ruby/object:Gem::Version
|
271
|
-
hash: -
|
271
|
+
hash: -2499615178131073520
|
272
272
|
segments:
|
273
273
|
- 0
|
274
274
|
version: "0"
|