2013-06-04 21 views
5

Adlandırılmış bir denetleyici için bir RSpec denetleyici sınaması oluşturmaya çalışıyorum, ancak rspec yuvalamayı algılayamayacak ve post :create eylemi için uygun yolu oluşturamıyor. RSpec Denetleyici Sınama doğru URL üretmiyor

Bu

benim Spec kodu: Bu kodu için

# for: /app/controllers/admin/crm/report_adjustments_controller.rb 
require 'spec_helper' 
describe Admin::Crm::ReportAdjustmentsController do 
    render_views 

    before(:each) do 
    signin 
    end 

    describe "GET 'index'" do 
    it "returns http success" do 
     get :index 
     response.should be_success 
    end 
    end 

    describe "POST 'create'" do 
    it "creates with right parameters" do 
     expect { 
     post :create, report_adjustment: {distributor_id: @ole_distributor.id, amount: "30.0", date: Date.today } 
     }.to change(Crm::ReportAdjustment, :count).by(1) 
     response.should be_success 
    end 
    end 
end 

# routes.rb 
namespace :admin do 
    namespace :crm do 
    resources :report_adjustments 
    end 
end 

, get :index inşaat iyi ama post :create çağrıldığında, aşağıdaki hata oluşturulur: undefined method 'crm_report_adjustment_url'

Neden RSpec yeterince akıllı olurdu get :index ile bir şeyler anlamaya, ancak post :create ile değil? RSpec'in doğru yolu doğru şekilde yüklemesi için admin_crm_report_adjustments_url nedir?

Şimdiden teşekkürler. yerine url

+1

hem ': get' ve': post' aynı ele alınmalıdır. http://apidock.com/rails/v3.2.13/ActionController/TestCase/Behavior/process adresindeki pry hata ayıklayıcısını kullanarak uygulamanızda hata ayıklamayı deneyebilir ya da – phoet

+0

koyar Aynı problemi yaşıyorum, çözümü @roflmao mu buldunuz? – dwhite

cevap

1

deneyin gönderme:

post admin_crm_report_adjustments_url 

# or 

post "/admin/crm/report_adjustments" 
İlgili konular