Class: CabezaDeTermo::JsonSpec::ErbMessageFormatter
- Inherits:
-
Object
- Object
- CabezaDeTermo::JsonSpec::ErbMessageFormatter
- Defined in:
- lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb
Instance Method Summary collapse
- #accessors_chain ⇒ Object
- #expectation ⇒ Object
- #field ⇒ Object
- #format(value) ⇒ Object
-
#format_message ⇒ Object
Formatting.
-
#initialize(message) ⇒ ErbMessageFormatter
constructor
A new instance of ErbMessageFormatter.
- #list_string(array) ⇒ Object
- #message_on(expectation, value_holder, *params) ⇒ Object
- #value ⇒ Object
-
#value_holder ⇒ Object
Accessing.
Constructor Details
#initialize(message) ⇒ ErbMessageFormatter
Returns a new instance of ErbMessageFormatter.
7 8 9 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 7 def initialize() @message = end |
Instance Method Details
#accessors_chain ⇒ Object
30 31 32 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 30 def accessors_chain value_holder.accessors_chain end |
#expectation ⇒ Object
42 43 44 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 42 def expectation @expectation end |
#field ⇒ Object
34 35 36 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 34 def field accessors_chain.to_s end |
#format(value) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 46 def format(value) return 'null' if value == nil return 'an object' if value.kind_of? ::Hash return list_string(value) if value.kind_of? ::Array value.to_s end |
#format_message ⇒ Object
Formatting
20 21 22 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 20 def ERB.new(@message).result(binding) end |
#list_string(array) ⇒ Object
54 55 56 57 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 54 def list_string(array) values = array.collect { |each| format each } '[' + values.join(', ') + ']' end |
#message_on(expectation, value_holder, *params) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 11 def (expectation, value_holder, *params) @expectation = expectation @value_holder = value_holder end |
#value ⇒ Object
38 39 40 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 38 def value @value_holder.value end |
#value_holder ⇒ Object
Accessing
26 27 28 |
# File 'lib/cabeza-de-termo/json-spec/message-formatters/erb-message-formatter.rb', line 26 def value_holder @value_holder end |