rx-rspec 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b36a682d9edba3b5f7b8811178782c4492cf765
4
- data.tar.gz: 5317201f7b99a18bcdaedb4aa112e327e50ae76c
3
+ metadata.gz: f6507c53feee706f281f8077a6ccc6abb757b237
4
+ data.tar.gz: 8cd2b5dbcaa43a217e19515fed6413bc220181d3
5
5
  SHA512:
6
- metadata.gz: 222a02a74a8e05e81c2c292dde52e3ff32305952afe57199824ba94df2e70ee6ad36dab36e95ea873a7f4a3cb8d90a31b154e0051c4d8287ed14c8eb18d28c4e
7
- data.tar.gz: 1dffb8bb92400eea6db2fa3ccff0cf2c83e79c90fbb82d8c8814b53355a23e08ea6ceb9c6e5af1d2598eda2ceea925c40aa0142ba3f2fcf3275a802d745527da
6
+ metadata.gz: 9a7b1301ff7b25c0f2dda07b40016d436ebf1323a1d20c52a7dfa694f12e3bfebe1daa5221af7d7304a352623f4c3b2e443f6d670a0ecb32d71675dced69c50c
7
+ data.tar.gz: 29e1f358941a59f34f8f103ac0214bb8957d36bc47d75650767647646737d885d83443d0022a69c0541dea2da1ec1742dee861794f95e5b839855b81ab7f943d
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  .bundle/
2
2
  vendor/
3
+ coverage/
3
4
  rx-rspec-*.gem
4
5
  .byebug_history
@@ -4,3 +4,9 @@ rvm:
4
4
  - 2.2
5
5
  script:
6
6
  - bundle exec rspec -c -fd
7
+ addons:
8
+ code_climate:
9
+ repo_token: '${CODECLIMATE_REPO_TOKEN}'
10
+ after_success:
11
+ - bundle exec codeclimate-test-reporter
12
+
@@ -1,14 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rx-rspec (0.1.0)
4
+ rx-rspec (0.1.1)
5
5
  rx
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  byebug (9.0.6)
11
+ codeclimate-test-reporter (1.0.3)
12
+ simplecov
11
13
  diff-lcs (1.2.5)
14
+ docile (1.1.5)
15
+ json (2.0.2)
12
16
  rspec (3.5.0)
13
17
  rspec-core (~> 3.5.0)
14
18
  rspec-expectations (~> 3.5.0)
@@ -23,6 +27,11 @@ GEM
23
27
  rspec-support (~> 3.5.0)
24
28
  rspec-support (3.5.0)
25
29
  rx (0.0.3)
30
+ simplecov (0.12.0)
31
+ docile (~> 1.1.0)
32
+ json (>= 1.8, < 3)
33
+ simplecov-html (~> 0.10.0)
34
+ simplecov-html (0.10.0)
26
35
 
27
36
  PLATFORMS
28
37
  ruby
@@ -30,8 +39,10 @@ PLATFORMS
30
39
  DEPENDENCIES
31
40
  bundler (~> 1.13)
32
41
  byebug
42
+ codeclimate-test-reporter
33
43
  rspec (~> 3.0)
34
44
  rx-rspec!
45
+ simplecov
35
46
 
36
47
  BUNDLED WITH
37
48
  1.13.6
@@ -0,0 +1,21 @@
1
+ # The MIT License
2
+
3
+ Copyright (c) 2016 Anders Qvist
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Rspec matchers for RxRuby observables
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/rx-rspec.svg)](https://badge.fury.io/rb/rx-rspec)
4
+ [![Build Status](https://travis-ci.org/bittrance/rx-rspec.svg?branch=master)](https://travis-ci.org/bittrance/rx-rspec)
5
+ [![Code Climate](https://codeclimate.com/github/bittrance/rx-rspec/badges/gpa.svg)](https://codeclimate.com/github/bittrance/rx-rspec)
6
+ [![Test Coverage](https://codeclimate.com/github/bittrance/rx-rspec/badges/coverage.svg)](https://codeclimate.com/github/bittrance/rx-rspec/coverage)
7
+
3
8
  ## Rationale
4
9
 
5
10
  The asynchronous nature of RxRuby makes it hard to write good specs for code that returns observables. The complexity of next/error/completed notifications can also easily trip up a naive spec.
@@ -1,3 +1,44 @@
1
+ RSpec::Matchers.define :emit_include do |*expected|
2
+ events = []
3
+ errors = []
4
+ completed = []
5
+
6
+ match do |actual|
7
+ expected = expected.dup
8
+ Thread.new do
9
+ deadline = Time.now + 0.5
10
+ actual.subscribe_on_error { |err| errors << err }
11
+ subscription = actual.delay(0).subscribe(
12
+ lambda do |event|
13
+ events << event
14
+ idx = expected.index { |exp| values_match?(exp, event) }
15
+ expected.delete_at(idx) unless idx.nil?
16
+ subscription.unsubscribe if expected.empty?
17
+ end,
18
+ lambda {}, # Seems we cannot get here
19
+ lambda { completed << :complete }
20
+ )
21
+
22
+ until Time.now > deadline
23
+ break if expected.empty?
24
+ break unless completed.empty? && errors.empty?
25
+ sleep(0.05)
26
+ end
27
+ raise 'timeout' if Time.now > deadline
28
+ end.join
29
+
30
+ expected.empty?
31
+ end
32
+
33
+ failure_message do
34
+ if errors.empty?
35
+ "expected #{events} to include #{expected}"
36
+ else
37
+ "expected #{expected} but received error #{errors[0].inspect}"
38
+ end
39
+ end
40
+ end
41
+
1
42
  RSpec::Matchers.define :emit_exactly do |*expected|
2
43
  events = []
3
44
  errors = []
@@ -23,22 +64,7 @@ RSpec::Matchers.define :emit_exactly do |*expected|
23
64
  end.join
24
65
 
25
66
  return false unless errors.empty?
26
-
27
- expected.zip(events).all? do |exp, evt|
28
- if exp.respond_to?(:matches?)
29
- exp.matches?(evt)
30
- else
31
- exp == evt
32
- end
33
- end
34
- end
35
-
36
- description do
37
- if expected.size == 1
38
- "emit #{expected}"
39
- else
40
- "emit exactly #{expected.size} items"
41
- end
67
+ values_match? expected, events
42
68
  end
43
69
 
44
70
  failure_message do
@@ -48,6 +74,4 @@ RSpec::Matchers.define :emit_exactly do |*expected|
48
74
  "expected #{expected} but received error #{errors[0].inspect}"
49
75
  end
50
76
  end
51
-
52
- diffable
53
77
  end
@@ -1,12 +1,11 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'rx-rspec'
3
- spec.version = '0.1.0'
4
- spec.date = '2016-12-28'
3
+ spec.version = '0.1.1'
5
4
  spec.summary = 'rspec testing support for RxRuby'
6
- spec.description = 'Writing specs for reactive streams is tricky both because of their asynchronous nature and because their semantics. This module provides various matchers that allows you to write ordinary-looking specs that assert on the nature of your observables.'
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.'
7
6
  spec.authors = ['Anders Qvist']
8
7
  spec.email = 'bittrance@gmail.com'
9
- spec.homepage = 'http://rubygems.org/gems/rx-rspec'
8
+ spec.homepage = 'http://github.org/bittrance/rx-rspec'
10
9
  spec.license = 'MIT'
11
10
 
12
11
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^spec/) }
@@ -18,4 +17,6 @@ Gem::Specification.new do |spec|
18
17
  spec.add_development_dependency 'bundler', '~> 1.13'
19
18
  spec.add_development_dependency 'byebug'
20
19
  spec.add_development_dependency 'rspec', '~> 3.0'
20
+ spec.add_development_dependency 'simplecov'
21
+ spec.add_development_dependency 'codeclimate-test-reporter'
21
22
  end
metadata CHANGED
@@ -1,87 +1,117 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rx-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anders Qvist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-28 00:00:00.000000000 Z
11
+ date: 2017-01-04 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
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codeclimate-test-reporter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  description: Writing specs for reactive streams is tricky both because of their asynchronous
70
- nature and because their semantics. This module provides various matchers that allows
71
- you to write ordinary-looking specs that assert on the nature of your observables.
98
+ nature and because their next/error/completed semantics. The goal of rx-rspec is
99
+ to provide powerful matchers that lets you express your expectations in a traditional
100
+ rspec-like synchronous manner.
72
101
  email: bittrance@gmail.com
73
102
  executables: []
74
103
  extensions: []
75
104
  extra_rdoc_files: []
76
105
  files:
77
- - .gitignore
78
- - .travis.yml
106
+ - ".gitignore"
107
+ - ".travis.yml"
79
108
  - Gemfile
80
109
  - Gemfile.lock
110
+ - LICENSE.md
81
111
  - README.md
82
112
  - lib/rx-rspec/matchers.rb
83
113
  - rx-rspec.gemspec
84
- homepage: http://rubygems.org/gems/rx-rspec
114
+ homepage: http://github.org/bittrance/rx-rspec
85
115
  licenses:
86
116
  - MIT
87
117
  metadata: {}
@@ -91,17 +121,17 @@ require_paths:
91
121
  - lib
92
122
  required_ruby_version: !ruby/object:Gem::Requirement
93
123
  requirements:
94
- - - '>='
124
+ - - ">="
95
125
  - !ruby/object:Gem::Version
96
126
  version: 2.0.0
97
127
  required_rubygems_version: !ruby/object:Gem::Requirement
98
128
  requirements:
99
- - - '>='
129
+ - - ">="
100
130
  - !ruby/object:Gem::Version
101
131
  version: '0'
102
132
  requirements: []
103
133
  rubyforge_project:
104
- rubygems_version: 2.0.14.1
134
+ rubygems_version: 2.4.5.1
105
135
  signing_key:
106
136
  specification_version: 4
107
137
  summary: rspec testing support for RxRuby