Last active
August 29, 2015 13:58
-
-
Save Solnse/10168765 to your computer and use it in GitHub Desktop.
rspec error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FF | |
Failures: | |
1) Creating Projects can create a project | |
Failure/Error: click_link 'New Project' | |
ActionController::ParameterMissing: | |
param not found: project | |
# ./app/controllers/projects_controller.rb:29:in `project_params' | |
# ./app/controllers/projects_controller.rb:6:in `new' | |
# ./spec/features/creating_projects_spec.rb:7:in `block (2 levels) in <top (required)>' | |
2) Creating Projects can not create a project without a name | |
Failure/Error: click_link 'New Project' | |
ActionController::ParameterMissing: | |
param not found: project | |
# ./app/controllers/projects_controller.rb:29:in `project_params' | |
# ./app/controllers/projects_controller.rb:6:in `new' | |
# ./spec/features/creating_projects_spec.rb:7:in `block (2 levels) in <top (required)>' | |
Finished in 0.05251 seconds | |
2 examples, 2 failures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProjectsController < ApplicationController | |
def index | |
end | |
def new | |
# book says to have @project = Project.new(project_params) | |
@project = Project.new() | |
@project.save | |
end | |
def create | |
@project = Project.new(project_params) | |
if @project.save | |
flash[:notice] = "Project has been created." | |
redirect_to @project | |
else | |
flash[:alert] = "Project has not been created." | |
render "new" | |
end | |
end | |
def show | |
@project = Project.find(params[:id]) | |
end | |
private | |
def project_params | |
params.require(:project).permit(:name, :description) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
feature 'Creating Projects' do | |
before do | |
visit '/' | |
click_link 'New Project' | |
end | |
scenario "can create a project" do | |
fill_in 'Name', with: 'TextMate 2' | |
fill_in 'Description', with: 'A text-editor for the masses' | |
click_button 'Create Project' | |
expect(page).to have_content('Project has been created.') | |
project = Project.where(name: "TextMate 2").first | |
expect(page.current_url).to eql(project_url(project)) | |
title = "TextMate 2 - Projects - Ticketee" | |
expect(page).to have_title(title) | |
end | |
scenario "can not create a project without a name" do | |
click_button 'Create Project' | |
expect(page).to have_content("Project has not been created.") | |
expect(page).to have_content("Name can't be blank") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment