api_test_gem 0.1.0 → 0.1.1
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/Gemfile +2 -1
- data/Gemfile.lock +4 -0
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/api_test_gem.gemspec +9 -1
- data/lib/api_test.sh +26 -0
- data/lib/api_test_gem.rb +60 -0
- data/lib/auth_api_test.sh +5 -0
- data/spec/api_test_gem_spec.rb +16 -2
- data/spec/spec_helper.rb +1 -0
- metadata +42 -10
data/Gemfile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
|
-
|
4
|
+
gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "json"
|
5
6
|
|
6
7
|
# Add dependencies to develop your gem here.
|
7
8
|
# Include everything needed to run rake, tests, features, etc.
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
activesupport (3.0.9)
|
4
5
|
diff-lcs (1.1.2)
|
5
6
|
git (1.2.5)
|
6
7
|
jeweler (1.6.4)
|
7
8
|
bundler (~> 1.0)
|
8
9
|
git (>= 1.2.5)
|
9
10
|
rake
|
11
|
+
json (1.5.3)
|
10
12
|
rake (0.9.2)
|
11
13
|
rcov (0.9.10)
|
12
14
|
rspec (2.3.0)
|
@@ -22,7 +24,9 @@ PLATFORMS
|
|
22
24
|
ruby
|
23
25
|
|
24
26
|
DEPENDENCIES
|
27
|
+
activesupport (>= 2.3.5)
|
25
28
|
bundler (~> 1.0.0)
|
26
29
|
jeweler (~> 1.6.4)
|
30
|
+
json
|
27
31
|
rcov
|
28
32
|
rspec (~> 2.3.0)
|
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/api_test_gem.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{api_test_gem}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jaqueline Wilde"]
|
@@ -26,7 +26,9 @@ Gem::Specification.new do |s|
|
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"api_test_gem.gemspec",
|
29
|
+
"lib/api_test.sh",
|
29
30
|
"lib/api_test_gem.rb",
|
31
|
+
"lib/auth_api_test.sh",
|
30
32
|
"spec/api_test_gem_spec.rb",
|
31
33
|
"spec/spec_helper.rb"
|
32
34
|
]
|
@@ -41,17 +43,23 @@ Gem::Specification.new do |s|
|
|
41
43
|
s.specification_version = 3
|
42
44
|
|
43
45
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
|
47
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
44
48
|
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
45
49
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
46
50
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
47
51
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
48
52
|
else
|
53
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
54
|
+
s.add_dependency(%q<json>, [">= 0"])
|
49
55
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
50
56
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
51
57
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
52
58
|
s.add_dependency(%q<rcov>, [">= 0"])
|
53
59
|
end
|
54
60
|
else
|
61
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
62
|
+
s.add_dependency(%q<json>, [">= 0"])
|
55
63
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
56
64
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
65
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
data/lib/api_test.sh
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
AUTH="Haruki:jar90q71"
|
3
|
+
BASE="http://localhost:3000"
|
4
|
+
|
5
|
+
echo $BASE
|
6
|
+
|
7
|
+
METHOD=$1
|
8
|
+
DEST="$BASE$2"
|
9
|
+
XML=$3
|
10
|
+
|
11
|
+
echo $DEST
|
12
|
+
# make sure args were passed
|
13
|
+
if [ $# -eq 0 ]; then
|
14
|
+
echo "usage: ./`basename $0` HTTP-METHOD DESTINATION_URI [XML]"
|
15
|
+
echo "example: ./`basename $0` POST "/accounts" \"<account><name>ed</name><email>ed@ed.com</email></account>\""
|
16
|
+
exit 1
|
17
|
+
fi
|
18
|
+
|
19
|
+
# execute CURL call
|
20
|
+
curl -H 'Accept: text/javascript' -H 'Content-Type: application/json' -w '\nHTTP STATUS: %{http_code}\nTIME: %{time_total}\n' \
|
21
|
+
-X $METHOD \
|
22
|
+
-d "$XML" \
|
23
|
+
-u "$AUTH" \
|
24
|
+
"$DEST" --cookie cookie_for_auth
|
25
|
+
|
26
|
+
exit 0
|
data/lib/api_test_gem.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
def api_test(*args)
|
2
|
+
#unless (ARGV[0]!=nil && ARGV[1]!=nil)
|
3
|
+
unless (args[0]!=nil && args[1]!=nil)
|
4
|
+
puts "richtiger Aufruf via: 'api_test [controller] [action]'"
|
5
|
+
else
|
6
|
+
#route_yml=File.expand_path((File.dirname(__FILE__)).chomp('.')+ 'apitest_config.yml')
|
7
|
+
route_yml=File.expand_path("../projects/ave/tavex2/rails/api_test_config.yml")
|
8
|
+
#for usage
|
9
|
+
#route_yml=File.expand_path("#{Dir.pwd}/apitest_config.yml")
|
10
|
+
#arg_con=ARGV[0].split('/')
|
11
|
+
arg_con=args[0].split('/')
|
12
|
+
if File.exist?(route_yml)
|
13
|
+
parsed = begin
|
14
|
+
config=YAML.load(File.open("#{route_yml}"))
|
15
|
+
rescue ArgumentError => e
|
16
|
+
puts "Could not parse YAML: #{e.message}"
|
17
|
+
end
|
18
|
+
#config=YAML.load(File.open("#{route_yml}"))
|
19
|
+
else
|
20
|
+
puts "please create 'api_test_config.yml'"
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
#[arg_con[0], arg_con[1], ARGV[1]].each do |arg|
|
25
|
+
[arg_con[0], arg_con[1], args[1]].each do |arg|
|
26
|
+
if arg!=nil
|
27
|
+
config=config[arg]
|
28
|
+
end
|
29
|
+
if config==nil
|
30
|
+
puts "argument '#{arg}' doesn't exist"
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
route_sh=File.expand_path((File.dirname(__FILE__)).chomp('.') + '/api_test.sh')
|
36
|
+
|
37
|
+
for_exec = "sh #{route_sh} #{config['method']} #{config['url']}"
|
38
|
+
|
39
|
+
#params in json
|
40
|
+
params=config['param']
|
41
|
+
params_json=''
|
42
|
+
unless params==nil
|
43
|
+
params_json= JSON.generate(params)
|
44
|
+
end
|
45
|
+
for_exec<< " '#{params_json}'"
|
46
|
+
|
47
|
+
@result={:result=>`#{for_exec}`, :curl=>"#{for_exec}"}
|
48
|
+
result=@result[:result]
|
49
|
+
puts result
|
50
|
+
if result.include?("No route matches")
|
51
|
+
#puts "#{ARGV[0]} #{ARGV[1]} no route for given parameter"
|
52
|
+
puts "#{args[0]} #{args[1]} no route for given parameter"
|
53
|
+
elsif result.include?("HTTP STATUS: 500") || result.include?("HTTP STATUS: 200")
|
54
|
+
#puts "#{ARGV[0]} #{ARGV[1]} : ok"
|
55
|
+
puts "#{args[0]} #{args[1]} : ok"
|
56
|
+
else
|
57
|
+
puts "#{for_exec}: something is unclear, please check"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/spec/api_test_gem_spec.rb
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "ApiTestGem" do
|
4
|
-
|
5
|
-
|
4
|
+
before(:each) do
|
5
|
+
api_test('product', 'update')
|
6
|
+
end
|
7
|
+
it "gets the right url" do
|
8
|
+
@result[:curl].include?("/products/3").should be true
|
9
|
+
end
|
10
|
+
it "gets the infos from api_test_config.yml" do
|
11
|
+
@result[:curl].include?('"identifier":"Produkt"').should be true
|
12
|
+
@result[:curl].include?('"info_short":"short product info"').should be true
|
13
|
+
@result[:curl].include?('"minimum_price":12.5').should be true
|
14
|
+
@result[:curl].include?('"calc_type_id":1').should be true
|
15
|
+
end
|
16
|
+
it "returns the result of the curl request" do
|
17
|
+
@result[:result].should_not be_nil
|
18
|
+
@result[:result].is_a?(String).should be true
|
19
|
+
puts Dir.pwd
|
6
20
|
end
|
7
21
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
4
|
require 'api_test_gem'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
# Requires supporting files with custom matchers and macros, etc,
|
7
8
|
# in ./support/ and its subdirectories.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_test_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jaqueline Wilde
|
@@ -20,6 +20,36 @@ default_executable:
|
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 9
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 3
|
31
|
+
- 5
|
32
|
+
version: 2.3.5
|
33
|
+
type: :runtime
|
34
|
+
name: activesupport
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
name: json
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
23
53
|
none: false
|
24
54
|
requirements:
|
25
55
|
- - ~>
|
@@ -33,9 +63,9 @@ dependencies:
|
|
33
63
|
type: :development
|
34
64
|
name: rspec
|
35
65
|
prerelease: false
|
36
|
-
version_requirements: *
|
66
|
+
version_requirements: *id003
|
37
67
|
- !ruby/object:Gem::Dependency
|
38
|
-
requirement: &
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
39
69
|
none: false
|
40
70
|
requirements:
|
41
71
|
- - ~>
|
@@ -49,9 +79,9 @@ dependencies:
|
|
49
79
|
type: :development
|
50
80
|
name: bundler
|
51
81
|
prerelease: false
|
52
|
-
version_requirements: *
|
82
|
+
version_requirements: *id004
|
53
83
|
- !ruby/object:Gem::Dependency
|
54
|
-
requirement: &
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
55
85
|
none: false
|
56
86
|
requirements:
|
57
87
|
- - ~>
|
@@ -65,9 +95,9 @@ dependencies:
|
|
65
95
|
type: :development
|
66
96
|
name: jeweler
|
67
97
|
prerelease: false
|
68
|
-
version_requirements: *
|
98
|
+
version_requirements: *id005
|
69
99
|
- !ruby/object:Gem::Dependency
|
70
|
-
requirement: &
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
71
101
|
none: false
|
72
102
|
requirements:
|
73
103
|
- - ">="
|
@@ -79,7 +109,7 @@ dependencies:
|
|
79
109
|
type: :development
|
80
110
|
name: rcov
|
81
111
|
prerelease: false
|
82
|
-
version_requirements: *
|
112
|
+
version_requirements: *id006
|
83
113
|
description: ""
|
84
114
|
email: jaqui.wilde@web.de
|
85
115
|
executables: []
|
@@ -99,7 +129,9 @@ files:
|
|
99
129
|
- Rakefile
|
100
130
|
- VERSION
|
101
131
|
- api_test_gem.gemspec
|
132
|
+
- lib/api_test.sh
|
102
133
|
- lib/api_test_gem.rb
|
134
|
+
- lib/auth_api_test.sh
|
103
135
|
- spec/api_test_gem_spec.rb
|
104
136
|
- spec/spec_helper.rb
|
105
137
|
has_rdoc: true
|