webpoke 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/bin/poke +5 -5
- data/lib/Webpoke/Config.rb +2 -2
- data/lib/Webpoke/Test.rb +2 -2
- data/lib/Webpoke/version.rb +1 -1
- data/lib/webpoke.rb +8 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be902de90c305d014335c28d1a27e777e00bd228
|
4
|
+
data.tar.gz: 30e2f79e091ce784ad1fbe70f6eadf834e474089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8960c831b32710d73af4b54692306b5d925e209cb129c332a6cc81e21d7ff77dc07c9f263807a67524d8784e6a238c324063bee0836e1c340503f22bcdd784fc
|
7
|
+
data.tar.gz: 67e62ad540e2088334ad629b7f9be5f793c7612299a75cb6332d0b631b913d0aef6e0577635acad598deaa29633472dc2d46d1d9f0c1c746ee6f06b956957010
|
data/bin/poke
CHANGED
@@ -5,8 +5,6 @@ require 'optparse'
|
|
5
5
|
|
6
6
|
options = {}
|
7
7
|
|
8
|
-
file = ARGV[0]
|
9
|
-
|
10
8
|
optparser = OptionParser.new do |opts|
|
11
9
|
opts.banner = "Usage: poke [options] file_with_tests"
|
12
10
|
opts.on( '-h', '--help', 'Display this screen' ) do
|
@@ -19,8 +17,8 @@ optparser = OptionParser.new do |opts|
|
|
19
17
|
options[:bootstrap] = File.expand_path file
|
20
18
|
end
|
21
19
|
|
22
|
-
options[:group] =
|
23
|
-
opts.on( '-g group', '--group groups',
|
20
|
+
options[:group] = nil
|
21
|
+
opts.on( '-g group', '--group groups', "Only run tests in group" ) do |group|
|
24
22
|
options[:group] = group
|
25
23
|
end
|
26
24
|
|
@@ -45,7 +43,7 @@ optparser = OptionParser.new do |opts|
|
|
45
43
|
|
46
44
|
end
|
47
45
|
|
48
|
-
if !
|
46
|
+
if !ARGV[0]
|
49
47
|
puts opts.help()
|
50
48
|
exit 255
|
51
49
|
end
|
@@ -57,6 +55,8 @@ if options[:bootstrap]
|
|
57
55
|
end
|
58
56
|
|
59
57
|
|
58
|
+
file = ARGV[0]
|
59
|
+
|
60
60
|
if (File.directory?(file))
|
61
61
|
Dir.glob(File.expand_path(file)+'/*.rb').each do |f|
|
62
62
|
require File.expand_path(f)
|
data/lib/Webpoke/Config.rb
CHANGED
@@ -40,8 +40,8 @@ class Webpoke::Config
|
|
40
40
|
when String
|
41
41
|
raise new Webpoke::ConfigError("I don't know how to parse [#{type}] responses yet :/") unless @@valid_parse_types.include? type
|
42
42
|
@parse = {
|
43
|
-
|
44
|
-
|
43
|
+
output: lambda {|d| JSON.parse(d, symbolize_names: true)},
|
44
|
+
input: lambda {|d| d.to_json }
|
45
45
|
}
|
46
46
|
when Hash
|
47
47
|
@parse = type
|
data/lib/Webpoke/Test.rb
CHANGED
@@ -59,15 +59,15 @@ Returns the test description
|
|
59
59
|
return false
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
62
|
|
64
63
|
if @success
|
65
64
|
begin
|
66
65
|
result = @success.call(response, body)
|
67
66
|
rescue Exception => e
|
68
67
|
result = false
|
69
|
-
Webpoke.log "
|
68
|
+
Webpoke.log "\nError while executing success for test".red
|
70
69
|
Webpoke.log e
|
70
|
+
Webpoke.log e.backtrace.join "\n"
|
71
71
|
end
|
72
72
|
else
|
73
73
|
result = self.default_success(response, body)
|
data/lib/Webpoke/version.rb
CHANGED
data/lib/webpoke.rb
CHANGED
@@ -64,7 +64,7 @@ module Webpoke
|
|
64
64
|
|
65
65
|
if test.data
|
66
66
|
if $config.parse[:input]
|
67
|
-
args[:body] = config.parse[:input].call(test.data)
|
67
|
+
args[:body] = $config.parse[:input].call(test.data)
|
68
68
|
else
|
69
69
|
args[:data] = test.data
|
70
70
|
end
|
@@ -86,7 +86,7 @@ module Webpoke
|
|
86
86
|
def run (group=nil)
|
87
87
|
|
88
88
|
$tests.each do |test|
|
89
|
-
|
89
|
+
next if group && test.group != group
|
90
90
|
$tested +=1
|
91
91
|
|
92
92
|
fqu = if test.url.match(/^https?:\/\//i) then url; else $config.base+test.url; end
|
@@ -105,9 +105,12 @@ module Webpoke
|
|
105
105
|
$errors += 1;
|
106
106
|
next;
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
|
+
body = r.body
|
109
110
|
begin
|
110
|
-
|
111
|
+
if $config.parse[:output] && body.is_a?(String)
|
112
|
+
body = $config.parse[:output].call(r.body)
|
113
|
+
end
|
111
114
|
rescue Exception => e
|
112
115
|
log "Parsing failure: ".red
|
113
116
|
log "\t#{e}"
|
@@ -117,6 +120,7 @@ module Webpoke
|
|
117
120
|
next;
|
118
121
|
end
|
119
122
|
|
123
|
+
|
120
124
|
if test.passed?(r.code, body)
|
121
125
|
$successes +=1
|
122
126
|
log "OK!".green
|