auger 1.2.4 → 1.3.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/README.md CHANGED
@@ -103,6 +103,19 @@ a request, in the case of `http` the response is an HTTP::Reponse object.
103
103
  and the response is passed to a block. The result of executing the block is
104
104
  presented as the result of this test (in this case true or false).
105
105
 
106
+ For better control over the result, it is possible to construct and
107
+ return an Auger::Result object, with an outcome (string to be
108
+ printed) and a boolean status (which aug client will use to print
109
+ the result in green or red), for example:
110
+
111
+ ```ruby
112
+ test 'http status code' do |response|
113
+ Result(r.code, r.code == '200')
114
+ end
115
+ ```
116
+
117
+ will always show the code, in green if 200, red otherwise.
118
+
106
119
  Save the config to a file `fe_web` and run with the `aug` command:
107
120
 
108
121
  $ aug ./fe_web
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.4
1
+ 1.3.0
data/bin/aug CHANGED
@@ -74,6 +74,32 @@ def format_outcome(outcome)
74
74
  end
75
75
  end
76
76
 
77
+ ## pretty-print Result object
78
+ module Auger
79
+ class Result
80
+ def format
81
+ output =
82
+ case self.outcome
83
+ when TrueClass then "\u2713"
84
+ when MatchData then outcome.captures.empty? ? "\u2713" : outcome.captures.join(' ')
85
+ when FalseClass then "\u2717"
86
+ when NilClass then "nil"
87
+ when Exception then "#{outcome.class}: #{outcome.to_s}"
88
+ else outcome.to_s
89
+ end
90
+
91
+ color =
92
+ case self.status
93
+ when FalseClass, NilClass then :red
94
+ when Exception then :magenta
95
+ else :green
96
+ end
97
+
98
+ return output.color(color)
99
+ end
100
+ end
101
+ end
102
+
77
103
  Auger::Config.load(cfg).projects.each do |project|
78
104
 
79
105
  threads = Hash.new { |h,k| h[k] = [] }
@@ -103,8 +129,7 @@ Auger::Config.load(cfg).projects.each do |project|
103
129
  threads[server].each do |thread|
104
130
  results = thread.value # this waits on thread
105
131
  results.flatten.each do |result|
106
- output = format_outcome(result.outcome)
107
- puts " %+#{max_test_length}s %-30s" % [result.test.name, output]
132
+ puts " %+#{max_test_length}s %-30s" % [result.test.name, result.format]
108
133
  end
109
134
  end
110
135
  end
data/lib/auger/project.rb CHANGED
@@ -59,6 +59,14 @@ module Auger
59
59
 
60
60
  alias :fqdn :fqdns
61
61
 
62
+ def tests
63
+ @connections.map do |connection|
64
+ connection.requests.map do |request|
65
+ request.tests.map { |test| test }
66
+ end
67
+ end.flatten
68
+ end
69
+
62
70
  end
63
71
 
64
72
  end
data/lib/auger/request.rb CHANGED
@@ -18,6 +18,11 @@ module Auger
18
18
  @tests << Test.new(name, block)
19
19
  end
20
20
 
21
+ ## called within test block to return a Result object
22
+ def Result(*args)
23
+ Auger::Result.new(*args)
24
+ end
25
+
21
26
  ## callback to be run after request, but before tests
22
27
  def before_tests(&block)
23
28
  @before_tests_proc = block
data/lib/auger/result.rb CHANGED
@@ -1,26 +1,30 @@
1
1
  module Auger
2
-
2
+
3
3
  class Result
4
- attr_accessor :test, :outcome
5
- def initialize(test, outcome)
6
- @test = test
4
+ attr_accessor :test, :outcome, :status
5
+
6
+ # def initialize(test, outcome)
7
+ # @test = test
8
+ # @outcome = outcome
9
+ # end
10
+
11
+ # def initialize(*args)
12
+ # hash = args.last.is_a?(Hash) ? args.pop : {}
13
+ # hash.each { |k,v| puts "got hash: #{k} = #{v}" }
14
+ # (@outcome, @status) = args
15
+ # end
16
+
17
+ ## optional args are outcome, status, Hash of instance variables
18
+ # def initialize(*args)
19
+ # hash = args.last.is_a?(Hash) ? args.pop : {}
20
+ # (@outcome, @status) = args
21
+ # hash.each { |k,v| self.instance_variable_set("@#{k}", v) }
22
+ # end
23
+
24
+ def initialize(outcome = nil, status = outcome)
7
25
  @outcome = outcome
26
+ @status = status
8
27
  end
9
-
10
- # def to_s
11
- # case @outcome
12
- # when MatchData then
13
- # @outcome.captures.empty? ? "\u2713" : @outcome.captures.join(' ')
14
- # when TrueClass then
15
- # "\u2713"
16
- # when FalseClass then
17
- # "\u2717"
18
- # when NilClass then
19
- # "\u2717"
20
- # else
21
- # @outcome.to_s
22
- # end
23
- # end
24
28
 
25
29
  end
26
30
 
data/lib/auger/test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Auger
2
2
 
3
3
  class Test
4
- attr_accessor :name, :block
4
+ attr_accessor :name, :block, :id
5
5
 
6
6
  def initialize(name, block)
7
7
  @name = name
@@ -14,10 +14,12 @@ module Auger
14
14
  if response.is_a?(Exception) or @block.nil?
15
15
  response
16
16
  else
17
- @block.call(response) rescue $!
17
+ @block.call(response) rescue $! # run the test
18
18
  end
19
19
 
20
- Auger::Result.new(self, outcome)
20
+ result = outcome.is_a?(Result) ? outcome : Auger::Result.new(outcome)
21
+ result.test = self
22
+ result
21
23
  end
22
24
 
23
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-21 00:00:00.000000000 Z
13
+ date: 2012-06-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 1.8.22
184
+ rubygems_version: 1.8.23
185
185
  signing_key:
186
186
  specification_version: 3
187
187
  summary: App && infrastructure testing DSL