verified_double 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/CHANGELOG.markdown +12 -0
  2. data/README.md +25 -14
  3. data/features/CHANGELOG.markdown +12 -0
  4. data/features/readme.md +25 -14
  5. data/features/verified_mocks.feature +4 -2
  6. data/lib/verified_double.rb +10 -1
  7. data/lib/verified_double/matchers.rb +2 -2
  8. data/lib/verified_double/method_signature.rb +5 -5
  9. data/lib/verified_double/method_signature/boolean_value.rb +9 -0
  10. data/lib/verified_double/method_signature/class_value.rb +17 -0
  11. data/lib/verified_double/method_signature/instance_double_value.rb +9 -0
  12. data/lib/verified_double/method_signature/instance_value.rb +17 -0
  13. data/lib/verified_double/method_signature/recording_double_class_value.rb +9 -0
  14. data/lib/verified_double/method_signature/rspec_double_value.rb +9 -0
  15. data/lib/verified_double/method_signature/value.rb +37 -0
  16. data/lib/verified_double/method_signatures_report.rb +10 -3
  17. data/lib/verified_double/parse_method_signature.rb +2 -2
  18. data/lib/verified_double/recorded_method_signature.rb +9 -0
  19. data/lib/verified_double/recording_double.rb +13 -4
  20. data/lib/verified_double/stack_frame.rb +11 -0
  21. data/lib/verified_double/version.rb +1 -1
  22. data/spec/spec_helper.rb +1 -0
  23. data/spec/verified_double/matchers_spec.rb +1 -1
  24. data/spec/verified_double/method_signature/boolean_value_spec.rb +11 -0
  25. data/spec/verified_double/method_signature/class_value_spec.rb +35 -0
  26. data/spec/verified_double/method_signature/instance_double_value_spec.rb +17 -0
  27. data/spec/verified_double/method_signature/instance_value_spec.rb +39 -0
  28. data/spec/verified_double/method_signature/recording_double_class_value_spec.rb +23 -0
  29. data/spec/verified_double/method_signature/rspec_double_spec.rb +14 -0
  30. data/spec/verified_double/method_signature/value_spec.rb +89 -0
  31. data/spec/verified_double/method_signature_spec.rb +16 -16
  32. data/spec/verified_double/method_signatures_report_spec.rb +14 -12
  33. data/spec/verified_double/parse_method_signature_spec.rb +3 -3
  34. data/spec/verified_double/recorded_method_signature_spec.rb +23 -0
  35. data/spec/verified_double/recording_double_spec.rb +103 -77
  36. data/spec/verified_double/stack_frame_spec.rb +15 -0
  37. data/spec/verified_double_spec.rb +1 -1
  38. metadata +29 -7
  39. data/lib/verified_double/method_signature_value.rb +0 -45
  40. data/spec/unit_helper.rb +0 -16
  41. data/spec/verified_double/method_signature_value_spec.rb +0 -126
@@ -1,16 +0,0 @@
1
- require 'active_support/core_ext/string'
2
- require 'pry'
3
-
4
- require 'verified_double/boolean'
5
-
6
- # Requiring because these are Value objects.
7
- # As value objects, we treat them as primitives.
8
- # Hence, there should be no need to mock or stub them.
9
- require "verified_double/method_signature"
10
- require "verified_double/method_signature_value"
11
-
12
- # Requiring because these are macros.
13
- require 'verified_double/relays_to_internal_double_returning_self'
14
-
15
- RSpec.configure do |config|
16
- end
@@ -1,126 +0,0 @@
1
- require 'unit_helper'
2
- require 'verified_double/method_signature_value'
3
-
4
- describe VerifiedDouble::MethodSignatureValue do
5
- let(:value){ :some_value }
6
-
7
- describe "#initialize" do
8
- it "requires a value from a method signature" do
9
- described_class.new(value)
10
- end
11
- end
12
-
13
- describe "#accepts?(other)" do
14
- subject { this.accepts?(other) }
15
-
16
- context "where self's value is an actual class and other's value matches it" do
17
- let(:this){ described_class.new(Fixnum) }
18
- let(:other){ described_class.new(Fixnum) }
19
- it { expect(subject).to be_true }
20
- end
21
-
22
- context "where self's value is an actual class and other's value does not match it" do
23
- let(:this){ described_class.new(Fixnum) }
24
- let(:other){ described_class.new(Object) }
25
- it { expect(subject).to be_false }
26
- end
27
-
28
- context "where the other value is an instance and self's value matches it" do
29
- let(:this){ described_class.new(1) }
30
- let(:other){ described_class.new(1) }
31
- it { expect(subject).to be_true }
32
- end
33
-
34
- context "where the other value is an instance and self's value does not it" do
35
- let(:this){ described_class.new(2) }
36
- let(:other){ described_class.new(1) }
37
- it { expect(subject).to be_false }
38
- end
39
-
40
- context "where self is an instance and the other's class is an ancestor of self's modified class" do
41
- let(:this){ described_class.new(1) }
42
- let(:other){ described_class.new(Object) }
43
- it { expect(subject).to be_true }
44
- end
45
-
46
- context "where self is an instance and the other's class is not an ancestor of self's modified class" do
47
- let(:this){ described_class.new(1) }
48
- let(:other){ described_class.new(Float) }
49
- it { expect(subject).to be_false }
50
- end
51
- end
52
-
53
- describe "#modified_class" do
54
- subject { method_signature_value.modified_class }
55
-
56
- context "where the value is recording double" do
57
- let(:recording_double){ VerifiedDouble.of_instance('Object') }
58
- let(:method_signature_value) { described_class.new(recording_double) }
59
-
60
- it "is the class represented by the class_name of the recording double" do
61
- expect(subject).to eq(Object)
62
- end
63
- end
64
-
65
- context "where the value is a double" do
66
- let(:d){ double('Object') }
67
- let(:method_signature_value) { described_class.new(d) }
68
-
69
- it "is the class represented by the class_name of the recording double" do
70
- expect(subject).to eq(Object)
71
- end
72
- end
73
-
74
- context "where the value is true" do
75
- let(:method_signature_value) { described_class.new(true) }
76
- it { expect(subject).to eq(VerifiedDouble::Boolean) }
77
- end
78
-
79
- context "where the value is false" do
80
- let(:method_signature_value) { described_class.new(false) }
81
- it { expect(subject).to eq(VerifiedDouble::Boolean) }
82
- end
83
-
84
- context "where the value is not true or false" do
85
- let(:method_signature_value) { described_class.new(1) }
86
- it "is the class of the value" do
87
- expect(subject).to eq(Fixnum)
88
- end
89
- end
90
- end
91
-
92
- describe "#recommended_value" do
93
- subject { described_class.new(value) }
94
-
95
- it "is a version of self that will be recommended to users to verify" do
96
- expect(subject.recommended_value.value).to eq(subject.modified_class)
97
- expect(subject.recommended_value.value).to_not eq(subject)
98
- end
99
- end
100
-
101
- describe "#as_instance" do
102
- context "where the value is an instance" do
103
- subject { described_class.new(:some_value) }
104
-
105
- it "returns the value" do
106
- expect(subject.as_instance).to eq(:some_value)
107
- end
108
- end
109
-
110
- context "where the value is a class which can be initialized" do
111
- subject { described_class.new(String) }
112
-
113
- it "returns the initialized instance of the value " do
114
- expect(subject.as_instance).to eq(String.new)
115
- end
116
- end
117
-
118
- context "where the value is a class which cannot be initialized" do
119
- subject { described_class.new(Integer) }
120
-
121
- it "returns an object" do
122
- expect(subject.as_instance).to be_an(Object)
123
- end
124
- end
125
- end
126
- end