Anyone have any tips on how to test an rss feed with cucumber (preference) or rspec?
Note, I am currently working on a Rails 3 application with a blog which I expose as an rss feed.
I would like to set up a test to ensure that it remains well formatted and consumable.
Thanks!
Jonathan
To test an RSS feed with RSpec you can use :format => "rss"
in your controller tests, i.e. you can simple use something like this:
describe "GET RSS feed" do
it "returns an RSS feed" do
get :index, :format => "rss"
response.should be_success
response.should render_template("posts/index")
response.content_type.should eq("application/rss+xml")
end
end
Using Test::Unit, you would write
def test_get_rss_feed
get :index, :format => "rss"
assert_response :success
assert_template "posts/index"
assert_equal 'application/rss+xml', @response.content_type
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With