Class: RSpec::Contracts::Message
- Inherits:
-
Object
- Object
- RSpec::Contracts::Message
- Defined in:
- lib/rspec/contracts/message.rb
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#specifications ⇒ Object
Returns the value of attribute specifications.
Instance Method Summary collapse
- #fully_described_by?(message) ⇒ Boolean
-
#initialize(method_name, specifications = {}) ⇒ Message
constructor
A new instance of Message.
- #to_hash ⇒ Object
Constructor Details
#initialize(method_name, specifications = {}) ⇒ Message
Returns a new instance of Message.
7 8 9 10 |
# File 'lib/rspec/contracts/message.rb', line 7 def initialize(method_name, specifications = {}) @method_name = method_name @specifications = specifications end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
4 5 6 |
# File 'lib/rspec/contracts/message.rb', line 4 def method_name @method_name end |
#specifications ⇒ Object
Returns the value of attribute specifications.
5 6 7 |
# File 'lib/rspec/contracts/message.rb', line 5 def specifications @specifications end |
Instance Method Details
#fully_described_by?(message) ⇒ Boolean
12 13 14 15 16 17 18 19 20 |
# File 'lib/rspec/contracts/message.rb', line 12 def fully_described_by?() return false if .method_name != method_name @specifications.each do |name, specification| unless specification.fully_described_by? .specifications[name] return false end end true end |
#to_hash ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rspec/contracts/message.rb', line 22 def to_hash { :method_name => method_name, :specifications => specifications.values.map(&:to_hash), } end |