verified_double 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/CHANGELOG.markdown +8 -0
  2. data/README.md +21 -49
  3. data/features/CHANGELOG.markdown +8 -0
  4. data/features/accessor_method_contracts.feature +107 -0
  5. data/features/customizing_arguments_and_return_values.feature +2 -2
  6. data/features/readme.md +21 -49
  7. data/features/rspec_mock_compatibility.feature +230 -0
  8. data/features/step_definitions/verified_double_steps.rb +17 -0
  9. data/features/{verified_double.feature → verified_mocks.feature} +5 -6
  10. data/features/verified_stubs.feature +94 -0
  11. data/lib/verified_double.rb +25 -10
  12. data/lib/verified_double/matchers.rb +35 -0
  13. data/lib/verified_double/method_signature_value.rb +15 -1
  14. data/lib/verified_double/method_signatures_report.rb +55 -0
  15. data/lib/verified_double/recording_double.rb +33 -12
  16. data/lib/verified_double/relays_to_internal_double_returning_self.rb +12 -0
  17. data/lib/verified_double/version.rb +1 -1
  18. data/spec/spec_helper.rb +3 -4
  19. data/spec/unit_helper.rb +3 -2
  20. data/spec/verified_double/matchers_spec.rb +96 -0
  21. data/spec/verified_double/method_signature_value_spec.rb +35 -0
  22. data/spec/verified_double/method_signatures_report_spec.rb +214 -0
  23. data/spec/verified_double/parse_method_signature_spec.rb +5 -1
  24. data/spec/verified_double/recording_double_spec.rb +103 -30
  25. data/spec/verified_double_spec.rb +70 -7
  26. data/verified_double.gemspec +0 -2
  27. metadata +17 -38
  28. data/lib/verified_double/get_registered_signatures.rb +0 -11
  29. data/lib/verified_double/get_unverified_signatures.rb +0 -13
  30. data/lib/verified_double/get_verified_signatures.rb +0 -17
  31. data/lib/verified_double/output_unverified_signatures.rb +0 -18
  32. data/lib/verified_double/report_unverified_signatures.rb +0 -16
  33. data/lib/verified_double/verify_doubles_service.rb +0 -15
  34. data/spec/verified_double/get_registered_signatures_spec.rb +0 -42
  35. data/spec/verified_double/get_unverified_signatures_spec.rb +0 -52
  36. data/spec/verified_double/get_verified_signatures_spec.rb +0 -63
  37. data/spec/verified_double/output_unverified_signatures_spec.rb +0 -58
  38. data/spec/verified_double/report_unverified_signatures_spec.rb +0 -57
  39. data/spec/verified_double/verify_doubles_service_spec.rb +0 -24
@@ -1,58 +0,0 @@
1
- require 'unit_helper'
2
- require 'verified_double/output_unverified_signatures'
3
-
4
- describe VerifiedDouble::OutputUnverifiedSignatures do
5
- class Dummy
6
- end
7
-
8
- let(:get_unverified_signatures_service){
9
- fire_double('VerifiedDouble::GetUnverifiedSignatures') }
10
-
11
- let(:unverified_signatures){ [
12
- VerifiedDouble::MethodSignature.new(
13
- class_name: 'Dummy',
14
- method_operator: '.',
15
- method: 'find',
16
- args: [VerifiedDouble::MethodSignatureValue.new(1)],
17
- return_values: [VerifiedDouble::MethodSignatureValue.new(Dummy.new)]),
18
- VerifiedDouble::MethodSignature.new(
19
- class_name: 'Dummy',
20
- method_operator: '.',
21
- method: 'where',
22
- args: [VerifiedDouble::MethodSignatureValue.new(id: 1)],
23
- return_values: [VerifiedDouble::MethodSignatureValue.new(Dummy.new)]) ] }
24
-
25
- subject { described_class.new(get_unverified_signatures_service) }
26
-
27
- describe "#execute" do
28
- context "where there are no unverified_signatures" do
29
- it "should not output anything" do
30
- get_unverified_signatures_service.should_receive(:execute).and_return([])
31
- subject.should_not_receive(:puts)
32
-
33
- subject.execute
34
- end
35
- end
36
-
37
- context "where there are unverified_signatures" do
38
- it "should output the recommended versions of the unverified_signatures" do
39
- get_unverified_signatures_service.should_receive(:execute).and_return(unverified_signatures)
40
-
41
- lines = [
42
- "The following mocks are not verified:",
43
- unverified_signatures[0].recommended_verified_signature,
44
- unverified_signatures[1].recommended_verified_signature ]
45
-
46
- subject.should_receive(:puts).with(lines.join("\n"))
47
- subject.execute
48
- end
49
- end
50
- end
51
-
52
- describe "#unverified_signatures" do
53
- it "are the results of get_unverified_signatures.execute" do
54
- get_unverified_signatures_service.should_receive(:execute).and_return(unverified_signatures)
55
- expect(subject.unverified_signatures).to eq(unverified_signatures)
56
- end
57
- end
58
- end
@@ -1,57 +0,0 @@
1
- require 'unit_helper'
2
- require 'verified_double/report_unverified_signatures'
3
-
4
- describe VerifiedDouble::ReportUnverifiedSignatures do
5
- let(:double_registry) { Set.new }
6
- let(:nested_example_group) { double('nested_example_group') }
7
-
8
- subject { described_class.new(double_registry, nested_example_group) }
9
-
10
- describe "#initialize" do
11
- it "requires a double registry and a nested example group" do
12
- expect(subject.double_registry).to eq(double_registry)
13
- expect(subject.nested_example_group).to eq(nested_example_group)
14
- end
15
- end
16
-
17
- describe "#execute" do
18
- service_names = [
19
- :get_registered_signatures,
20
- :get_verified_signatures,
21
- :get_unverified_signatures,
22
- :output_unverified_signatures]
23
-
24
- service_names.each do |service_name|
25
- service_class_name = "#{VerifiedDouble}::#{service_name.to_s.classify.pluralize}"
26
- let("#{service_name}_class") { fire_class_double(service_class_name).as_replaced_constant }
27
- let("#{service_name}_service") { fire_double(service_class_name) }
28
- end
29
-
30
- it "gets registered and verified signatures and then outputs the unverified signatures" do
31
- get_registered_signatures_class
32
- .should_receive(:new)
33
- .with(double_registry)
34
- .and_return(get_registered_signatures_service)
35
-
36
- get_verified_signatures_class
37
- .should_receive(:new)
38
- .with(nested_example_group)
39
- .and_return(get_verified_signatures_service)
40
-
41
- get_unverified_signatures_class
42
- .should_receive(:new)
43
- .with(get_registered_signatures_service, get_verified_signatures_service)
44
- .and_return(get_unverified_signatures_service)
45
-
46
- output_unverified_signatures_class
47
- .should_receive(:new)
48
- .with(get_unverified_signatures_service)
49
- .and_return(output_unverified_signatures_service)
50
-
51
- output_unverified_signatures_service.should_receive(:execute)
52
-
53
- subject.execute
54
- end
55
- end
56
-
57
- end
@@ -1,24 +0,0 @@
1
- require 'verified_double/verify_doubles_service'
2
-
3
- describe VerifiedDouble::VerifyDoublesService do
4
- let(:world) { double('VerifiedDouble::World') }
5
-
6
- subject { described_class.new(world) }
7
-
8
- describe "#execute" do
9
- it "should output the unverified_method_signatures of the world if there are any" do
10
- world.should_receive(:unverified_method_signatures).and_return(["Flight.find(Hash)=>Flight"])
11
- subject.should_receive("puts")
12
-
13
- subject.execute
14
- end
15
-
16
- it "should do nothing if there are no unverified_method_signatures" do
17
- world.should_receive(:unverified_method_signatures).and_return([])
18
- subject.should_not_receive("puts")
19
-
20
- subject.execute
21
- end
22
- end
23
- end
24
-