Hey guys,
I have a custom MIME type registered like that:
cat config/initializers/mime_types.rb
Mime::Type.register “lightbox”, :lightbox
→ This works perfectly well in my application.
However my corresponding specs keep failing, the code:
The controller-spec:
describe UserSessionsController do
describe ‘new action’ do
it ‘should render the new-template on lightbox-request’ do
get :new, :format => :lightbox
response.should render_template(:new)
end
end
end
The controller-action:
def new
@user_session = UserSession.new
respond_to do |format|
format.lightbox do
render :layout => false
end
format.html do
render
end
end
end
Running the spec:
bin/spec spec/controllers/user_sessions_controller_spec.rb -l 25
F
1)
‘UserSessionsController new action should render the new-template on
lightbox-request’ FAILED
expected “new”, got nil
./spec/controllers/user_sessions_controller_spec.rb:
26:
Finished in
0.338956
1 example, 1 failure
With line 26 of the spec being:
response.should render_template(:new)
The interesting thing now is in test.log:
Processing UserSessionsController#new to lightbox (for 0.0.0.0 at
2010-04-29 11:31:41) [GET]
Parameters: {“format”=>:lightbox, “action”=>“new”,
“controller”=>“user_sessions”}
Completed in 84ms (View: 2, DB: 558) | 406 Not Acceptable [http://
test.host/user_sessions/new.lightbox]
SQL (10.0ms) ROLLBACK
Hmmm → 406 Not Acceptable?
However, i can call up http://test.host/user_sessions/new.lightbox
manually in the browser without problems - the view is rendered,
without a layout, just as specified in the controller.
So this seems to be an rspec-specific problem - any ideas on how to
proceed?