Topic: Integration Test Problem

I am following along with a tutorial and have stumbled into a problem. One of my integration tests is failing and I am not sure why. The part of the test that is failing looks like this:

    def reads_rss
      get "/catalog/rss"
      assert_response :success
      assert_template "catalog/rss"
      assert_equal "application/xml", response.headers["type"]
      
      assert_tag     :tag => "channel",
                     :children =>
                       { :count => 10, :only =>
                         {:tag => "item"}}
    Book.latest.each do |book|
      assert_tag :tag => "title", :content => book.title
    end
  end

When running an integration test this is the error that it gives me:

Started
DEPRECATION WARNING: end_form_tag is deprecated and will be removed from Rails 2
.0  See http://www.rubyonrails.org/deprecation for details. (called from _run_rh
tml_47app47views47catalog47_search_box46rhtml at C:/rails/store/config/../app/vi
ews/catalog/_search_box.rhtml:4)
F.
Finished in 2.328 seconds.

  1) Failure:
test_browsing_the_site(BrowsingAndSearchingTest)
    [test/integration/browsing_and_searching_test.rb:30:in `reads_rss'
     test/integration/browsing_and_searching_test.rb:12:in `test_browsing_the_site'
     c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/inte
gration.rb:453:in `run']:
<"application/xml"> expected but was
<"application/xml; charset=utf-8">.

2 tests, 60 assertions, 1 failures, 0 errors


I am pretty sure the problem comes from the assert_equal "application/xml", response.headers["type"] portion of the test but am not sure why? Any help would be appreciated.

Thanks,

Re: Integration Test Problem

The response type includes the "charset" as well as the string you are looking for. Try assert_match instead.

assert_equal /application\/xml/, response.headers["type"]

This will do a partial search so it should pass.

Railscasts - Free Ruby on Rails Screencasts

Re: Integration Test Problem

Using assert_match works and the test passes but then the output I get looks like this and I am not sure what it means at all.

C:\rails\store>ruby test/integration/browsing_and_searching_test.rb
Loaded suite test/integration/browsing_and_searching_test
Started
DEPRECATION WARNING: end_form_tag is deprecated and will be removed from Rails 2
.0  See http://www.rubyonrails.org/deprecation for details. (called from _run_rh
tml_47app47views47catalog47_search_box46rhtml at C:/rails/store/config/../app/vi
ews/catalog/_search_box.rhtml:4)
ignoring attempt to close channel with link
  opened at byte 105, line 3
  closed at byte 180, line 5
  attributes at open: {}
  text around open: "c/elements/1.1/\">\n  <channel>\n    <title"
  text around close: "p://www.example.com/</link>\n    <languag"
ignoring attempt to close item with link
  opened at byte 314, line 9
  closed at byte 556, line 14
  attributes at open: {}
  text around open: "t</description>\n    <item>\n      <title>"
  text around close: ".com/catalog/show/10</link>\n    </item>\n"
ignoring attempt to close item with link
  opened at byte 580, line 16
  closed at byte 840, line 21
  attributes at open: {}
  text around open: "nk>\n    </item>\n    <item>\n      <title>"
  text around close: "e.com/catalog/show/9</link>\n    </item>\n"
ignoring attempt to close item with link
  opened at byte 864, line 23
  closed at byte 1118, line 28
  attributes at open: {}
  text around open: "nk>\n    </item>\n    <item>\n      <title>"
  text around close: "e.com/catalog/show/8</link>\n    </item>\n"
ignoring attempt to close item with link
  opened at byte 1142, line 30
  closed at byte 1428, line 35
  attributes at open: {}
  text around open: "nk>\n    </item>\n    <item>\n      <title>"
  text around close: "e.com/catalog/show/7</link>\n    </item>\n"
ignoring attempt to close item with link
  opened at byte 1452, line 37
  closed at byte 1738, line 42
  attributes at open: {}
  text around open: "nk>\n    </item>\n    <item>\n      <title>"
  text around close: "e.com/catalog/show/6</link>\n    </item>\n"
ignoring attempt to close item with link
  opened at byte 1762, line 44
  closed at byte 2048, line 49
  attributes at open: {}
  text around open: "nk>\n    </item>\n    <item>\n      <title>"
  text around close: "e.com/catalog/show/5</link>\n    </item>\n"
ignoring attempt to close item with link
  opened at byte 2072, line 51
  closed at byte 2358, line 56
  attributes at open: {}
  text around open: "nk>\n    </item>\n    <item>\n      <title>"
  text around close: "e.com/catalog/show/4</link>\n    </item>\n"
ignoring attempt to close item with link
  opened at byte 2382, line 58
  closed at byte 2668, line 63
  attributes at open: {}
  text around open: "nk>\n    </item>\n    <item>\n      <title>"
  text around close: "e.com/catalog/show/3</link>\n    </item>\n"
ignoring attempt to close item with link
  opened at byte 2692, line 65
  closed at byte 2978, line 70
  attributes at open: {}
  text around open: "nk>\n    </item>\n    <item>\n      <title>"
  text around close: "e.com/catalog/show/2</link>\n    </item>\n"
ignoring attempt to close item with link
  opened at byte 3002, line 72
  closed at byte 3296, line 77
  attributes at open: {}
  text around open: "nk>\n    </item>\n    <item>\n      <title>"
  text around close: "e.com/catalog/show/1</link>\n    </item>\n"
..
Finished in 2.0 seconds.

2 tests, 71 assertions, 0 failures, 0 errors


Why does this information now appear after running the test? Does it have something to do with the rxml file?
Thanks for the help,

Re: Integration Test Problem

Sounds like it, is the XML you are spitting out valid? The assert_tag method may be having a hard time parsing it. assert_tag is also being deprecated (AFAIK) in favor of assert_select. I would look into using that.

Railscasts - Free Ruby on Rails Screencasts