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 7784339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:04:47+00:00 2026-06-01T20:04:47+00:00

I’m running these rspec tests for my controller: require ‘spec_helper’ describe MoviesController do describe

  • 0

I’m running these rspec tests for my controller:

require 'spec_helper'

describe MoviesController do
  describe 'searching for similar movies' do
    before :each do 
      @fake_movies = [mock('Movie'), mock('Movie')]
      @fake_movie = FactoryGirl.build(:movie, :id => "1", :title => "Star Wars", :director => "George Lucas") 
    end
    it 'should follow the route to the similar movies by director page' do
      assert_routing('movies/1/similar', {:controller => 'movies', :action => 'similar', :id => '1'}) 
    end

    it 'should find the similar movies by director' do
      Movie.should_receive(:find_by_id).with("1").and_return(@fake_movie)
      Movie.should_receive(:find_by_director).with(@fake_movie.director).and_return(@fake_movies)
      get :similar, {:id => "1"}
    end

    it 'should select the Similiar Movies template for rendering' do
      Movie.should_receive(:find_by_id).with("1").and_return(@fake_movie)
      Movie.should_receive(:find_by_director).with(@fake_movie.director).and_return(@fake_movies)
      get :similar, {:id => "1"}
      response.should render_template('similar')
    end

    it 'it should make the results available to the template' do
      Movie.should_receive(:find_by_id).with("1").and_return(@fake_movie)
      Movie.should_receive(:find_by_director).with(@fake_movie.director).and_return(@fake_movies)
      get :similar, {:id => "1"}
      assigns(:movies).should == @fake_results
    end
  end
end

Buy they are failing with this output:

    Failures:

  1) MoviesController searching for similar movies should find the similar movies by director
     Failure/Error: get :similar, {:id => "1"}
       <Movie(id: integer, title: string, rating: string, description: text, release_date: datetime, created_at: datetime, updated_at: datetime, director: string) (class)> received :find_by_director with unexpected arguments
         expected: ("George Lucas")
              got: ()
     # ./app/controllers/movies_controller.rb:62:in `similar'
     # ./spec/controllers/movies_controller_spec.rb:17:in `block (3 levels) in <top (required)>'

  2) MoviesController searching for similar movies should select the Similiar Movies template for rendering
     Failure/Error: get :similar, {:id => "1"}
       <Movie(id: integer, title: string, rating: string, description: text, release_date: datetime, created_at: datetime, updated_at: datetime, director: string) (class)> received :find_by_director with unexpected arguments
         expected: ("George Lucas")
              got: ()
     # ./app/controllers/movies_controller.rb:62:in `similar'
     # ./spec/controllers/movies_controller_spec.rb:23:in `block (3 levels) in <top (required)>'

  3) MoviesController searching for similar movies it should make the results available to the template
     Failure/Error: get :similar, {:id => "1"}
       <Movie(id: integer, title: string, rating: string, description: text, release_date: datetime, created_at: datetime, updated_at: datetime, director: string) (class)> received :find_by_director with unexpected arguments
         expected: ("George Lucas")
              got: ()
     # ./app/controllers/movies_controller.rb:62:in `similar'
     # ./spec/controllers/movies_controller_spec.rb:30:in `block (3 levels) in <top (required)>'

Finished in 0.15517 seconds
4 examples, 3 failures

Failed examples:

rspec ./spec/controllers/movies_controller_spec.rb:14 # MoviesController searching for similar movies should find the similar movies by director
rspec ./spec/controllers/movies_controller_spec.rb:20 # MoviesController searching for similar movies should select the Similiar Movies template for rendering
rspec ./spec/controllers/movies_controller_spec.rb:27 # MoviesController searching for similar movies it should make the results available to the template

When this is my controller method:

def similar 
    @movies = Movie.find_by_director(Movie.find_by_id(params[:id]))
  end

I do not understand why these tests are failing.

  • 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-01T20:04:48+00:00Added an answer on June 1, 2026 at 8:04 pm

    The problem was I was calling the wrong method. find_by_director isn’t the method that was supposed to be used, but find_all_by_director, hence what was going to the method was wrong.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.