Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8405089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:45:43+00:00 2026-06-09T22:45:43+00:00

I have a failing rspec view test but the code works – I probably

  • 0

I have a failing rspec view test but the code works – I probably have a variable incorrectly setup but can’t figure out what it is.

When I display the contents of @incident_report (pp @incident_report) in my spec, it properly displays the record created by FactoryGirl.

When I display the actual rendered content (puts rendered), it shows the values from the the record I created with FactoryGirl…

But the “rendered.should contain(work_order)” spec fails with:

1) incident_reports/show.html displays the work order number on the incident
   Failure/Error: rendered.should contain(work_order)
     expected the following element's content to include "54785":

and none of the data is displayed, only the HTML template


spec/views/incident_report/show.html.haml_spec.rb code

require 'spec_helper'

describe "incident_reports/show.html" do
  before(:each) do
    @incident_report = Factory(:incident_report)
  end

  it "displays the work order number on the incident" do
    work_order = @incident_report.work_order
    pp @incident_report    #displays an incident_report, id => 1
    assign(:incident_report, @incident_report)
    render 
    puts rendered  #this DOES have the content from @incident_report
    rendered.should contain("Work Order:")
    rendered.should contain(work_order)
    end
  end

show.html.haml code

%h1 Display Incident Report
.navigation
  = link_to 'Edit', edit_incident_report_path(@incident_report)
  |
  \#{link_to 'Back', incident_reports_path}

= render 'form'

.navigation
  = link_to 'Edit', edit_incident_report_path(@incident_report)
  |
  \#{link_to 'Back', incident_reports_path}

Gotta be something really simple I’m overlooking.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:45:45+00:00Added an answer on June 9, 2026 at 10:45 pm

    Turns out it’s because I was using simple_form and when simple_form displays for a “show” action, it puts the field values into the html as a ‘value=”54785″‘ attribute. If you display it in a browser, the labels and values all show up correctly, but rspec can’t see them.

    I had to add

    rendered.should have_tag 'input', :with => { :value => "54765", :name => 'incident_report[work_order]' }
    

    to my example to get it to work.

    Seems like there should be a better solution but at least now I can continue testing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that is failing tests, but I can't understand why. I
I have an rspec test failing, but in development, when I perform the actions
My rspec title test is failing with: 1) HomeController Get 'index should have the
This following Controller test is failing, and I can't figure out why: describe GET
I have a RSpec test that keeps failing. subject { page } visit user_path(user)
I have a failing model.save() in my Django app. How can I see the
I have a simple test case failing in Django: Model (app/models.py): from django.db import
I recently upgraded a 1.3.6 application to Grails2. My test cases have started failing
I have a number of tests failing in the following JUnit Task. <target name=test-main
tl;dr the validation works in the browser, but fails with rspec. I'm not sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.