apirunner 0.3.8 → 0.3.9

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.8
1
+ 0.3.9
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"
8
+ s.version = "0.3.9"
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}
12
+ s.date = %q{2010-10-13}
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 = [
@@ -1,14 +1,14 @@
1
1
  class ApiConfiguration
2
2
 
3
- attr_accessor :protocol, :host, :namespace, :port, :verbosity, :priority
3
+ attr_accessor :protocol, :host, :namespace, :port, :verbosity, :priority, :substitution
4
4
 
5
5
  # initializes a configuration object from given YAML file for given environment
6
6
  def initialize(raw_config, env)
7
7
  raw_config[env.to_s].each { |key, value| self.instance_variable_set("@#{key}", value) }
8
8
  self.verbosity = raw_config['general']['verbosity'].first
9
9
  self.priority = raw_config['general']['priority'] || 0
10
+ self.substitution = raw_config['general']['substitution']
10
11
  self
11
12
  end
12
-
13
13
  end
14
14
 
data/lib/api_runner.rb CHANGED
@@ -94,7 +94,7 @@ class ApiRunner
94
94
  def objectize(raw_specs)
95
95
  specs = []
96
96
  raw_specs.each do |spec|
97
- specs << Testcase.new(spec)
97
+ specs << Testcase.new(spec, @configuration.substitution)
98
98
  end
99
99
  specs
100
100
  end
data/lib/testcase.rb CHANGED
@@ -2,12 +2,22 @@ class Testcase
2
2
 
3
3
  attr_reader :raw, :name, :request, :response_expectation, :wait_before_request
4
4
 
5
- def initialize(raw)
5
+ def initialize(raw, substitution)
6
6
  @raw = raw
7
7
  @name = raw['name']
8
8
  @request = @raw['request']
9
9
  @response_expectation = @raw['response_expectation']
10
10
  @wait_before_request = @raw['wait_before_request'].nil? ? 0 : @raw['wait_before_request']
11
+ create_resource_substitutes(substitution)
12
+ end
13
+
14
+ private
15
+ # substitutes rersource names cause of race conditions in multiple system scenarios
16
+ def create_resource_substitutes(substitution)
17
+ substitution['substitutes'].each do |substitute|
18
+ @request = JSON.parse(@request.to_json.gsub(substitute, substitution['prefix'] + substitute))
19
+ @response_expectation = JSON.parse(@response_expectation.to_json.gsub(substitute, substitution['prefix'] + substitute))
20
+ end unless substitution.nil?
11
21
  end
12
22
 
13
23
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 8
9
- version: 0.3.8
8
+ - 9
9
+ version: 0.3.9
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-12 00:00:00 +02:00
17
+ date: 2010-10-13 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -267,7 +267,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
267
267
  requirements:
268
268
  - - ">="
269
269
  - !ruby/object:Gem::Version
270
- hash: 4462734146908601774
270
+ hash: -2406206885312499226
271
271
  segments:
272
272
  - 0
273
273
  version: "0"