Class: RSpec::Contracts::FulfillmentView
- Inherits:
-
Object
- Object
- RSpec::Contracts::FulfillmentView
- Defined in:
- lib/rspec/contracts/fulfillment_view.rb
Instance Method Summary collapse
- #contracts_count ⇒ Object
-
#initialize(fulfillment) ⇒ FulfillmentView
constructor
A new instance of FulfillmentView.
- #pluralize(number, noun) ⇒ Object
- #render ⇒ Object
- #render_complete ⇒ Object
- #render_incomplete ⇒ Object
- #unfulfilled_views ⇒ Object
Constructor Details
#initialize(fulfillment) ⇒ FulfillmentView
Returns a new instance of FulfillmentView.
4 5 6 |
# File 'lib/rspec/contracts/fulfillment_view.rb', line 4 def initialize(fulfillment) @fulfillment = fulfillment end |
Instance Method Details
#contracts_count ⇒ Object
28 29 30 |
# File 'lib/rspec/contracts/fulfillment_view.rb', line 28 def contracts_count pluralize @fulfillment.requirements_count, "contract" end |
#pluralize(number, noun) ⇒ Object
32 33 34 35 |
# File 'lib/rspec/contracts/fulfillment_view.rb', line 32 def pluralize(number, noun) suffix = (number == 1) ? "" : "s" "#{number} #{noun}#{suffix}" end |
#render ⇒ Object
8 9 10 |
# File 'lib/rspec/contracts/fulfillment_view.rb', line 8 def render @fulfillment.complete? ? render_complete : render_incomplete end |
#render_complete ⇒ Object
12 13 14 |
# File 'lib/rspec/contracts/fulfillment_view.rb', line 12 def render_complete "#{contracts_count} verified." end |
#render_incomplete ⇒ Object
16 17 18 19 20 |
# File 'lib/rspec/contracts/fulfillment_view.rb', line 16 def render_incomplete lines = unfulfilled_views lines.unshift("WARNING: #{unfulfilled_views.count} of #{contracts_count} unverified.") lines.join "\n" end |
#unfulfilled_views ⇒ Object
22 23 24 25 26 |
# File 'lib/rspec/contracts/fulfillment_view.rb', line 22 def unfulfilled_views @fulfillment.unfulfilled_requirements.map do |requirement| RSpec::Contracts::RequirementView.new(requirement).render end end |