wires-test 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wires/test.rb +57 -5
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd0144c2e8b8371e6fde9acd0fc5a40a79276ac6
|
4
|
+
data.tar.gz: 842566c9931b47044d2ca703bb46d6d7f6d192c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edd7fb5f62c0fe7f87cd878ef87ca6e060700aff9bc38902fd2f436b3935c1b35d4839ff6c757b7caa091e263f0a79b9d45e57e9d6c85ec0e4f13b195f47b409
|
7
|
+
data.tar.gz: f9e890e4da08d0ebfe69d6c22f66f1aaceea17864ef7b298075a5eff952716453ee048a74b2147b5e2c21bf04653be21f80b8190b8c3012e5fee8b9845224a63
|
data/lib/wires/test.rb
CHANGED
@@ -4,11 +4,63 @@ require 'minitest/autorun'
|
|
4
4
|
|
5
5
|
module Wires
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
module Test
|
8
|
+
|
9
|
+
module Helper
|
10
|
+
|
11
|
+
def before_setup
|
12
|
+
@received_wires_events = []
|
13
|
+
Channel.before_fire { |e,c| @received_wires_events << [e,c] }
|
14
|
+
Hub.run
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def after_teardown
|
19
|
+
super
|
20
|
+
Hub.kill
|
21
|
+
clear_fired
|
22
|
+
end
|
23
|
+
|
24
|
+
def fired?(event,channel='*', clear:false, exclusive:false, plurality:nil,
|
25
|
+
exact_event:false, exact_channel:false, &block)
|
26
|
+
key_event = Event.new_from event
|
27
|
+
key_chan = Channel.new channel
|
28
|
+
|
29
|
+
results = @received_wires_events.select { |e,c|
|
30
|
+
(exact_event ? (key_event.class == e.class) : (key_event =~ e)) and
|
31
|
+
(exact_channel ? (key_chan === c) : (key_chan =~ c))
|
32
|
+
}
|
33
|
+
|
34
|
+
clear_fired if clear
|
35
|
+
|
36
|
+
return false if results.empty?
|
37
|
+
return false if exclusive and (@received_wires_events != results)
|
38
|
+
return false if plurality and (results.size != plurality)
|
39
|
+
|
40
|
+
results.each(&block) # Execute passed block for each match
|
41
|
+
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
def assert_fired(event, channel='*', assert_string=nil, **options, &block)
|
46
|
+
assert fired?(event, channel, **options, &block), assert_string||\
|
47
|
+
"Expected an event matching #{event.inspect}"\
|
48
|
+
" to have been fired on channel #{channel.inspect}."
|
49
|
+
end
|
50
|
+
|
51
|
+
def refute_fired(event, channel='*', assert_string=nil, **options, &block)
|
52
|
+
refute fired?(event, channel, **options, &block), assert_string||\
|
53
|
+
"Expected no events matching #{event.inspect}"\
|
54
|
+
" to have been fired on channel #{channel.inspect}."
|
55
|
+
end
|
56
|
+
|
57
|
+
def clear_fired
|
58
|
+
@received_wires_events.clear
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Unit < Minitest::Unit; include Test::Helper; end
|
63
|
+
class Spec < Minitest::Spec; include Test::Helper; end
|
12
64
|
end
|
13
65
|
|
14
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wires-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe McIlvain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wires
|
@@ -25,35 +25,35 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
33
|
+
version: '4.3'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: jemc-reporter
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '>='
|
@@ -74,7 +74,7 @@ extra_rdoc_files: []
|
|
74
74
|
files:
|
75
75
|
- lib/wires/test.rb
|
76
76
|
- LICENSE
|
77
|
-
homepage: https://github.com/jemc/wires/
|
77
|
+
homepage: https://github.com/jemc/wires-test/
|
78
78
|
licenses:
|
79
79
|
- 'Copyright (c) Joe McIlvain. All rights reserved '
|
80
80
|
metadata: {}
|