abt 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,12 +19,11 @@ Get it running locally first, here's an example:
19
19
  worker.test_config = @test_config
20
20
  worker.run_local
21
21
 
22
- Add notifier
22
+ Add built in notifier:
23
23
 
24
- worker.add_notifier("HipchatNotifier",{"hipchat_api_key"=>'secret_api_key',"room_name"=>'Room Name',"title"=>"From"})
25
- and/or
26
- worker.add_notifier("WebHookNotifier",{"url"=>'notification_url'})
27
- you could add as many notifiers as you need
24
+ worker.add_notifier(:hip_chat_notifier, :config=>{"hipchat_api_key"=>'secret_api_key', "room_name"=>'Room Name', "user_name"=>"AbtWorker"})
25
+
26
+ you can add as many notifiers as you need and even make your own (read down for how to build custom notifiers).
28
27
 
29
28
  Then try queuing it up.
30
29
 
@@ -40,14 +39,14 @@ Schedule it to run regularly to ensure you're always being covered.
40
39
 
41
40
  ## Custom notifiers
42
41
 
43
- ###All you need:
42
+ Here's how to build your own notifiers.
44
43
 
45
- * Implement in your notifier following methods:
44
+ * Implement in your notifier the following methods:
46
45
 
47
46
  setup configuration:
48
47
 
49
- def initialize(notifier_details)
50
- @url = notifier_details["url"]
48
+ def initialize(config)
49
+ @url = config["url"]
51
50
  end
52
51
 
53
52
  process simple text message
@@ -56,13 +55,12 @@ process simple text message
56
55
  puts message
57
56
  end
58
57
 
59
- if you need you could process more detailed results, 'result' is an instance of Test::Unit::TestResult
58
+ if you want more detailed results, 'result' is an instance of Test::Unit::TestResult
60
59
 
61
60
  def send_formatted_message(result)
62
61
  result.inspect
63
62
  end
64
63
 
64
+ Then to use it:
65
65
 
66
- * Add your custom notifier into 'notifiers' folder or just merge it
67
- * Add your notifier to worker
68
- worker.add_notifier("YourCustomNotifierClass",{"option_name"=>'option_value'})
66
+ worker.add_notifier(File.join(File.dirname(__FILE__), 'console_notifier'), :class_name=>'ConsoleNotifier', :config={})
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 3
4
+ :patch: 4
5
5
  :build: !!null
@@ -1,53 +1,49 @@
1
1
  require 'iron_worker'
2
2
  require 'json'
3
- # bump.....
4
- ARGV=[]
3
+
4
+ # bump.
5
+ ARGV=[] # this needs to stay here or else it won't run the correct tests
5
6
  module Abt
6
- #
7
- #class MiniTestWithHooks < MiniTest::Unit
8
- # def before_suites
9
- # end
10
- #
11
- # def after_suites
12
- # end
13
- #
14
- # def _run_suites(suites, type)
15
- # puts 'run_suites ' + suites.inspect + ' type=' + type.inspect
16
- # begin
17
- # before_suites
18
- # super(suites, type)
19
- # ensure
20
- # after_suites
21
- # end
22
- # end
23
- #
24
- #
25
- #
26
- # def _run_suite(suite, type)
27
- # puts 'run_suite ' + suite.inspect + ' type=' + type.inspect
28
- # begin
29
- # # suite.before_suite
30
- # super(suite, type)
31
- # ensure
32
- # # suite.after_suite
33
- # end
34
- # end
35
- #end
36
- #
37
- #..
7
+
8
+ @@notifiers = {}
9
+ @@notifiers[:hip_chat_notifier] = {:file=>'notifiers/hip_chat_notifier', :class_name=>'HipChatNotifier'}
10
+
11
+ def self.notifiers
12
+ @@notifiers
13
+ end
14
+
38
15
  class AbtWorker < IronWorker::Base
39
16
  merge_gem 'minitest', :require=>['minitest/unit', 'minitest/autorun']
40
17
  merge_gem 'test-unit', :require=>['test/unit/priority', 'test/unit/testcase', 'test/unit/assertions', 'test/unit']
41
18
  merge_gem 'git'
42
- merge_gem 'hipchat-api'
43
19
  merge_gem 'bundler'
44
20
  merge 'test_collector'
45
- merge_folder 'notifiers'
21
+ #merge_folder 'notifiers'
46
22
  attr_accessor :git_url, :test_config, :notifiers, :notify_every
47
23
 
48
- def add_notifier(notifier_name, notifier_details={})
49
- @notifiers||=[]
50
- @notifiers<<{"notifier_name"=>notifier_name, "notifier_details"=>notifier_details}
24
+ def initialize
25
+ @notifiers = []
26
+ end
27
+
28
+ def add_notifier(notifier_class, notifier_details={})
29
+ p notifier_class
30
+ p notifier_details
31
+ notifier_entry = {}
32
+ if notifier_class.instance_of?(Symbol)
33
+ p Abt.notifiers
34
+ n = Abt.notifiers[notifier_class]
35
+ puts "n=" + n.inspect
36
+ raise "Notifier not found: #{notifier_class}" if n.nil?
37
+ self.class.merge n[:file]
38
+ notifier_entry["class_name"] = n[:class_name]
39
+ notifier_entry["config"] = notifier_details[:config]
40
+ else
41
+ self.class.merge notifier_class
42
+ raise "Must include :class option" if notifier_details[:class_name].nil?
43
+ notifier_entry["class_name"] = notifier_details[:class_name]
44
+ notifier_entry["config"] = notifier_details[:config]
45
+ end
46
+ @notifiers << notifier_entry
51
47
  end
52
48
 
53
49
  def run
@@ -59,9 +55,6 @@ module Abt
59
55
  require File.join(File.dirname(__FILE__), '/gems/test-unit/lib/test/unit')
60
56
  require File.join(File.dirname(__FILE__), '/gems/minitest/lib/minitest/autorun')
61
57
  end
62
- # Test::Unit.run = false
63
- #MiniTest::Unit.runner = MiniTestWithHooks.new
64
- # g = Git.open(user_dir, :log => Logger.new(STDOUT))
65
58
  clone_dir = 'cloned'
66
59
  x = File.join(user_dir, clone_dir)
67
60
  p x
@@ -97,10 +90,12 @@ module Abt
97
90
  if notifiers
98
91
  notifiers.each do |notifier|
99
92
  puts "NOTIFIER:#{notifier.inspect}"
100
- Test::Unit::Notify::Notifier.add_notifier(Kernel.const_get(notifier["notifier_name"]).new(notifier["notifier_details"]))
93
+ Test::Unit::Notify::Notifier.add_notifier(Kernel.const_get(notifier["class_name"]).new(notifier["config"]))
101
94
  end
102
95
  end
96
+ puts 'Starting autorunner'
103
97
  Test::Unit::AutoRunner.run
98
+ puts 'Autorunner finished'
104
99
 
105
100
  if old_specs
106
101
  Gem.loaded_specs.clear
@@ -112,36 +107,7 @@ module Abt
112
107
  end
113
108
 
114
109
  end
115
- # ...
116
- # def suite_results_output(options={})
117
- # line_break = "\n"
118
- # if options[:format] == 'html'
119
- # line_break = "<br/>"
120
- # end
121
- # s = "Suite Results:#{line_break}"
122
- # s << "#{@num_failed} failed out of #{@num_tests} tests.#{line_break}"
123
- # if @num_failed > 0
124
- # @failed.each do |f|
125
- # s << "#{f.test_class}.#{f.test_method} failed: #{f.result.message}#{line_break}"
126
- # end
127
- # end
128
- # s << "Test suite duration: #{duration}ms.#{line_break}"
129
- # s
130
- # end
131
- #
132
- # def duration
133
- # ((@end_time.to_f - @start_time.to_f) * 1000.0).to_i
134
- # end
135
- #
136
- # def time_in_ms(t)
137
- # (t.to_f * 1000.0).to_i
138
- # end
139
- #
140
- # # callbacks
141
- # def on_complete
142
- #
143
- # end
144
- #
110
+
145
111
  end
146
112
 
147
113
  end
@@ -1,10 +1,11 @@
1
- class HipchatNotifier
1
+ class HipChatNotifier
2
+ IronWorker.config.merge_gem 'hipchat-api'
2
3
  require 'hipchat-api'
3
4
 
4
- def initialize(notifier_details)
5
- @client = HipChat::API.new(notifier_details["hipchat_api_key"])
6
- @room_name = notifier_details["room_name"]
7
- @title= notifier_details["title"]
5
+ def initialize(config)
6
+ @client = HipChat::API.new(config["token"])
7
+ @room_name = config["room_name"]
8
+ @user_name = config["user_name"] || "AbtWorker"
8
9
  end
9
10
 
10
11
  def send_formatted_message(result)
@@ -21,9 +22,9 @@ class HipchatNotifier
21
22
  def send_message(message,color='yellow')
22
23
  puts "sending_message #{message}"
23
24
  begin
24
- puts @client.rooms_message(@room_name, @title, message, false,color).body
25
+ puts @client.rooms_message(@room_name, @user_name, message, false,color).body
25
26
  rescue =>ex
26
27
  ex.inspect
27
28
  end
28
29
  end
29
- end
30
+ end
@@ -35,7 +35,7 @@ module Test
35
35
  def self.add_notifier(sender)
36
36
  @senders||=[]
37
37
  @senders<<sender
38
- puts "adding sender!#{@senders.inspect}"
38
+ puts "adding sender! #{@senders.inspect}"
39
39
  end
40
40
 
41
41
  def self.get_notifiers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: git
16
- requirement: &17412460 !ruby/object:Gem::Requirement
16
+ requirement: &10726500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,32 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *17412460
24
+ version_requirements: *10726500
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &10725240 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *10725240
36
+ - !ruby/object:Gem::Dependency
37
+ name: test-unit
38
+ requirement: &10723760 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *10723760
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: iron_worker
27
- requirement: &17374320 !ruby/object:Gem::Requirement
49
+ requirement: &10722560 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ! '>='
@@ -32,10 +54,32 @@ dependencies:
32
54
  version: '0'
33
55
  type: :runtime
34
56
  prerelease: false
35
- version_requirements: *17374320
57
+ version_requirements: *10722560
36
58
  - !ruby/object:Gem::Dependency
37
59
  name: git
38
- requirement: &17372020 !ruby/object:Gem::Requirement
60
+ requirement: &10721240 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *10721240
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: &10719700 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *10719700
80
+ - !ruby/object:Gem::Dependency
81
+ name: test-unit
82
+ requirement: &10718080 !ruby/object:Gem::Requirement
39
83
  none: false
40
84
  requirements:
41
85
  - - ! '>='
@@ -43,10 +87,10 @@ dependencies:
43
87
  version: '0'
44
88
  type: :runtime
45
89
  prerelease: false
46
- version_requirements: *17372020
90
+ version_requirements: *10718080
47
91
  - !ruby/object:Gem::Dependency
48
92
  name: iron_worker
49
- requirement: &17370600 !ruby/object:Gem::Requirement
93
+ requirement: &10716960 !ruby/object:Gem::Requirement
50
94
  none: false
51
95
  requirements:
52
96
  - - ! '>='
@@ -54,21 +98,21 @@ dependencies:
54
98
  version: '0'
55
99
  type: :runtime
56
100
  prerelease: false
57
- version_requirements: *17370600
101
+ version_requirements: *10716960
58
102
  description: Always Be Testing Yo! A testing framework that runs on IronWorker http://www.iron.io
59
103
  email: travis@iron.io
60
104
  executables: []
61
105
  extensions: []
62
106
  extra_rdoc_files:
63
- - README.markdown
107
+ - README.md
64
108
  files:
65
109
  - VERSION.yml
66
110
  - lib/abt.rb
67
111
  - lib/abt/abt_worker.rb
68
- - lib/abt/notifiers/hipchat_notifier.rb
112
+ - lib/abt/notifiers/hip_chat_notifier.rb
69
113
  - lib/abt/notifiers/web_hook_notifier.rb
70
114
  - lib/abt/test_collector.rb
71
- - README.markdown
115
+ - README.md
72
116
  homepage: https://github.com/iron-io/abt
73
117
  licenses: []
74
118
  post_install_message: