views:

13

answers:

1

hi , i am working in Rspec of ROR.. I am trying to test my controllers using RSpec.i am having a Users controller with functions like new , tags, etc..

i created a file under spec/users_controller_spec.rb

and added the test cases as.

 require 'spec_helper'

describe UsersController do
integrate_views

it "should use UsersController" do
   controller.should be_an_instance_of(UsersController)
end


describe "GET 'new'" do
    it "should be successful" do
      get 'new'
      response.should be_success
    end

    it "should have the title" do
      get 'new'
      response.should have_tag("title", "First app" )
    end
end
end

which gets pass.

But when i add a test case for tags .. like

  describe "GET 'tags'" do
    it "should be successful" do
      get 'tags'
      response.should be_success
    end
  end

this results in an error as

F...

1) 'UsersController GET 'tags' should be successful' FAILED expected success? to return true, got false

why it is coming like this ?? i am very new to ROR and cant find the reason of why i am getting this error.. How to make this pass . Also i tried the Url

http://localhost:3000/users/tags which is running for me .. But on testing using $spec spec/ i am getting the error ..

A: 

Your test may be failing for any number of reasons. Does the route require an ID in the parameter hash? Is the controller action redirecting? Is the controller raising an error?

You'll need to look at the controller code /and/or routes.rb to discover the cause of the failure. Take note of before filters in the controller, which may not allow the action to be reachable at all.

zetetic