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

  • SEARCH
  • Home
  • 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 4067536
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:15:43+00:00 2026-05-20T16:15:43+00:00

I am trying to get going with development of view components with Rspec2 and

  • 0

I am trying to get going with development of view components with Rspec2 and Rails3.
However, I make the following observation, and I don’t understand what is going on, and how to fix this.

In my spec I define:

  describe "main/index.html.erb" do
    it "displays a photo url in products partial" do
      assign(:designs, [stub_model(Design, :name => "test", :photo => "photo_url")])

      render
      rendered.should contain("photo_url")
    end
  end

When I run:

rspec spec/view/main_spec.rb

I get this error:

    1) main/index.html.erb displays a photo url in products partial
       Failure/Error: render
       ActionView::Template::Error:
         undefined method `photo' for nil:NilClass
       # ./app/views/main/_design.html.erb:3:in   `_app_views_main__design_html_erb__2937334847274155273_2170841960__1566661024965846011'
       # ./app/views/main/index.html.erb:25:in `_app_views_main_index_html_erb__837234277009287876_2170861440__898201527838028543'
       # ./spec/views/main_spec.rb:7:in `block (2 levels) in '

However, if I only ‘access’ a local photo object in my partial everything passes. This is:

in _design.html.erb:

        ---> PASS
        ---> FAIL

In my view I call my partial as follows:

main.html.erb

      { :designs => @designs } %> 

What does the community think?
Thank you for your help!

  • 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-05-20T16:15:43+00:00Added an answer on May 20, 2026 at 4:15 pm

    The problem has been solved some while ago already.

    It is important to keep “convention over configuration” in mind.
    In this case, the spec could be made working by naming the spec files exactly to the filenames in the /app folder and putting a _spec.rb at the end.
    So, the right spec for the index erb in main would be

    /spec/views/main/index.erb_spec.rb
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get into android development and I'm going through the tutorials, however
So I'm new to rhino mocks and I'm trying to get it going in
I'm trying to get a bare-bones example of logging going in my ASP.NET application.
I'm going nuts here, trying to get my system configured. I have a laptop
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Im trying to get into some basic JavaFX game development and I'm getting confused
I'm trying to get a report going which shows the individual diff-stats per commit
I'm trying to get a project going on my system. I imported the source
Trying to get my css / C# functions to look like this: body {
Trying to get an ASP application deployed; it worked for a while but then

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.