Class: VerifiedDouble::MethodSignaturesReport
- Inherits:
-
Object
- Object
- VerifiedDouble::MethodSignaturesReport
- Defined in:
- lib/verified_double/method_signatures_report.rb
Instance Attribute Summary collapse
-
#registered_signatures ⇒ Object
Returns the value of attribute registered_signatures.
-
#unverified_signatures ⇒ Object
Returns the value of attribute unverified_signatures.
-
#verified_signatures ⇒ Object
Returns the value of attribute verified_signatures.
-
#verified_signatures_from_matchers ⇒ Object
Returns the value of attribute verified_signatures_from_matchers.
-
#verified_signatures_from_tags ⇒ Object
Returns the value of attribute verified_signatures_from_tags.
Instance Method Summary collapse
- #identify_unverified_signatures ⇒ Object
-
#initialize ⇒ MethodSignaturesReport
constructor
A new instance of MethodSignaturesReport.
- #merge_verified_signatures ⇒ Object
- #output_unverified_signatures ⇒ Object
- #set_registered_signatures ⇒ Object
- #set_verified_signatures_from_matchers ⇒ Object
- #set_verified_signatures_from_tags(nested_example_group) ⇒ Object
Constructor Details
#initialize ⇒ MethodSignaturesReport
Returns a new instance of MethodSignaturesReport.
6 7 8 9 10 11 12 |
# File 'lib/verified_double/method_signatures_report.rb', line 6 def initialize @registered_signatures = [] @unverified_signatures = [] @verified_signatures = [] @verified_signatures_from_tags = [] @verified_signatures_from_matchers = [] end |
Instance Attribute Details
#registered_signatures ⇒ Object
Returns the value of attribute registered_signatures.
3 4 5 |
# File 'lib/verified_double/method_signatures_report.rb', line 3 def registered_signatures @registered_signatures end |
#unverified_signatures ⇒ Object
Returns the value of attribute unverified_signatures.
3 4 5 |
# File 'lib/verified_double/method_signatures_report.rb', line 3 def unverified_signatures @unverified_signatures end |
#verified_signatures ⇒ Object
Returns the value of attribute verified_signatures.
3 4 5 |
# File 'lib/verified_double/method_signatures_report.rb', line 3 def verified_signatures @verified_signatures end |
#verified_signatures_from_matchers ⇒ Object
Returns the value of attribute verified_signatures_from_matchers.
3 4 5 |
# File 'lib/verified_double/method_signatures_report.rb', line 3 def verified_signatures_from_matchers @verified_signatures_from_matchers end |
#verified_signatures_from_tags ⇒ Object
Returns the value of attribute verified_signatures_from_tags.
3 4 5 |
# File 'lib/verified_double/method_signatures_report.rb', line 3 def @verified_signatures_from_tags end |
Instance Method Details
#identify_unverified_signatures ⇒ Object
14 15 16 17 18 19 |
# File 'lib/verified_double/method_signatures_report.rb', line 14 def identify_unverified_signatures @unverified_signatures = @registered_signatures.select{|registered_signature| @verified_signatures.all?{|verified_signature| ! registered_signature.belongs_to?(verified_signature) } } self end |
#merge_verified_signatures ⇒ Object
21 22 23 24 |
# File 'lib/verified_double/method_signatures_report.rb', line 21 def merge_verified_signatures @verified_signatures = @verified_signatures_from_tags + @verified_signatures_from_matchers self end |
#output_unverified_signatures ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/verified_double/method_signatures_report.rb', line 26 def output_unverified_signatures if @unverified_signatures.any? output = [nil, "The following mocks are not verified:" ] + @unverified_signatures .map(&:recommended_verified_signature) .map(&:to_s) .sort .each_with_index .map{|string, i| "#{i+1}. #{string}" } + ["For more info, check out https://www.relishapp.com/gsmendoza/verified-double."] puts output.join("\n\n") end self end |
#set_registered_signatures ⇒ Object
41 42 43 44 |
# File 'lib/verified_double/method_signatures_report.rb', line 41 def set_registered_signatures @registered_signatures = VerifiedDouble.registry.uniq self end |
#set_verified_signatures_from_matchers ⇒ Object
46 47 48 49 |
# File 'lib/verified_double/method_signatures_report.rb', line 46 def set_verified_signatures_from_matchers @verified_signatures_from_matchers = VerifiedDouble.verified_signatures_from_matchers self end |
#set_verified_signatures_from_tags(nested_example_group) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/verified_double/method_signatures_report.rb', line 51 def (nested_example_group) examples = nested_example_group .class .descendant_filtered_examples verified_signatures = examples.map do |example| if example.[:verifies_contract] == true ExampleMetadata.new(example.).verified_signature else example.[:verifies_contract] end end @verified_signatures_from_tags = verified_signatures .compact .uniq .map{|method_signature_string| ParseMethodSignature.new(method_signature_string).execute } self end |