2013-11-21 2 views
0

매우 기본적인 Rspec 코드에 문제가 있습니다. 'undefined method'와 같은 문제 인 'for'for get '.정의되지 않은 메소드 'get'with Rspec

그러나 내 경우에는 주어진 솔루션 중 아무 것도 나를 위해 일하지 않았습니다!

나는 '/ RailsProject/스펙/컨트롤러'에서 내 RSpec에 코드를 가지고 있고 코드는 다음과 같습니다

:

require "../spec_helper" 
describe "ApiMobile", :type => :controller do 
    it "Log In" do 
     get 'apiMobile/v0/logIn/test' 
     expect(response).to be_success 
    end 
end 

당신은 내가 모든 지시를 따랐습니다하지만 난 여전히 문제가 볼 수 있듯이

1) ApiMobile Log In 
Failure/Error: get 'apiMobile/v0/logIn/test' 
NoMethodError: 
    undefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1:0x000000023b5ec8> 
# ./api_mobile_controller_spec.rb:6:in `block (2 levels) in <top (required)>' 
Finished in 0.00056 seconds 
1 example, 1 failure 

내가 누락되었거나 비슷합니까?

감사합니다.

+0

컨트롤러 방법을 기호로 지정한 후 사양 도우미 –

+0

에 'rspec/rails'가 있어야합니다. 사양을 정의하는 이상적인 방법은 https://www.relishapp.com/rspec/rspec-rails/docs/controller-specs를 참조하십시오. –

+0

새로운 오류가 발생하는 경우 : 'require': 이러한 파일 - 레일/rspec (LoadError) –

답변

0

필자는 마침내 무슨 일이 일어나고 있는지 발견했습니다. Peter Alfvin은 옳았습니다. 잘못은 isntallation이었습니다.

Gemfile 'gem rspec'에 추가했는데 명령 줄에 'bundle install'다음에 'rspec --init'을 입력했습니다. 하지만 필자도 'rspec-rails'를 추가하고 'rils generate rspec : install'을 입력해야했습니다.

이제 get 명령이 작동합니다 (다른 오류가 있지만 경로와 관련 있다고 생각합니다).

관련 문제