Commits

Anonymous committed 95ab632

Fixed broken ruby test.

Comments (0)

Files changed (2)

ruby/repustate.rb

                   :author => '',
                   :images => [],
                   :titles => [],
-                })
+                }, response_type=nil)
     args = {
       :title => options[:report_title],
       :author => options[:author],

ruby/tc_repustate.rb

     return Repustate.new(KEY)
   end
 
-  def check_result(result, check_status=true)
+  def check_status(result, response_type)
+    if response_type == 'json'
+      status = result['status']
+    else
+      status = result.root.elements['status'].text
+    end
+    assert_equal('OK', status, result)
+  end
+
+  def check_call(func_name, options={}, response_type='json', check_status=true)
+    args = [func_name, options]
+    if func_name != 'powerpoint'
+      args.push(response_type)
+    end
+    result = get_accessor().send(*args)
     assert_not_nil(result, 'Invalid result')
     if check_status
-      status = result['status']
-      assert_equal('OK', status, result)
+      check_status(result, response_type)
     end
   end
 
-  def check_call(func_name, options={}, check_status=true)
-    result = get_accessor().send(func_name, options)
-    check_result(result, check_status)
-  end
-
   def test_sentiment_for_text
     check_call('sentiment', {:text => TEXT})
   end
   end
 
   def test_xml_response_type
-    result = get_accessor().send('sentiment', {:text => TEXT}, 'xml')
-    check_result(result)
+    check_call('sentiment', {:text => TEXT}, 'xml')
   end
 
   def test_bulk_sentiment
       :images => ['repustate.gif'],
       :titles => ['A test title'],
     }
-    check_call('powerpoint', options, check_status=false)
+    check_call('powerpoint', options, 'json', false)
   end
 
 end