capybara - Rspec issues with Devise -


in tickets_controller.rb:

def create     @ticket = @project.tickets.build(ticket_params)     @ticket.author = current_user     if @ticket.save       flash[:notice] = "ticket has been created."       redirect_to [@project, @ticket]     else       flash.now[:alert] = "ticket has not been created."       render "new"     end 

end

so assumed, should ok pass test, it's giving me errors below.

i'm under impression it's not invoking email address current_user.email...

the repo here https://github.com/tenzan/ticketee.

deployed version here https://github.com/tenzan/ticketee

$ rspec spec/features/creating_tickets_spec.rb ...f  failures:    1) users can create new tickets valid attributes      failure/error: expect(page).to have_content "author: #{user.email}"        expected find text "author: test4@example.com" in "internet explorer non-standards compliance pages ugly!"      # ./spec/features/creating_tickets_spec.rb:36:in `block (3 levels) in <top (required)>'      # ./spec/features/creating_tickets_spec.rb:35:in `block (2 levels) in <top (required)>'  finished in 0.64558 seconds (files took 1.3 seconds load) 4 examples, 1 failure  failed examples:  rspec ./spec/features/creating_tickets_spec.rb:30 # users can create new tickets valid attributes 

update 1:

show.html.erb ticket:

<header>   <h2><%= @ticket.name %></h2>   <ul class="actions">     <li><%= link_to "edit ticket", [:edit, @project, @ticket],       class: "edit" %></li>       <li><%= link_to "delete ticket", [@project, @ticket], method: :delete,       data: { confirm: "are sure want delete ticket?"},       class: "delete" %></li>   </ul> </header>  <table id="attributes">    <tr>      <th>author: </th>      <td><%= @ticket.author.email %></td>    </tr>    <tr>      <th>created: </th>      <td><%= time_ago_in_words(@ticket.created_at) %> ago</td>    </tr> </table>  <div id="ticket">   <header>     <h1><%= @project.name %></h1>   </header>   <header>     <h2><%= @ticket.name %></h2> </header>   <%= simple_format(@ticket.description) %> </div> 

creating_tickets_specs.rb:

require 'rails_helper'  rspec.feature 'users can create new tickets'   let(:user) { factorygirl.create(:user) }   before     login_as(user)     project = factorygirl.create(:project, name: "internet explorer")     visit project_path(project)     click_link "new ticket"   end   scenario "with valid attributes"     fill_in "name", with: "non-standards compliance"     fill_in "description", with: "my pages ugly!"     click_button "create ticket"     expect(page).to have_content "ticket has been created."     within("#ticket")       expect(page).to have_content "author: #{user.email}"     end   end   scenario "when providing invalid attributes"     click_button "create ticket"     expect(page).to have_content "ticket has not been created."     expect(page).to have_content "name can't blank"     expect(page).to have_content "description can't blank"   end   scenario "with invalid description"     fill_in "name", with: "non-standards compliance"     fill_in "description", with: "it sucks"     click_button "create ticket"     expect(page).to have_content "ticket has not been created."     expect(page).to have_content "description short"   end end 

a couple things

  1. after set author on ticket, calling save?
  2. what in show template it's blowing up?

typically write controller code as:

current_user.tickets.create ticket_params 

which, assuming relationships set correctly, automatically set relationships expect.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -