Class: Janky::Notifier::Mock
- Inherits:
-
Object
- Object
- Janky::Notifier::Mock
- Defined in:
- lib/janky/notifier/mock.rb
Overview
Mock notifier implementation used in testing environments.
Instance Attribute Summary collapse
-
#notifications ⇒ Object
readonly
Returns the value of attribute notifications.
Instance Method Summary collapse
- #completed(build) ⇒ Object
- #failure?(repo, branch, room_name) ⇒ Boolean
-
#initialize ⇒ Mock
constructor
A new instance of Mock.
- #notify(state, build) ⇒ Object
- #queued(build) ⇒ Object
- #reset! ⇒ Object
- #started(build) ⇒ Object
- #success?(repo, branch, room_name) ⇒ Boolean
Constructor Details
#initialize ⇒ Mock
Returns a new instance of Mock.
5 6 7 |
# File 'lib/janky/notifier/mock.rb', line 5 def initialize @notifications = [] end |
Instance Attribute Details
#notifications ⇒ Object (readonly)
Returns the value of attribute notifications.
9 10 11 |
# File 'lib/janky/notifier/mock.rb', line 9 def notifications @notifications end |
Instance Method Details
#completed(build) ⇒ Object
21 22 23 |
# File 'lib/janky/notifier/mock.rb', line 21 def completed(build) notify(:completed, build) end |
#failure?(repo, branch, room_name) ⇒ Boolean
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/janky/notifier/mock.rb', line 43 def failure?(repo, branch, room_name) room_name ||= Janky::ChatService.default_room_name builds = @notifications.select do |state, build| state == :completed && build.red? && build.repo_name == repo && build.branch_name == branch && build.room_name == room_name end builds.size == 1 end |
#notify(state, build) ⇒ Object
25 26 27 |
# File 'lib/janky/notifier/mock.rb', line 25 def notify(state, build) @notifications << [state, build] end |
#queued(build) ⇒ Object
11 12 |
# File 'lib/janky/notifier/mock.rb', line 11 def queued(build) end |
#reset! ⇒ Object
14 15 16 |
# File 'lib/janky/notifier/mock.rb', line 14 def reset! @notifications.clear end |
#started(build) ⇒ Object
18 19 |
# File 'lib/janky/notifier/mock.rb', line 18 def started(build) end |
#success?(repo, branch, room_name) ⇒ Boolean
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/janky/notifier/mock.rb', line 29 def success?(repo, branch, room_name) room_name ||= Janky::ChatService.default_room_name builds = @notifications.select do |state, build| state == :completed && build.green? && build.repo_name == repo && build.branch_name == branch && build.room_name == room_name end builds.size == 1 end |