rx-rspec 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/lib/rx-rspec/exactly.rb +7 -1
- data/lib/rx-rspec/first.rb +4 -1
- data/lib/rx-rspec/include.rb +4 -1
- data/lib/rx-rspec/nothing.rb +39 -0
- data/lib/rx-rspec/shared.rb +9 -0
- data/rx-rspec.gemspec +1 -1
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea42b945e59e9144d939237c9388170601eb97c8
|
4
|
+
data.tar.gz: a92e9dffc00ac1d9f9ff15b10defa294d4cc9f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 224d617fa86f43db7611cb5bf5eb94e7bb6503acb3f5d1a50ab55401f13f0687da030800af328e5b3a92793ade520a33c5ea19c64678a9d80ea134021f36da7b
|
7
|
+
data.tar.gz: afc76bd47831a7f388a4a9d4d0f59c01a5a5db5481dd15985f5a13a9e883e89b9acbb20c8841bd994bb2b45790c06bf0dbd98a0d9f317ffe6a9ad3939eabbaad
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -13,7 +13,7 @@ The asynchronous nature of RxRuby makes it hard to write good specs for code tha
|
|
13
13
|
|
14
14
|
The goal of rx-rspec is to provide powerful matchers that lets you express your expectations in a traditional rspec-like synchronous manner.
|
15
15
|
|
16
|
-
Currently, the ambition of this project is simply to support the use cases that I encounter in my own usage of RxRuby. Your pull requests are
|
16
|
+
Currently, the ambition of this project is simply to support the use cases that I encounter in my own usage of RxRuby. Your pull requests are welcome.
|
17
17
|
|
18
18
|
## Usage
|
19
19
|
|
@@ -37,6 +37,7 @@ end
|
|
37
37
|
|
38
38
|
rx-spec include the following matchers:
|
39
39
|
|
40
|
-
- **
|
40
|
+
- **emit_nothing()** matches an observable that completes without emitting events or erroring.
|
41
|
+
- **emit_exactly()** matches against all items produced by the observable and requires the observable to be completed.
|
41
42
|
- **emit_first()** matches against the first elements of the observable, but does not require it to complete
|
42
43
|
- **emit_include()** consumes elements until the expected elements have occurred
|
data/lib/rx-rspec/exactly.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
require 'rx-rspec/shared'
|
2
3
|
|
3
4
|
# TODO:
|
4
5
|
# - should have specific timeout message 'x seconds waiting for y'
|
5
6
|
|
6
7
|
RSpec::Matchers.define :emit_exactly do |*expected|
|
8
|
+
include RxRspec::Shared
|
9
|
+
|
7
10
|
events = []
|
8
11
|
errors = []
|
9
12
|
match do |actual|
|
@@ -28,14 +31,17 @@ RSpec::Matchers.define :emit_exactly do |*expected|
|
|
28
31
|
end.join
|
29
32
|
|
30
33
|
return false unless errors.empty?
|
34
|
+
@actual = events
|
31
35
|
values_match? expected, events
|
32
36
|
end
|
33
37
|
|
38
|
+
diffable
|
39
|
+
|
34
40
|
failure_message do
|
35
41
|
if errors.empty?
|
36
42
|
"expected #{events} to match #{expected}"
|
37
43
|
else
|
38
|
-
|
44
|
+
present_error(expected, errors[0])
|
39
45
|
end
|
40
46
|
end
|
41
47
|
end
|
data/lib/rx-rspec/first.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
require 'rx-rspec/shared'
|
2
3
|
|
3
4
|
# TODO:
|
4
5
|
# - should have specific timeout message 'x seconds waiting for y'
|
5
6
|
|
6
7
|
RSpec::Matchers.define :emit_first do |*expected|
|
8
|
+
include RxRspec::Shared
|
9
|
+
|
7
10
|
events = []
|
8
11
|
errors = []
|
9
12
|
completed = []
|
@@ -37,7 +40,7 @@ RSpec::Matchers.define :emit_first do |*expected|
|
|
37
40
|
if errors.empty?
|
38
41
|
"expected #{events} to emit at least #{expected}"
|
39
42
|
else
|
40
|
-
|
43
|
+
present_error(expected, errors[0])
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
data/lib/rx-rspec/include.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
require 'rx-rspec/shared'
|
2
3
|
|
3
4
|
# TODO:
|
4
5
|
# - should have specific timeout message 'x seconds waiting for y'
|
5
6
|
|
6
7
|
RSpec::Matchers.define :emit_include do |*expected|
|
8
|
+
include RxRspec::Shared
|
9
|
+
|
7
10
|
events = []
|
8
11
|
errors = []
|
9
12
|
completed = []
|
@@ -38,7 +41,7 @@ RSpec::Matchers.define :emit_include do |*expected|
|
|
38
41
|
if errors.empty?
|
39
42
|
"expected #{events} to include #{expected}"
|
40
43
|
else
|
41
|
-
|
44
|
+
present_error(expected, errors[0])
|
42
45
|
end
|
43
46
|
end
|
44
47
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rx-rspec/shared'
|
3
|
+
|
4
|
+
# TODO:
|
5
|
+
# - should have specific timeout message 'x seconds waiting for y'
|
6
|
+
|
7
|
+
RSpec::Matchers.define :emit_nothing do |*expected|
|
8
|
+
include RxRspec::Shared
|
9
|
+
|
10
|
+
events = []
|
11
|
+
errors = []
|
12
|
+
completed = []
|
13
|
+
match do |actual|
|
14
|
+
Thread.new do
|
15
|
+
actual.subscribe(
|
16
|
+
lambda { |event| events << event },
|
17
|
+
lambda { |err| errors << err },
|
18
|
+
lambda { completed << :complete }
|
19
|
+
)
|
20
|
+
for n in 1..10
|
21
|
+
break unless completed.empty?
|
22
|
+
break unless errors.empty? && events.empty?
|
23
|
+
sleep(0.05)
|
24
|
+
end
|
25
|
+
raise 'timeout' if errors.empty? && events.empty? && completed.empty?
|
26
|
+
end.join
|
27
|
+
|
28
|
+
return false unless errors.empty?
|
29
|
+
return events.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
failure_message do
|
33
|
+
if errors.empty?
|
34
|
+
"unexpected #{events[0]} emitted"
|
35
|
+
else
|
36
|
+
present_error(expected, errors[0])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/rx-rspec.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'rx-rspec'
|
3
|
-
spec.version = '0.
|
3
|
+
spec.version = '0.3.0'
|
4
4
|
spec.summary = 'rspec testing support for RxRuby'
|
5
5
|
spec.description = 'Writing specs for reactive streams is tricky both because of their asynchronous nature and because their next/error/completed semantics. The goal of rx-rspec is to provide powerful matchers that lets you express your expectations in a traditional rspec-like synchronous manner.'
|
6
6
|
spec.authors = ['Anders Qvist']
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rx-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anders Qvist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rx
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.13'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: byebug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
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
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: codeclimate-test-reporter
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: Writing specs for reactive streams is tricky both because of their asynchronous
|
@@ -103,8 +103,8 @@ executables: []
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
-
-
|
107
|
-
-
|
106
|
+
- .gitignore
|
107
|
+
- .travis.yml
|
108
108
|
- Gemfile
|
109
109
|
- Gemfile.lock
|
110
110
|
- LICENSE.md
|
@@ -113,6 +113,8 @@ files:
|
|
113
113
|
- lib/rx-rspec/exactly.rb
|
114
114
|
- lib/rx-rspec/first.rb
|
115
115
|
- lib/rx-rspec/include.rb
|
116
|
+
- lib/rx-rspec/nothing.rb
|
117
|
+
- lib/rx-rspec/shared.rb
|
116
118
|
- rx-rspec.gemspec
|
117
119
|
homepage: http://github.org/bittrance/rx-rspec
|
118
120
|
licenses:
|
@@ -124,17 +126,17 @@ require_paths:
|
|
124
126
|
- lib
|
125
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
128
|
requirements:
|
127
|
-
- -
|
129
|
+
- - '>='
|
128
130
|
- !ruby/object:Gem::Version
|
129
131
|
version: 2.0.0
|
130
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
133
|
requirements:
|
132
|
-
- -
|
134
|
+
- - '>='
|
133
135
|
- !ruby/object:Gem::Version
|
134
136
|
version: '0'
|
135
137
|
requirements: []
|
136
138
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.0.14.1
|
138
140
|
signing_key:
|
139
141
|
specification_version: 4
|
140
142
|
summary: rspec testing support for RxRuby
|