Class: Errands::TestHelpers::Wrapper
Defined Under Namespace
Classes: Vanilla
Class Method Summary
collapse
Instance Method Summary
collapse
extended, included, #set_store
Constructor Details
Returns a new instance of Wrapper.
67
68
69
70
|
# File 'lib/errands/test_helpers/wrapper.rb', line 67
def initialize
set_store :errands_test
our_store!
end
|
Class Method Details
.after ⇒ Object
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/errands/test_helpers/wrapper.rb', line 96
def self.after
threads_cleanup
if @instance
@instance.stop_helped if @instance.helped
@instance.theirs_reset!
end
@instance = nil
end
|
.help(helped, options = {}, &block) ⇒ Object
61
62
63
64
65
|
# File 'lib/errands/test_helpers/wrapper.rb', line 61
def self.help(helped, options = {}, &block)
helper
@instance.help helped, &block
end
|
.helper ⇒ Object
57
58
59
|
# File 'lib/errands/test_helpers/wrapper.rb', line 57
def self.helper
@instance = new
end
|
.threads_cleanup ⇒ Object
107
108
109
110
111
|
# File 'lib/errands/test_helpers/wrapper.rb', line 107
def self.threads_cleanup
while (t = Thread.list.select { |t| t[:errands] } - [Thread.main]).any?
t.each &:exit
end
end
|
Instance Method Details
#help(helped) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/errands/test_helpers/wrapper.rb', line 76
def help(helped)
(our[:helped] = helped).tap do |i|
i.instance_variable_set '@errands_wait_timeout', 10
i.start unless i.started?
yield i if block_given?
end
end
|
#helped(i = nil) ⇒ Object
84
85
86
|
# File 'lib/errands/test_helpers/wrapper.rb', line 84
def helped(i = nil)
i ? our[:helped] = i : our[:helped]
end
|
#push_event(e) ⇒ Object
88
89
90
|
# File 'lib/errands/test_helpers/wrapper.rb', line 88
def push_event(e)
theirs && theirs[:events] && theirs[:events] << e
end
|
#stop_helped ⇒ Object
113
114
115
116
|
# File 'lib/errands/test_helpers/wrapper.rb', line 113
def stop_helped
helped.stop
helped.wait_for :stopped
end
|
#theirs ⇒ Object
72
73
74
|
# File 'lib/errands/test_helpers/wrapper.rb', line 72
def theirs
Vanilla.theirs
end
|
#theirs_reset! ⇒ Object
92
93
94
|
# File 'lib/errands/test_helpers/wrapper.rb', line 92
def theirs_reset!
theirs && theirs.clear
end
|