webpoke 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b980ca6a8f667b53abd42762d98796f5ff420d2
4
- data.tar.gz: d21244eb1d3d4456d433b2d0a37deb8faea1359b
3
+ metadata.gz: be902de90c305d014335c28d1a27e777e00bd228
4
+ data.tar.gz: 30e2f79e091ce784ad1fbe70f6eadf834e474089
5
5
  SHA512:
6
- metadata.gz: b48244af31f75d68687a26a65e2bf0b37e5ff5a7fb80175fca71931b32b72252213dea9cf1d241e4000c22af6c06935d992e0de589df2879cd940e95a6182225
7
- data.tar.gz: bb4357cf189c738263f457936ffced676d9870df6598a0786588fa846a5f2a5d19989453e694c53ca585a730d43c2868255c0c4ba88e607c3451d28270df9b3f
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', Array, "Only run tests in group" ) do |group|
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 !file
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)
@@ -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
- input: lambda {|d| JSON.parse(d, symbolyze_names: true)},
44
- output: lambda {|d| d.to_json }
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 "Error while executing success for test".red
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)
@@ -1,3 +1,3 @@
1
1
  module Webpoke
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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
- return if group && !test.group == group
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
- body = $config.parse[:ouput] ? $config.parse[:output].call(r.body) : r.body
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpoke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Hidalgo