Search code examples
ruby-on-railsrspecrspec-rails

Failure/Error: click_button "Sign in" ActionView::MissingTemplate:


I am actually clicking on the Sign in button. But it was a ajax call using jquery/ajax to process the sign in. Please help me how to resolve this issue. I am getting this error while testing with rspec.

Error:

Creating todos after login should show the left navigation on the dashboard
Failure/Error: click_button "Sign in"
ActionView::MissingTemplate:
Missing template sessions/create, application/create with {:locale=>[:en],    

**spec/features/todos/create_spec.rb**
describe "Creating todos" do

  let(:user) { FactoryGirl.create(:user)}
  before(:each) do
    visit root_path
    click_link "Login"

    fill_in "login_email",  with:  "[email protected]"
    fill_in "password",  with: "password"
    click_button "Sign in"
  end

  describe "after login" do
    it "should show the left navigation on the dashboard" do
      visit employees_dashboard_path
      page.should have_link('Todo', href: todos_path)
    end
  end

view form:

<div id="signinForm">
  <%= form_tag sessions_url, remote: true do |f| %>
    <div class="form-group">
      <%= text_field_tag :email, "", placeholder: "Email", class: "form-control", id:                      "login_email", data: {errorkey: "email"} %>
    </div>
    <div class="form-group">
          <%= password_field_tag :password, "", placeholder: "Password", class: "form-control", data: {errorkey: "password"} %>
    </div>
    <button type="submit" class="btn btn-block btn-primary">Sign in</button>
  <% end %>
</div>

Solution

  • Resolved my issue!. I am actually making ajax calls in my app. So I need to add js true to resolve this issue.

    describe "Creating todos" , :js => true do