<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to test a XML builder view</title>
	<atom:link href="http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/feed/" rel="self" type="application/rss+xml" />
	<link>http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/</link>
	<description>Rails experiments by Matt Aimonetti</description>
	<lastBuildDate>Tue, 23 Feb 2010 22:05:18 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Mislav</title>
		<link>http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/comment-page-1/#comment-1536</link>
		<dc:creator>Mislav</dc:creator>
		<pubDate>Wed, 31 Oct 2007 08:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view#comment-1536</guid>
		<description>Great article. How about making your life easier with a helper?

&lt;pre&gt;&lt;code&gt;def hpricot
  yield Hpricot.XML(response.body.to_s)
end
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code&gt;  it &quot;should have the high average as values of the first graph&quot; do
    render &quot;/averages/index.xml.builder&quot;
    hpricot do &#124;doc&#124;
      (doc/:graph/:value).first.inner_html.should == &quot;74.5&quot;
    end
  end
&lt;/code&gt;&lt;/pre&gt;

Also, in places where you use @inner_html@ you should maybe use @inner_text@ if you want to test text content of a specific element, not markup.</description>
		<content:encoded><![CDATA[<p>Great article. How about making your life easier with a helper?</p>
<p>&lt;pre&gt;&lt;code&gt;def hpricot<br />
  yield Hpricot.XML(response.body.to_s)<br />
end<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p>&lt;pre&gt;&lt;code&gt;  it &quot;should have the high average as values of the first graph&quot; do<br />
    render &quot;/averages/index.xml.builder&quot;<br />
    hpricot do |doc|<br />
      (doc/:graph/:value).first.inner_html.should == &quot;74.5&quot;<br />
    end<br />
  end<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p>Also, in places where you use @inner_html@ you should maybe use @inner_text@ if you want to test text content of a specific element, not markup.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mislav</title>
		<link>http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/comment-page-1/#comment-1537</link>
		<dc:creator>Mislav</dc:creator>
		<pubDate>Wed, 31 Oct 2007 08:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view#comment-1537</guid>
		<description>I hate Textile, it always mangles what I wanted to say :(</description>
		<content:encoded><![CDATA[<p>I hate Textile, it always mangles what I wanted to say <img src='http://railsontherun.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Knowles</title>
		<link>http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/comment-page-1/#comment-1538</link>
		<dc:creator>Josh Knowles</dc:creator>
		<pubDate>Wed, 31 Oct 2007 08:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view#comment-1538</guid>
		<description>Cool use of hpricot, but why not just use the built in have_tag matcher?  There is nothing unique about the xml that couldn&#039;t be tested the same as html.</description>
		<content:encoded><![CDATA[<p>Cool use of hpricot, but why not just use the built in have_tag matcher?  There is nothing unique about the xml that couldn&#8217;t be tested the same as html.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Aimonetti</title>
		<link>http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/comment-page-1/#comment-1539</link>
		<dc:creator>Matt Aimonetti</dc:creator>
		<pubDate>Wed, 31 Oct 2007 08:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view#comment-1539</guid>
		<description>@mislav you are replacing  doc = Hpricot.XML(response.body.to_s) by a bloc using a helper. I like the idea of using a helper, but why not doing something like:

    def parse_xml_response
       Hpricot.XML(response.body.to_s)
    end

then use it as:

  it &quot;should have the high average as values of the first graph&quot; do
    render &quot;/averages/index.xml.builder&quot;
    doc = parse_xml_response
    (doc/:graph/:value).first.inner_html.should == &quot;74.5&quot;
  end

Didn&#039;t try it but looks better than a bloc to me. What do you think? Did you have a specific reason to use a bloc?

Good point about inner_text!</description>
		<content:encoded><![CDATA[<p>@mislav you are replacing  doc = Hpricot.XML(response.body.to_s) by a bloc using a helper. I like the idea of using a helper, but why not doing something like:</p>
<p>    def parse_xml_response<br />
       Hpricot.XML(response.body.to_s)<br />
    end</p>
<p>then use it as:</p>
<p>  it &quot;should have the high average as values of the first graph&quot; do<br />
    render &quot;/averages/index.xml.builder&quot;<br />
    doc = parse_xml_response<br />
    (doc/:graph/:value).first.inner_html.should == &quot;74.5&quot;<br />
  end</p>
<p>Didn&#8217;t try it but looks better than a bloc to me. What do you think? Did you have a specific reason to use a bloc?</p>
<p>Good point about inner_text!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Aimonetti</title>
		<link>http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/comment-page-1/#comment-1540</link>
		<dc:creator>Matt Aimonetti</dc:creator>
		<pubDate>Wed, 31 Oct 2007 08:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view#comment-1540</guid>
		<description>stupid textle!

Here is the snippet of code which got messed up:

    it &quot;should have the high average as values of the first graph&quot; do
      render &quot;/averages/index.xml.builder&quot;
      doc = parse_xml_response
      (doc/:graph/:value).first.inner_html.should == &quot;74.5&quot;
    end


@joshknowles


    it &quot;should render the months in the series&quot; do
      render &quot;/averages/index.xml.builder&quot;
      response.should have_tag(&quot;value&quot;, &#039;February&#039;)
      response.should have_tag(&quot;value&quot;, &#039;November&#039;)
      doc = Hpricot.XML(response.body.to_s)
      (doc/:value).first.inner_html.should == &#039;February&#039;
      (doc/:value)[1].inner_html.should == &#039;November&#039;
    end

works well but I can&#039;t find a way to check a node&#039;s attribute:

    it &quot;should set the xid attributes for the series&quot; do
      render &quot;/averages/index.xml.builder&quot;
      doc = Hpricot.XML(response.body.to_s)
      (doc/:value).first[&quot;xid&quot;].should == &#039;0&#039;
      (doc/:value).last[&quot;xid&quot;].should == &#039;1&#039;
    end

-Matt</description>
		<content:encoded><![CDATA[<p>stupid textle!</p>
<p>Here is the snippet of code which got messed up:</p>
<p>    it &quot;should have the high average as values of the first graph&quot; do<br />
      render &quot;/averages/index.xml.builder&quot;<br />
      doc = parse_xml_response<br />
      (doc/:graph/:value).first.inner_html.should == &quot;74.5&quot;<br />
    end</p>
<p>@joshknowles</p>
<p>    it &quot;should render the months in the series&quot; do<br />
      render &quot;/averages/index.xml.builder&quot;<br />
      response.should have_tag(&quot;value&quot;, &#8216;February&#8217;)<br />
      response.should have_tag(&quot;value&quot;, &#8216;November&#8217;)<br />
      doc = Hpricot.XML(response.body.to_s)<br />
      (doc/:value).first.inner_html.should == &#8216;February&#8217;<br />
      (doc/:value)[1].inner_html.should == &#8216;November&#8217;<br />
    end</p>
<p>works well but I can&#8217;t find a way to check a node&#8217;s attribute:</p>
<p>    it &quot;should set the xid attributes for the series&quot; do<br />
      render &quot;/averages/index.xml.builder&quot;<br />
      doc = Hpricot.XML(response.body.to_s)<br />
      (doc/:value).first[&quot;xid&quot;].should == &#8216;0&#8242;<br />
      (doc/:value).last[&quot;xid&quot;].should == &#8216;1&#8242;<br />
    end</p>
<p>-Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Aimonetti</title>
		<link>http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/comment-page-1/#comment-1541</link>
		<dc:creator>Matt Aimonetti</dc:creator>
		<pubDate>Wed, 31 Oct 2007 08:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view#comment-1541</guid>
		<description>after chatting offline with Josh, I found a solution:


    it &quot;should set the xid attributes for the series&quot; do
      render &quot;/averages/index.xml.builder&quot;
      response.should have_tag(&quot;value[xid=0]:first-child&quot;)
      response.should have_tag(&quot;value[xid=1]:last-child&quot;)
      # same as:
      doc = Hpricot.XML(response.body.to_s)
      (doc/:value).first[&quot;xid&quot;].should == &#039;0&#039;
     (doc/:value).last[&quot;xid&quot;].should == &#039;1&#039;
  end

have_tag wraps assert_select, check out all the cool options you get with assert_select:

http://cheat.errtheblog.com/s/assert_select/

Thanks Josh!</description>
		<content:encoded><![CDATA[<p>after chatting offline with Josh, I found a solution:</p>
<p>    it &quot;should set the xid attributes for the series&quot; do<br />
      render &quot;/averages/index.xml.builder&quot;<br />
      response.should have_tag(&quot;value[xid=0]:first-child&quot;)<br />
      response.should have_tag(&quot;value[xid=1]:last-child&quot;)<br />
      # same as:<br />
      doc = Hpricot.XML(response.body.to_s)<br />
      (doc/:value).first[&quot;xid&quot;].should == &#8216;0&#8242;<br />
     (doc/:value).last[&quot;xid&quot;].should == &#8216;1&#8242;<br />
  end</p>
<p>have_tag wraps assert_select, check out all the cool options you get with assert_select:</p>
<p><a href="http://cheat.errtheblog.com/s/assert_select/" rel="nofollow">http://cheat.errtheblog.com/s/assert_select/</a></p>
<p>Thanks Josh!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: josh</title>
		<link>http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/comment-page-1/#comment-1542</link>
		<dc:creator>josh</dc:creator>
		<pubDate>Wed, 31 Oct 2007 08:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view#comment-1542</guid>
		<description>Just FYI, your xml feed refreshes several times a day. All articles are marked as new. NetNewsWire tells me I have tons of new stuff to read, but it&#039;s a lie!</description>
		<content:encoded><![CDATA[<p>Just FYI, your xml feed refreshes several times a day. All articles are marked as new. NetNewsWire tells me I have tons of new stuff to read, but it&#8217;s a lie!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Aimonetti</title>
		<link>http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view/comment-page-1/#comment-1543</link>
		<dc:creator>Matt Aimonetti</dc:creator>
		<pubDate>Wed, 31 Oct 2007 08:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://railsontherun.com/2007/10/31/how-to-test-a-xml-builder-view#comment-1543</guid>
		<description>@josh make sure you are using the feedburner feed: http://feeds.feedburner.com/railsontherun  for some reason the atom feed provided by mephisto resets itself.</description>
		<content:encoded><![CDATA[<p>@josh make sure you are using the feedburner feed: <a href="http://feeds.feedburner.com/railsontherun" rel="nofollow">http://feeds.feedburner.com/railsontherun</a>  for some reason the atom feed provided by mephisto resets itself.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
