fakes-rspec 2.0.0 → 2.1.0

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: a31d41eefe7f164425a119dfc161ae76b5dc97f5
4
- data.tar.gz: 386040e2e3f3d321ea271e7da32e4f36bff8154f
3
+ metadata.gz: 6f15ab9ad7b838efacecdedd5a966423ddb09a82
4
+ data.tar.gz: a8d59a776ec88595fbb4f4cb448a724889f1718b
5
5
  SHA512:
6
- metadata.gz: b4f539e4bdd5d82f65c604a8f1cb5821f67ffa9bd0152774433f8a285afc8073eec87442d7db13b135ffd3a76ebb2d13b60dced80c42ee2700890f991bc148d7
7
- data.tar.gz: 7630d8f7f2fec481fcb3fa8cb4d779a0e9b7b39258aa13d35676ac5a40e0d42f2fd435c1f36ddd441d9ceb91dfe80c85d755f2afd10ee405cef534c63ca4e532
6
+ metadata.gz: 4cae4c7c2d2c104289e5d920cf4ed790f0c2dac928d73b09494b4b18017e8ec70a3ec5d249bb18a19fe9f412aa6174f3ce7bdcd245194e82e14e5ef3b291ec66
7
+ data.tar.gz: 03f256c31540a8f82eccbe2a08b468ecd01958b00f10553ffb8e6c5a4f4dbd544ce8c1f1c7c64c883390359b4115dc877c66673b32a4b737f804768046487f3e
@@ -22,5 +22,5 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency('guard', "~> 2.6.1")
23
23
  s.add_development_dependency('guard-rspec', "~> 4.2.9")
24
24
  s.add_runtime_dependency('fakes', "~> 1.1.4")
25
- s.add_runtime_dependency('rspec', "~> 2.14.1")
25
+ s.add_runtime_dependency('rspec', "~> 3.0")
26
26
  end
@@ -3,11 +3,11 @@ require 'rspec'
3
3
  require 'singleton'
4
4
 
5
5
  require 'fakes_rspec/block_criteria'
6
- require 'fakes_rspec/matcher'
7
6
  require 'fakes_rspec/nullo_specification'
8
7
  require 'fakes_rspec/occurrences'
9
8
  require 'fakes_rspec/received_occurrences_criteria'
10
9
  require 'fakes_rspec/received_criteria'
10
+ require 'fakes_rspec/matcher'
11
11
 
12
12
  RSpec.configure do |config|
13
13
  config.after(:each) do
@@ -2,10 +2,14 @@ module RSpec
2
2
  def self.create_received_criteria_from(the_call)
3
3
  return Fakes::RSpec::ReceivedCriteria.new(the_call)
4
4
  end
5
- def self.create_received_occurences_criteria_from(the_call,occurence)
6
- return Fakes::RSpec::ReceivedOccurrencesCriteria.new(create_received_criteria_from(the_call),the_call,occurence)
5
+
6
+ def self.create_received_occurences_criteria_from(the_call, occurence)
7
+ occurence_spec = occurence.nil? ? Fakes::RSpec::NulloSpecification.instance : occurence
8
+
9
+ return Fakes::RSpec::ReceivedOccurrencesCriteria.new(create_received_criteria_from(the_call),the_call,occurence_spec)
7
10
  end
8
11
 
12
+
9
13
  Matchers.define :have_received_message do|symbol,*args|
10
14
  @occurence_spec = Fakes::RSpec::NulloSpecification.instance
11
15
 
@@ -39,8 +43,11 @@ module RSpec
39
43
  chain :occurs do|the_proc|
40
44
  @occurence_spec = Fakes::RSpec::Occurrences.from_block(the_proc)
41
45
  end
46
+
42
47
  match do|the_fake|
43
- RSpec.create_received_occurences_criteria_from(the_fake.received(symbol),@occurence_spec).is_satisfied_by(*args)
48
+ criteria = RSpec.create_received_occurences_criteria_from(the_fake.received(symbol),@occurence_spec)
49
+
50
+ criteria.is_satisfied_by(*args)
44
51
  end
45
52
  end
46
53
  end
@@ -1,5 +1,5 @@
1
1
  module Fakes
2
2
  module RSpec
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
@@ -6,8 +6,8 @@ module Fakes
6
6
  context "when matching" do
7
7
  subject{BlockCriteria.new(lambda{|item| return item == 1})}
8
8
  it "should match if its block returns true" do
9
- subject.is_satisfied_by(1).should be_true
10
- subject.is_satisfied_by(2).should be_false
9
+ expect(subject.is_satisfied_by(1)).to be_truthy
10
+ expect(subject.is_satisfied_by(2)).to be_falsy
11
11
  end
12
12
  end
13
13
  end
@@ -6,7 +6,9 @@ module Fakes
6
6
  subject{NulloSpecification.instance}
7
7
 
8
8
  it "should be satisfied by anything" do
9
- [1,10,"a",Object.new].each{|item| subject.is_satisfied_by(item).should be_true}
9
+ [1,10,"a",Object.new].each do |item|
10
+ expect(subject.is_satisfied_by(item)).to be_truthy
11
+ end
10
12
  end
11
13
  end
12
14
  end
@@ -7,8 +7,8 @@ module Fakes
7
7
  subject{Occurrences.exact(1)}
8
8
 
9
9
  it "should create a matcher that matches an exact number of occurrences" do
10
- subject.is_satisfied_by(1).should be_true
11
- subject.is_satisfied_by(2).should be_false
10
+ expect(subject.is_satisfied_by(1)).to be_truthy
11
+ expect(subject.is_satisfied_by(2)).to be_falsy
12
12
  end
13
13
  end
14
14
 
@@ -16,19 +16,19 @@ module Fakes
16
16
  subject{Occurrences.at_least(3)}
17
17
 
18
18
  it "should create a matcher that matches an exact number of occurrences" do
19
- subject.is_satisfied_by(3).should be_true
20
- subject.is_satisfied_by(4).should be_true
21
- subject.is_satisfied_by(2).should be_false
19
+ expect(subject.is_satisfied_by(3)).to be_truthy
20
+ expect(subject.is_satisfied_by(4)).to be_truthy
21
+ expect(subject.is_satisfied_by(2)).to be_falsy
22
22
  end
23
23
  end
24
24
  context "when creating an at most occurrence matcher" do
25
25
  subject{Occurrences.at_most(3)}
26
26
 
27
27
  it "should create a matcher that matches an exact number of occurrences" do
28
- subject.is_satisfied_by(3).should be_true
29
- subject.is_satisfied_by(2).should be_true
30
- subject.is_satisfied_by(1).should be_true
31
- subject.is_satisfied_by(4).should be_false
28
+ expect(subject.is_satisfied_by(3)).to be_truthy
29
+ expect(subject.is_satisfied_by(2)).to be_truthy
30
+ expect(subject.is_satisfied_by(1)).to be_truthy
31
+ expect(subject.is_satisfied_by(4)).to be_falsy
32
32
  end
33
33
  end
34
34
  end
@@ -10,7 +10,7 @@ module Fakes
10
10
 
11
11
  sut = ReceivedCriteria.new(item.received(:hello))
12
12
 
13
- sut.is_satisfied_by.should be_true
13
+ expect(sut.is_satisfied_by).to be_truthy
14
14
  end
15
15
  end
16
16
  context "when matching a call made with arguments" do
@@ -21,16 +21,16 @@ module Fakes
21
21
  end
22
22
  context "and we care about the arguments it was called with" do
23
23
  it "should match if it received the correct call" do
24
- @sut.is_satisfied_by("world").should be_true
24
+ expect(@sut.is_satisfied_by("world")).to be_truthy
25
25
  end
26
26
  it "should not match if the arguments provided are not in the call history" do
27
- @sut.is_satisfied_by("yo").should be_false
27
+ expect(@sut.is_satisfied_by("yo")).to be_falsy
28
28
  end
29
29
 
30
30
  end
31
31
  context "and we don't care about the arguments it was called with" do
32
32
  it "should match if it received a call to the method" do
33
- @sut.is_satisfied_by.should be_true
33
+ expect(@sut.is_satisfied_by).to be_truthy
34
34
  end
35
35
  end
36
36
  end
@@ -8,18 +8,20 @@ module Fakes
8
8
  let(:the_call){fake}
9
9
  let(:arg_set){fake}
10
10
  let(:the_arg){1}
11
+
11
12
  subject{ReceivedOccurrencesCriteria.new(original,the_call,occurrence)}
13
+
12
14
  context "when matching a call made" do
13
15
  context "and the original criteria is not satisfied" do
14
16
  before (:each) do
15
17
  original.stub(:is_satisfied_by).with(the_arg).and_return(false)
16
18
  end
17
19
  it "should not match" do
18
- subject.is_satisfied_by(the_arg).should be_false
20
+ expect(subject.is_satisfied_by(the_arg)).to be_falsy
19
21
  end
20
22
  it "should not use the occurrence or the call" do
21
- occurrence.should_not have_received_message(:is_satisfied_by)
22
- the_call.should_not have_received_message(:called_with)
23
+ expect(occurrence.received?(:is_satisfied_by)).to be_falsy
24
+ expect(the_call.received?(:called_with)).to be_falsy
23
25
  end
24
26
  end
25
27
  context "and the original criteria is satisfied" do
@@ -38,7 +40,7 @@ module Fakes
38
40
  @result = subject.is_satisfied_by
39
41
  end
40
42
  it "should match if the occurrence matches the total number of invocations" do
41
- @result.should be_true
43
+ expect(@result).to be_truthy
42
44
  end
43
45
  end
44
46
  context "and its occurrence is satisfied" do
@@ -46,7 +48,7 @@ module Fakes
46
48
  occurrence.stub(:is_satisfied_by).with(1).and_return(true)
47
49
  end
48
50
  it "should match" do
49
- subject.is_satisfied_by(the_arg).should be_true
51
+ expect(subject.is_satisfied_by(the_arg)).to be_truthy
50
52
  end
51
53
  end
52
54
  context "and its occurrence is not satisfied" do
@@ -54,7 +56,7 @@ module Fakes
54
56
  occurrence.stub(:is_satisfied_by).with(1).and_return(false)
55
57
  end
56
58
  it "should not match" do
57
- subject.is_satisfied_by(the_arg).should be_false
59
+ expect(subject.is_satisfied_by(the_arg)).to be_falsy
58
60
  end
59
61
  end
60
62
  end
@@ -6,11 +6,13 @@ describe "using the rspec extensions" do
6
6
  item.hello
7
7
  item.last("other")
8
8
 
9
- item.should_not have_received_message(:hello,"world")
10
- item.should have_received_message(:hello)
11
- item.should_not have_received_message(:once_more)
12
- item.should_not have_received_message(:last,"hello")
13
- item.should have_received_message(:last,"other")
9
+ expect(item).to_not have_received_message(:hello, "world")
10
+ expect(item).to have_received_message(:hello)
11
+ expect(item).to_not have_received_message(:hello,"world")
12
+ expect(item).to have_received_message(:hello)
13
+ expect(item).to_not have_received_message(:once_more)
14
+ expect(item).to_not have_received_message(:last,"hello")
15
+ expect(item).to have_received_message(:last,"other")
14
16
  end
15
17
 
16
18
  it "should be able to determine if a call has been made a certain number of times" do
@@ -19,20 +21,22 @@ describe "using the rspec extensions" do
19
21
  item.hello
20
22
  item.last("other")
21
23
 
22
- item.should_not have_received_message(:hello,"world")
23
- item.should have_received_message(:hello).twice
24
- item.should have_received_message(:hello)
25
- item.should_not have_received_message(:once_more)
26
- item.should_not have_received_message(:last,"hello")
27
- item.should have_received_message(:last,"other").once
28
- item.should_not have_received_message(:last).twice
24
+
25
+ expect(item).to_not have_received_message(:hello,"world")
26
+ expect(item).to_not have_received_message(:hello,"world")
27
+ expect(item).to have_received_message(:hello).twice
28
+ expect(item).to have_received_message(:hello)
29
+ expect(item).to_not have_received_message(:once_more)
30
+ expect(item).to_not have_received_message(:last,"hello")
31
+ expect(item).to have_received_message(:last,"other").once
32
+ expect(item).to_not have_received_message(:last).twice
29
33
  end
30
34
 
31
35
  it "should be able to determine if a call was made once" do
32
36
  item = fake
33
37
  item.hello
34
38
 
35
- item.should have_received_message(:hello).once
39
+ expect(item).to have_received_message(:hello).once
36
40
  end
37
41
 
38
42
  it "should be able to determine if a call was made twice" do
@@ -40,7 +44,7 @@ describe "using the rspec extensions" do
40
44
  item.hello
41
45
  item.hello
42
46
 
43
- item.should have_received_message(:hello).twice
47
+ expect(item).to have_received_message(:hello).twice
44
48
  end
45
49
 
46
50
  it "should be able to determine if a call was made at least once" do
@@ -48,7 +52,7 @@ describe "using the rspec extensions" do
48
52
  item.hello
49
53
  item.hello
50
54
 
51
- item.should have_received_message(:hello).at_least_once
55
+ expect(item).to have_received_message(:hello).at_least_once
52
56
  end
53
57
 
54
58
  it "should be able to determine if a call was made at least twice" do
@@ -57,8 +61,8 @@ describe "using the rspec extensions" do
57
61
  item.hello
58
62
  item.hello
59
63
 
60
- item.should have_received_message(:hello).at_least_twice
61
- item.should have_received_message(:hello).at_least_twice
64
+ expect(item).to have_received_message(:hello).at_least_twice
65
+ expect(item).to have_received_message(:hello).at_least_twice
62
66
  end
63
67
 
64
68
 
@@ -68,8 +72,8 @@ describe "using the rspec extensions" do
68
72
  item.goodbye
69
73
  item.goodbye
70
74
 
71
- item.should have_received_message(:hello).at_most_once
72
- item.should_not have_received_message(:goodbye).at_most_once
75
+ expect(item).to have_received_message(:hello).at_most_once
76
+ expect(item).to_not have_received_message(:goodbye).at_most_once
73
77
  end
74
78
 
75
79
  it "should be able to determine if a call was made at most twice" do
@@ -79,8 +83,8 @@ describe "using the rspec extensions" do
79
83
  item.goodbye
80
84
  item.goodbye
81
85
 
82
- item.should have_received_message(:hello).at_most_twice
83
- item.should_not have_received_message(:goodbye).at_most_twice
86
+ expect(item).to have_received_message(:hello).at_most_twice
87
+ expect(item).to_not have_received_message(:goodbye).at_most_twice
84
88
  end
85
89
 
86
90
  it "should be able to determine if a call was made at least a specified number of times" do
@@ -90,22 +94,22 @@ describe "using the rspec extensions" do
90
94
  item.goodbye
91
95
  item.goodbye
92
96
 
93
- item.should have_received_message(:hello).at_most(1)
94
- item.should_not have_received_message(:goodbye).at_most(1)
97
+ expect(item).to have_received_message(:hello).at_most(1)
98
+ expect(item).to_not have_received_message(:goodbye).at_most(1)
95
99
  end
96
100
  context "using the arg matching style" do
97
101
  it "should be able to determing if a call was made using arg matchers" do
98
102
  item = fake
99
103
  item.hello("Yes")
100
104
 
101
- item.should have_received_message(:hello,arg_match.any)
105
+ expect(item).to have_received_message(:hello,arg_match.any)
102
106
  end
103
107
 
104
108
  it "should be able to determing if a call was made using a combination of arg matchers and explicit values" do
105
109
  item = fake
106
110
  item.hello("Yes",2)
107
111
 
108
- item.should have_received_message(:hello,arg_match.regex(/Y/),2)
112
+ expect(item).to have_received_message(:hello,arg_match.regex(/Y/),2)
109
113
  end
110
114
  end
111
115
  context "using class swapping" do
@@ -114,14 +118,14 @@ describe "using the rspec extensions" do
114
118
 
115
119
  Dir.stub(:exist?).and_return false
116
120
 
117
- Dir.exist('/').should be_false
121
+ expect(Dir.exist('/')).to be_falsy
118
122
  end
119
123
 
120
124
  it "should be able to determing if a call was made using a combination of arg matchers and explicit values" do
121
125
  item = fake
122
126
  item.hello("Yes",2)
123
127
 
124
- item.should have_received_message(:hello,arg_match.regex(/Y/),2)
128
+ expect(item).to have_received_message(:hello,arg_match.regex(/Y/),2)
125
129
  end
126
130
  end
127
131
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakes-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Develop With Passion®
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-26 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.14.1
75
+ version: '3.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.14.1
82
+ version: '3.0'
83
83
  description: Faking library that allows inspection of received calls after they have
84
84
  been made. Also supports tracking calls with multiple argument sets.
85
85
  email: