verified_double 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +7 -0
- data/features/CHANGELOG.markdown +7 -0
- data/features/customizing_arguments_and_return_values.feature +28 -0
- data/lib/verified_double/method_signature/class_value.rb +1 -1
- data/lib/verified_double/recorded_method_signature.rb +1 -1
- data/lib/verified_double/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/shared_examples.rb +9 -0
- data/spec/verified_double/method_signature/class_value_spec.rb +6 -1
- data/spec/verified_double/recorded_method_signature_spec.rb +2 -0
- metadata +4 -2
data/CHANGELOG.markdown
CHANGED
data/features/CHANGELOG.markdown
CHANGED
@@ -98,3 +98,31 @@ Feature: 04. Customizing arguments and return values
|
|
98
98
|
|
99
99
|
When I run the test suite
|
100
100
|
Then I should not see any output saying the mock is unverified
|
101
|
+
|
102
|
+
Scenario: class double as return value
|
103
|
+
Given a test that uses VerifiedDouble to mock an object:
|
104
|
+
"""
|
105
|
+
require 'spec_helper'
|
106
|
+
describe ObjectUnderTest do
|
107
|
+
let(:collaborator_class){ VerifiedDouble.of_class('Collaborator') }
|
108
|
+
let(:instance_double) { VerifiedDouble.of_instance('Collaborator', class: collaborator_class) }
|
109
|
+
|
110
|
+
it "tests something" do
|
111
|
+
expect(instance_double.class).to eq(collaborator_class)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
"""
|
115
|
+
|
116
|
+
And the test suite has a contract test for the mock:
|
117
|
+
"""
|
118
|
+
require 'spec_helper'
|
119
|
+
|
120
|
+
describe 'Collaborator' do
|
121
|
+
it "tests something", verifies_contract: 'Collaborator#class()=>Class' do
|
122
|
+
# do nothing
|
123
|
+
end
|
124
|
+
end
|
125
|
+
"""
|
126
|
+
|
127
|
+
When I run the test suite
|
128
|
+
Then I should not see any output saying the mock is unverified
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pry'
|
2
2
|
require 'verified_double'
|
3
3
|
require 'verified_double/rspec_configuration'
|
4
|
+
require 'support/shared_examples.rb'
|
4
5
|
|
5
6
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
6
7
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
shared_examples_for "it can initialize its stack frame within a shared example" do
|
2
|
+
it "set the stack frame of the signature's caller" do
|
3
|
+
subject = described_class.new(attributes).tap {|method_signature|
|
4
|
+
method_signature.method = 'do_something' }
|
5
|
+
|
6
|
+
expect(subject.stack_frame.to_s)
|
7
|
+
.to include("./spec/support/shared_examples.rb")
|
8
|
+
end
|
9
|
+
end
|
@@ -10,9 +10,14 @@ describe VerifiedDouble::MethodSignature::ClassValue do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
context "where the value and other do not have the same content" do
|
13
|
-
let(:other) { described_class.new(
|
13
|
+
let(:other) { described_class.new(Float) }
|
14
14
|
it { expect(subject.belongs_to?(other)).to be_false }
|
15
15
|
end
|
16
|
+
|
17
|
+
context "where the other is a Class" do
|
18
|
+
let(:other) { described_class.new(Class) }
|
19
|
+
it { expect(subject.belongs_to?(other)).to be_true }
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
describe "#content_as_instance" do
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: verified_double
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- George Mendoza
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
type: :runtime
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/verified_double/stack_frame.rb
|
135
135
|
- lib/verified_double/version.rb
|
136
136
|
- spec/spec_helper.rb
|
137
|
+
- spec/support/shared_examples.rb
|
137
138
|
- spec/verified_double/can_record_interactions_spec.rb
|
138
139
|
- spec/verified_double/matchers_spec.rb
|
139
140
|
- spec/verified_double/method_signature/boolean_value_spec.rb
|
@@ -187,6 +188,7 @@ test_files:
|
|
187
188
|
- features/verified_mocks.feature
|
188
189
|
- features/verified_stubs.feature
|
189
190
|
- spec/spec_helper.rb
|
191
|
+
- spec/support/shared_examples.rb
|
190
192
|
- spec/verified_double/can_record_interactions_spec.rb
|
191
193
|
- spec/verified_double/matchers_spec.rb
|
192
194
|
- spec/verified_double/method_signature/boolean_value_spec.rb
|