Hello, everyone. I've been lurking here for a while, but this is my first post.
I think I've run into a RSpec bug in a Rails project I'm working on. I was working on a few REST controllers, and started getting failures on a specific spec that verified whether a certain action returned XML output. I spent quite a lot of time checking my code to see if it was something I did wrong, but it works when I test it manually. So I created an empty Rails app, and wrote the bare minimum of code necessary to reproduce this problem. I'm using Rails 2.1.1, with rspec-1.1.8 and rspec-rails-1.1.8, all installed as gems. I started by creating a dead-simple model with two string attributes and no validations, along with this fixture: # spec/fixtures/users.yml one: name: Name email: email Then I created a simple controller, and its corresponding spec. class UsersController < ApplicationController def index respond_to do |format| format.xml { render :xml => User.find(:all).to_xml} end end end # spec require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe UsersController do fixtures :users it "should return a XML user list" do get :index, :format => :xml response.body.should == User.find(:all).to_xml end end It all looks straightforward enough - I use the same call on both the controller and the spec, so the two results should indeed be the same. However, when I run the spec I get this failure: 1) 'UsersController should return a XML user list' FAILED expected: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<users type=\"array\">\n <user>\n <created-at type=\"datetime\">2008-10-20T11:24:28Z</created-at>\n <email>email</email>\n <id type=\"integer\">953125641</id>\n <name>Name</name>\n <updated-at type=\"datetime\">2008-10-20T11:24:28Z</updated-at>\n </user>\n</users>\n", got: " " (using ==) ./spec/controllers/users_controller_spec.rb:10: /usr/lib64/ruby/1.8/timeout.rb:53:in `timeout' Finished in 0.256981 seconds This happens both when using "rake spec" and when running only that spec file. Firing up the app and accessing localhost:3000/users.xml returns the correct result. In the "real" project, it's even weirder: the "expected" site of the assertion shows a string composed of the XML out put concatenated to itself, and the "got" side has the correct output. Something like "Expected 'aa' but got 'a'". What could the problem be? Is it really a RSpec bug, or is it something I did wrong? -- Bira http://compexplicita.wordpress.com http://compexplicita.tumblr.com _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users