Class: Manacle::Example
- Inherits:
-
Object
- Object
- Manacle::Example
- Defined in:
- lib/manacle/formatter.rb
Instance Attribute Summary collapse
-
#case ⇒ Object
readonly
Returns the value of attribute case.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#execution_result ⇒ Object
readonly
Returns the value of attribute execution_result.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#full_description ⇒ Object
readonly
Returns the value of attribute full_description.
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#run_time ⇒ Object
readonly
Returns the value of attribute run_time.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #build_description(example) ⇒ Object
- #build_params(example) ⇒ Object
-
#initialize(example, last_response) ⇒ Example
constructor
A new instance of Example.
- #param_value(param) ⇒ Object
Constructor Details
#initialize(example, last_response) ⇒ Example
Returns a new instance of Example.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/manacle/formatter.rb', line 10 def initialize(example, last_response) @description = example.description @full_description = build_description(example) @execution_result = example.execution_result # @run_time = RSpec::Core::Formatters::Helpers.format_duration(@execution_result.run_time) @run_time = execution_result.run_time @status = @execution_result.status.to_s = example. @exception = example.exception @file_path = [:file_path] @last_response = last_response if ['passed', 'failed'].include?(@status) # @last_response = last_response @case = [:case] @params = [:params] @params ||= build_params(example) end |
Instance Attribute Details
#case ⇒ Object (readonly)
Returns the value of attribute case.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def case @case end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def description @description end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def exception @exception end |
#execution_result ⇒ Object (readonly)
Returns the value of attribute execution_result.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def execution_result @execution_result end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def file_path @file_path end |
#full_description ⇒ Object (readonly)
Returns the value of attribute full_description.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def full_description @full_description end |
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def last_response @last_response end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def params @params end |
#run_time ⇒ Object (readonly)
Returns the value of attribute run_time.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def run_time @run_time end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/manacle/formatter.rb', line 8 def status @status end |
Instance Method Details
#build_description(example) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/manacle/formatter.rb', line 45 def build_description(example) full_description = [example.description, example.example_group.description] parent = example.example_group.parent while parent.is_a?(Class) full_description << parent.try(:description) parent = parent.parent end full_description.reverse.join('<br/>') end |
#build_params(example) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/manacle/formatter.rb', line 27 def build_params(example) return [] if last_response.nil? xml = Nokogiri::XML(last_response.request.[:body]) ns = {ns: 'http://www.quantiguous.com/services'} params = [] example.example_group.described_class.param_defaults.each do |pv| p = pv.keys.first; v = pv.values.first if v.nil? params << xml.at_xpath("//ns:#{p}", ns).name.to_sym unless xml.at_xpath("//ns:#{p}", ns).nil? else params << xml.at_xpath("//ns:#{p}", ns).name.to_sym unless xml.at_xpath("//ns:#{p}", ns).try(:text) == v end end params end |
#param_value(param) ⇒ Object
55 56 57 58 |
# File 'lib/manacle/formatter.rb', line 55 def param_value(param) @reqDoc ||= Nokogiri::XML(@last_response.request.[:body]) @reqDoc.at_xpath('//ns:' + param.to_s, 'ns' => 'http://www.quantiguous.com/services').try(:text) end |