Ruby-on-rails – Missing template sessions/new, application/new with {:locale=>[:en]

ruby-on-rails

I seem to be failing 6 spec tests. The good news is that I'm failing them all for the same reason! So, these are the test results I'm getting:

1) Authentication signin page
Failure/Error: before { visit signin_path }
ActionView::MissingTemplate:
Missing template sessions/new, application/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Brawain/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:8:in `block (3 levels) in '

2) Authentication signin page
Failure/Error: before { visit signin_path }
ActionView::MissingTemplate:
Missing template sessions/new, application/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Brawain/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:8:in `block (3 levels) in '

3) Authentication signin page with valid information
Failure/Error: before { visit signin_path }
ActionView::MissingTemplate:
Missing template sessions/new, application/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Brawain/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:8:in `block (3 levels) in '

4) Authentication signin page with valid information
Failure/Error: before { visit signin_path }
ActionView::MissingTemplate:
Missing template sessions/new, application/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Brawain/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:8:in `block (3 levels) in '

5) Authentication signin page with valid information
Failure/Error: before { visit signin_path }
ActionView::MissingTemplate:
Missing template sessions/new, application/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Brawain/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:8:in `block (3 levels) in '

6) Authentication signin page with valid information
Failure/Error: before { visit signin_path }
ActionView::MissingTemplate:
Missing template sessions/new, application/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Brawain/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:8:in `block (3 levels) in '

And here are the relevant documents. So, my spec:

require 'spec_helper'

describe "Authentication" do

subject { page }

describe "signin page" do
before { visit signin_path }

it { should have_content('Sign in') }
it { should have_title('Sign in') }

describe "with valid information" do
  let(:user) { FactoryGirl.create(:user) }
  before do
    fill_in "Email",    with: user.email.upcase
    fill_in "Password", with: user.password
    click_button "Sign in"
  end

  it { should have_title(user.first) }
  it { should have_link('Profile',     href: user_path(user)) }
  it { should have_link('Sign out',    href: signout_path) }
  it { should_not have_link('Sign in', href: signin_path) }
end
end
end

This is my utilities.rb

include ApplicationHelper

def full_title(page_title)
base_title = "Techmasters"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end

def valid_signin(user)
fill_in "Email",    with: user.email
fill_in "Password", with: user.password
click_button "Sign in"
end

RSpec::Matchers.define :have_error_message do |message|
match do |page|
expect(page).to have_selector('div.alert.alert-error', text: message)
end
end

signin page at app/views/sessions/new.html.erb

<% provide(:title, "Sign in") %>
<h1>Sign in</h1>

<div class="row">
<div class="span6 offset3">
<%= form_for(:session, url: sessions_path) do |f| %>

  <%= f.label :email %>
  <%= f.text_field :email %>

  <%= f.label :password %>
  <%= f.password_field :password %>

  <%= f.submit "Sign in", class: "btn btn-large btn-primary" %>
<% end %>

<p>New user? <%= link_to "Sign up now!", signup_path %></p>
</div>
</div>

sessions controller

class SessionsController < ApplicationController

def new
end

def create
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
  sign_in user
  redirect_to user
else
  flash.now[:error] = 'Invalid email/password combination'
  render 'new'
end
end

def destroy
end
end

my user controller

class User < ActiveRecord::Base
attr_accessible :first, :last, :email, :password, :password_confirmation
has_secure_password

before_save { self.email = email.downcase }
before_create :create_remember_token
validates :first, :last, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[andover]+\.[edu]+\z/i
validates :email, presence:   true,
                format:     { with: VALID_EMAIL_REGEX },
                uniqueness: { case_sensitive: false }
validates :password, length: { minimum: 6 }

has_and_belongs_to_many :order
has_many :orders_users

def User.new_remember_token
SecureRandom.urlsafe_base64
end

def User.encrypt(token)
Digest::SHA1.hexdigest(token.to_s)
end

private

def create_remember_token
  self.remember_token = User.encrypt(User.new_remember_token)
end
end

sessions helper

module SessionsHelper

def sign_in(user)
remember_token = User.new_remember_token
cookies.permanent[:remember_token] = remember_token
user.update_attribute(:remember_token, User.encrypt(remember_token))
self.current_user = user
end

def signed_in?
!current_user.nil?
end

def current_user=(user)
@current_user = user
end

def current_user
remember_token = User.encrypt(cookies[:remember_token])
@current_user ||= User.find_by(remember_token: remember_token)
end

end

header code

<header class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
  <%= link_to "sample app", root_path, id: "logo" %>
  <nav>
    <ul class="nav pull-right">
      <li><%= link_to "Home", root_path %></li>
      <li><%= link_to "Help", help_path %></li>
      <% if signed_in? %>
        <li><%= link_to "Users", '#' %></li>
        <li id="fat-menu" class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            Account <b class="caret"></b>
          </a>
          <ul class="dropdown-menu">
            <li><%= link_to "Profile", current_user %></li>
            <li><%= link_to "Settings", '#' %></li>
            <li class="divider"></li>
            <li>
              <%= link_to "Sign out", signout_path, method: "delete" %>
            </li>
          </ul>
        </li>
      <% else %>
        <li><%= link_to "Sign in", signin_path %></li>
      <% end %>
    </ul>
  </nav>
</div>
</div>
</header>

this is the signup page

<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>

<div class="row">
<div class="span6 offset3">
<%= form_for(@user) do |f| %>
    <%= render 'shared/error_messages' %>

    <%= f.label :first %>
    <%= f.text_field :first %>

    <%= f.label :last %>
    <%= f.text_field :last %>

    <%= f.label :email %>
    <%= f.text_field :email %>

    <%= f.label :password %>
    <%= f.password_field :password %>

    <%= f.label :password_confirmation, "Confirmation" %>
    <%= f.password_field :password_confirmation %>

  <%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
<% end %>
</div>
</div>

I think that's all the possible information I could give you. I could give you my other specs but I passed those so I think that would be silly. Anyway, do any of you guys know what's wrong?

Edit: Rake routes command.

  Prefix Verb   URI Pattern               Controller#Action
  users GET    /users(.:format)          users#index
        POST   /users(.:format)          users#create
new_user GET    /users/new(.:format)      users#new
edit_user GET    /users/:id/edit(.:format) users#edit
   user GET    /users/:id(.:format)      users#show
        PATCH  /users/:id(.:format)      users#update
        PUT    /users/:id(.:format)      users#update
        DELETE /users/:id(.:format)      users#destroy
sessions POST   /sessions(.:format)       sessions#create
new_session GET    /sessions/new(.:format)   sessions#new
session DELETE /sessions/:id(.:format)   sessions#destroy
   root GET    /                         static_pages#home
 signup GET    /signup(.:format)         users#new
 signin GET    /signin(.:format)         sessions#new
signout DELETE /signout(.:format)        sessions#destroy
   help GET    /help(.:format)           static_pages#help
  about GET    /about(.:format)          static_pages#about
contact GET    /contact(.:format)        static_pages#contact

Best Answer

for those errors its just saying it can't find the view file with those handlers,

Mind if I have a look at the results of your

rake routes

command?

I'm assuming you don't have any other specs that call

visit signin_path
Related Topic