Sha256: 18a9a37e9474360b18a96c8644cea65a865cbbeb8189c5246b3b600da28aeacf

Contents?: true

Size: 787 Bytes

Versions: 3

Compression:

Stored size: 787 Bytes

Contents

module RubossTestHelpers

  # Use this to test xml or fxml responses in unit tests.  For example,
  # set_response_to user.to_fxml
  # assert_xml_select 'user name', 'quentin'
  def set_response_to(response, content_type = 'xml')
    @response = MockResponse.new(response, content_type)
  end
  
  # Make xml functional testing work.
  # From http://weblog.jamisbuck.org/2007/1/4/assert_xml_select
  def xml_document
    @xml_document ||= HTML::Document.new(@response.body, false, true)
  end  
  
  def assert_xml_select(*args, &block)
    @html_document = xml_document
    assert_select(*args, &block)
  end   
  
end

class MockResponse
  attr_reader :body, :content_type
    
  def initialize(body, content_type = 'xml')
    @body = body
    @content_type = content_type
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruboss4ruby-1.0.5 lib/ruboss4ruby/ruboss_test_helpers.rb
ruboss4ruby-1.0.3 lib/ruboss4ruby/ruboss_test_helpers.rb
ruboss4ruby-1.0.4 lib/ruboss4ruby/ruboss_test_helpers.rb