परीक्षण के लिए नया, मैं कुछ नियंत्रक परीक्षण पास करने के लिए संघर्ष कर रहा हूं।रुपेक नियंत्रक त्रुटि <"index"> की उम्मीद है लेकिन <"">
expecting <"index"> but rendering with <"">
मैं अपने नियंत्रक चश्मा में से एक में निम्नलिखित है:
निम्नलिखित नियंत्रक परीक्षण त्रुटि फेंकता
require 'spec_helper'
describe NasController do
render_views
login_user
describe "GET #nas" do
it "populates an array of devices" do
@location = FactoryGirl.create(:location)
@location.users << @current_user
@nas = FactoryGirl.create(:nas, location_id: @location.id)
get :index
assigns(:nas).should eq([@nas])
end
it "renders the :index view" do
response.should render_template(:index)
end
end
मेरी नियंत्रक मैक्रो में, मैं यह है:
def login_user
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:user]
@current_user = FactoryGirl.create(:user)
@current_user.roles << Role.first
sign_in @current_user
User.current_user = @current_user
@user = @current_user
@ability = Ability.new(@current_user)
end
end
मैं तैयार और उपयोग कर रहा हूं और फिर अपने गाइड का पालन कर रहा हूं। परिक्षण। मेरा मानना है कि मेरे उपयोगकर्ता पहले से साइन इन हैं और इंडेक्स एक्शन देखने की क्षमता रखते हैं।
परीक्षा उत्तीर्ण करने के लिए मैं क्या कर सकता हूं?
- अद्यतन 1 -
नियंत्रक कोड:
class NasController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource
respond_to :js
def index
if params[:location_id]
...
else
@nas = Nas.accessible_by(current_ability).page(params[:page]).order(sort_column + ' ' + sort_direction)
respond_to do |format|
format.html # show.html.erb
end
end
end
अरे। वह अभी भी विफल रहता है। इसे पहले कोशिश की - स्थान निर्माण को दोहराने की भी कोशिश की। इसे मत समझो एक ही परीक्षण दूसरे नियंत्रक में गुजरता है। – simonmorley
क्या उनके नियंत्रक में कुछ ऐसा है जो आपको नाज़ तालिका खाली होने पर इंडेक्स लाने से रोकता है? –
नहीं, और मैंने दोनों devise और cancan फ़िल्टर को हटाने का प्रयास किया है। और @nas = Nas.all के साथ ढूंढने की जगह बस मामले में। निराशा होती! – simonmorley