verified_double 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +5 -0
- data/README.md +10 -1
- data/features/CHANGELOG.markdown +5 -0
- data/features/readme.md +10 -1
- data/lib/verified_double/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daa010e506d5bac557ecd6d866e90783556f0f47
|
4
|
+
data.tar.gz: e185e88d2f88a5337267d50598c34616242150a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e01c603415dd87dfcc15856c1f70aa1f75a0e9d1b8872480949c8da229cb9bd69ae6661b7db837db29abc94c44563e962d8f8457613c3dfd5b72fe5315989a4
|
7
|
+
data.tar.gz: fbc6ebaf22d52a0ea73f862c7b273eeda798eb2da085bd8c5bb0c0d03544efe3cab35066bf498836acfbeb3125cc266a097b6cfe19b5f7102aaadb6cffef481f
|
data/CHANGELOG.markdown
CHANGED
data/README.md
CHANGED
@@ -7,6 +7,7 @@ VerifiedDouble is a gem for verifying rspec mocks. The gem works similar to [rsp
|
|
7
7
|
For example, if I mock the created_at method of a model like this:
|
8
8
|
|
9
9
|
```ruby
|
10
|
+
# spec/foo_spec.rb
|
10
11
|
item = VerifiedDouble.of_instance(Item)
|
11
12
|
expect(item).to receive(:created_at).and_return(Time.now)
|
12
13
|
```
|
@@ -14,6 +15,7 @@ expect(item).to receive(:created_at).and_return(Time.now)
|
|
14
15
|
When I run the tests, the gem will look for a "contract test" tagged with the method's signature. This test should ensure that calling `#created_at` on Item will return a Time object.
|
15
16
|
|
16
17
|
```ruby
|
18
|
+
# spec/item_spec.rb
|
17
19
|
describe Item do
|
18
20
|
describe '#created_at()=>Time', verifies_contract: true do
|
19
21
|
it "tests something" do
|
@@ -46,6 +48,7 @@ And require it when running rspec:
|
|
46
48
|
Let's look again at the example above:
|
47
49
|
|
48
50
|
```ruby
|
51
|
+
# spec/foo_spec.rb
|
49
52
|
item = VerifiedDouble.of_instance(Item)
|
50
53
|
expect(item).to receive(:created_at).and_return(Time.now)
|
51
54
|
```
|
@@ -63,6 +66,7 @@ The following mocks are not verified:
|
|
63
66
|
You can then tag the test for `Item#created_at()=>Time` with the method signature:
|
64
67
|
|
65
68
|
```ruby
|
69
|
+
# spec/item_spec.rb
|
66
70
|
describe Item do
|
67
71
|
describe '#created_at()=>Time', verifies_contract: true do
|
68
72
|
it "tests something" do
|
@@ -76,11 +80,12 @@ Take note that:
|
|
76
80
|
|
77
81
|
1. The described class must be a class, not a string.
|
78
82
|
2. The described method must start with `#` if its an instance method and `.` if it's a class method.
|
79
|
-
3. You need to add the
|
83
|
+
3. You need to add the `verifies_contract: true` tag to the test.
|
80
84
|
|
81
85
|
If your testing style doesn't follow these conventions, you can tag the test with the whole method signature:
|
82
86
|
|
83
87
|
```ruby
|
88
|
+
# spec/item_spec.rb
|
84
89
|
describe 'Item' do
|
85
90
|
it "has a creation timestamp", verifies_contract: `Item#created_at()=>Time` do
|
86
91
|
#...
|
@@ -92,6 +97,10 @@ Since VerifiedDouble relies on tags to link mocks and contracts together, you'll
|
|
92
97
|
need to run the tests containing the contracts along with tests with the mocks in
|
93
98
|
order to clear the VerifiedDouble warnings.
|
94
99
|
|
100
|
+
```
|
101
|
+
rspec spec/foo_spec.rb spec/item_spec.rb
|
102
|
+
```
|
103
|
+
|
95
104
|
## Booleans
|
96
105
|
|
97
106
|
Since Ruby doesn't have Boolean class covering both `TrueClass` and `FalseClass`,
|
data/features/CHANGELOG.markdown
CHANGED
data/features/readme.md
CHANGED
@@ -7,6 +7,7 @@ VerifiedDouble is a gem for verifying rspec mocks. The gem works similar to [rsp
|
|
7
7
|
For example, if I mock the created_at method of a model like this:
|
8
8
|
|
9
9
|
```ruby
|
10
|
+
# spec/foo_spec.rb
|
10
11
|
item = VerifiedDouble.of_instance(Item)
|
11
12
|
expect(item).to receive(:created_at).and_return(Time.now)
|
12
13
|
```
|
@@ -14,6 +15,7 @@ expect(item).to receive(:created_at).and_return(Time.now)
|
|
14
15
|
When I run the tests, the gem will look for a "contract test" tagged with the method's signature. This test should ensure that calling `#created_at` on Item will return a Time object.
|
15
16
|
|
16
17
|
```ruby
|
18
|
+
# spec/item_spec.rb
|
17
19
|
describe Item do
|
18
20
|
describe '#created_at()=>Time', verifies_contract: true do
|
19
21
|
it "tests something" do
|
@@ -46,6 +48,7 @@ And require it when running rspec:
|
|
46
48
|
Let's look again at the example above:
|
47
49
|
|
48
50
|
```ruby
|
51
|
+
# spec/foo_spec.rb
|
49
52
|
item = VerifiedDouble.of_instance(Item)
|
50
53
|
expect(item).to receive(:created_at).and_return(Time.now)
|
51
54
|
```
|
@@ -63,6 +66,7 @@ The following mocks are not verified:
|
|
63
66
|
You can then tag the test for `Item#created_at()=>Time` with the method signature:
|
64
67
|
|
65
68
|
```ruby
|
69
|
+
# spec/item_spec.rb
|
66
70
|
describe Item do
|
67
71
|
describe '#created_at()=>Time', verifies_contract: true do
|
68
72
|
it "tests something" do
|
@@ -76,11 +80,12 @@ Take note that:
|
|
76
80
|
|
77
81
|
1. The described class must be a class, not a string.
|
78
82
|
2. The described method must start with `#` if its an instance method and `.` if it's a class method.
|
79
|
-
3. You need to add the
|
83
|
+
3. You need to add the `verifies_contract: true` tag to the test.
|
80
84
|
|
81
85
|
If your testing style doesn't follow these conventions, you can tag the test with the whole method signature:
|
82
86
|
|
83
87
|
```ruby
|
88
|
+
# spec/item_spec.rb
|
84
89
|
describe 'Item' do
|
85
90
|
it "has a creation timestamp", verifies_contract: `Item#created_at()=>Time` do
|
86
91
|
#...
|
@@ -92,6 +97,10 @@ Since VerifiedDouble relies on tags to link mocks and contracts together, you'll
|
|
92
97
|
need to run the tests containing the contracts along with tests with the mocks in
|
93
98
|
order to clear the VerifiedDouble warnings.
|
94
99
|
|
100
|
+
```
|
101
|
+
rspec spec/foo_spec.rb spec/item_spec.rb
|
102
|
+
```
|
103
|
+
|
95
104
|
## Booleans
|
96
105
|
|
97
106
|
Since Ruby doesn't have Boolean class covering both `TrueClass` and `FalseClass`,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: verified_double
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Mendoza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|