I have a UsersController that has index
and new
actions. I use haml, the index haml file contains the following code:
= link_to 'Add User', new_user_path, { :remote => true, 'data-toggle' => 'modal',
'data-target' => '#modal-window', 'class' => 'btn btn-primary pull-right' }
So when the user clicks 'Add User' the _new.html.haml
partial is presented to the user as a modal. It works great. Here's the new action in the controller:
def new
@user = User.new
respond_to do |format|
format.html
format.js
end
end
Now in my controller spec I am trying to do the following:
describe "new action" do
before do
get 'new'
end
# specs for 'new' action go here
end
However that gives an error
Failure/Error: get 'new'
ActionView::MissingTemplate:
Missing template users/new, application/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:
* "#<RSpec::Rails::ViewRendering::EmptyTemplatePathSetDecorator:0x007faa44b03218>"
Presumably because it can't find new.html.haml
which of course doesn't exist because the file is a partial named _new.html.haml
. What is the correct syntax for get
ting the partial? If not, how can I test the new
action?