rspec-message-within 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/.travis.yml +9 -0
- data/lib/rspec/message/within.rb +38 -61
- data/lib/rspec/message/within/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MGY0MzBiODNkZWFmOTU0OWZkZWM3MDY4NWMzZTdhNWViMjNkZDBjYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YmRiN2Q5Y2U1ZGI4MzQ3MGY3Y2QxOWUyMTNhMzgzYWYwNjk1NmQxMA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmUwMmY2MzJkZThkMjdlMDVmZGM5NzIxMGRiNTllNGRlMGViMWQwODJjYzg3
|
10
|
+
OGRhZGRmZDY4MDE1MGI1OWY2NTJmMGI3ODIwZTJmNmI0MmMyNWVkMTkzNzEz
|
11
|
+
ODZlYjVlZmFlNDM5ZGRjMDBiNjkyYjM3NWRiZjEyYzg0NzIwOTE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODZmNTQ5ZDk3NjE3MDc5NDNjZGQ3NTBiNTJkY2M0MmExNzAwNmRlNDJhMTYy
|
14
|
+
NzFhYTI3YzEyYzEzM2M1MWVkYjJhZmE4YWI4ZTUyY2U4NWRlMWMwYzdiMmM0
|
15
|
+
OGI1MTBkMTU4YmM4N2YzZjlkNzg2YmMzN2IzZjU0NmVjNTZmZjU=
|
data/.travis.yml
ADDED
data/lib/rspec/message/within.rb
CHANGED
@@ -2,90 +2,67 @@ require 'rspec/message/within/version'
|
|
2
2
|
require 'rspec/mocks'
|
3
3
|
|
4
4
|
module RSpec
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
break if yield
|
13
|
-
sleep 0
|
14
|
-
end
|
5
|
+
module MessageWithin
|
6
|
+
def self.until(within_time)
|
7
|
+
if within_time && within_time > 0.0
|
8
|
+
time = Time.now + within_time
|
9
|
+
while time > Time.now
|
10
|
+
break if yield
|
11
|
+
sleep 0
|
15
12
|
end
|
16
13
|
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
base.send :define_method, :verify_messages_received, InstanceMethods.instance_method(:verify_messages_received)
|
18
|
+
module RSpec
|
19
|
+
module Mocks
|
20
|
+
class MessageExpectation
|
21
|
+
alias_method :orig_verify_messages_received, :verify_messages_received
|
22
|
+
def verify_messages_received
|
23
|
+
MessageWithin.until(@within_time || 0) do
|
24
|
+
expected_messages_received? and !negative?
|
26
25
|
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
Within.until(@within_time || 0) do
|
31
|
-
expected_messages_received? and !negative?
|
32
|
-
end
|
33
|
-
|
34
|
-
orig_verify_messages_received
|
35
|
-
end
|
27
|
+
orig_verify_messages_received
|
28
|
+
end
|
36
29
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
30
|
+
def within(time)
|
31
|
+
@within_time = time
|
32
|
+
self
|
42
33
|
end
|
34
|
+
end
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
module Matchers
|
37
|
+
class Receive
|
38
|
+
def within(*args, &block)
|
39
|
+
@recorded_customizations << ::RSpec::Mocks::Matchers::Receive::Customization.new(:within, args, block)
|
40
|
+
self
|
47
41
|
end
|
48
42
|
|
49
|
-
|
50
|
-
|
51
|
-
@recorded_customizations << ::RSpec::Mocks::Matchers::Receive::Customization.new(:within, args, block)
|
52
|
-
self
|
53
|
-
end
|
54
|
-
def seconds
|
55
|
-
self
|
56
|
-
end
|
43
|
+
def seconds
|
44
|
+
self
|
57
45
|
end
|
58
46
|
end
|
47
|
+
end
|
59
48
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
base.send :undef_method, :expectation_fulfilled?
|
64
|
-
base.send :define_method, :expectation_fulfilled?, InstanceMethods.instance_method(:expectation_fulfilled?)
|
65
|
-
end
|
66
|
-
|
67
|
-
module InstanceMethods
|
68
|
-
def expectation_fulfilled?
|
69
|
-
Within.until(@within_time || 0) do
|
70
|
-
orig_expectation_fulfilled?
|
71
|
-
end
|
49
|
+
module AnyInstance
|
50
|
+
class ExpectationChain
|
51
|
+
alias_method :orig_expectation_fulfilled?, :expectation_fulfilled?
|
72
52
|
|
53
|
+
def expectation_fulfilled?
|
54
|
+
RSpec::MessageWithin.until(@within_time || 0) do
|
73
55
|
orig_expectation_fulfilled?
|
74
56
|
end
|
57
|
+
|
58
|
+
orig_expectation_fulfilled?
|
75
59
|
end
|
76
|
-
end
|
77
60
|
|
78
|
-
module ChainPatch
|
79
61
|
def within(time)
|
80
62
|
@within_time = time
|
81
63
|
self
|
82
64
|
end
|
83
65
|
end
|
84
|
-
|
85
|
-
::RSpec::Mocks::MessageExpectation.send :include, MessageExpectationPatch
|
86
|
-
::RSpec::Mocks::AnyInstance::Chain.send :include, ChainPatch
|
87
|
-
::RSpec::Mocks::AnyInstance::ExpectationChain.send :include, ExpectationChainPatch
|
88
|
-
::RSpec::Mocks::Matchers::Receive.send :include, ReceivePatch
|
89
66
|
end
|
90
67
|
end
|
91
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-message-within
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: rake
|
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
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
|
+
- .travis.yml
|
77
78
|
- Gemfile
|
78
79
|
- LICENSE.txt
|
79
80
|
- README.md
|
@@ -93,17 +94,17 @@ require_paths:
|
|
93
94
|
- lib
|
94
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
96
|
requirements:
|
96
|
-
- - '>='
|
97
|
+
- - ! '>='
|
97
98
|
- !ruby/object:Gem::Version
|
98
99
|
version: '0'
|
99
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
101
|
requirements:
|
101
|
-
- - '>='
|
102
|
+
- - ! '>='
|
102
103
|
- !ruby/object:Gem::Version
|
103
104
|
version: '0'
|
104
105
|
requirements: []
|
105
106
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.0.
|
107
|
+
rubygems_version: 2.0.7
|
107
108
|
signing_key:
|
108
109
|
specification_version: 4
|
109
110
|
summary: expect(object).to receive(:message).within(:some).seconds
|