2011-08-21 61 views
0

我試圖讓Rspec的啓動和運行,但在命令行中調用rspec spec時遇到了以下問題:Rspec的不Rails3中正常工作,FactoryGirl

Failure/Error: Unable to find matching line from backtrace 
    undefined method `request=' for #<Name:0x000001033c1be0> 

這似乎是一個問題某些寶石的組合,但我無法弄清楚what's錯了我的設置:

這就是:

rails -v 
Rails 3.0.9 
ruby -v 
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] 
rvm -v 
rvm 1.6.2 

我的Gemfile看起來像這樣(我跳過irrelevan噸寶石):

group :development, :test do 
gem 'factory_girl_rails' 
gem 'rspec-rails', '~> 2.6' 
gem 'webrat' 
end 

增加:

我添加以下行spec_helper.rb,爲了固定被描述here的誤差。

config.include RSpec::Rails::ControllerExampleGroup 

任何提示?

+0

嘗試寶石「RSpec的護欄」,「〜> 2.6」 –

+0

不:-(幫助 – auralbee

回答

1

與此同時我解決了這個問題。

上面描述的問題發生在我設置我的第一個控制器測試時。

describe MyController do 
    describe "#index" do 
    it "responses successfully" do 
     get :index 
     response.should be_success 
    end 
    end 
end 

爲了擺脫這個問題,我不得不將上述提到的行從spec_helper直接移到ControllerSpec中。

describe MyController do 
    include RSpec::Rails::ControllerExampleGroup 

    describe "#index" do 
    it "responses successfully" do 
     get :index 
     response.should be_success 
    end 
    end 
end 

回去工作;-)

+0

我有同樣的問題,但你的解決方案沒有奏效爲了我 :-( –