통합 테스트에서 RSpec에 (내가 하드 코드 값이없는 것을 알고)에서 다음호출 내가 할 노력하고있어
get '/api/get-other-items?id=5109'
내가 찾을 수있는 가장 가까운이었다 : call a specific url with rspec하지만 단 하나의 항목 만 선택합니다. 내가
undefined local variable or method `get_other_items' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f938fd65590>
얻을 수 있지만 경로가 존재 내가
get get_other_items, :id => '5109' q
로 실행하면
get :controller => 'api', :action => 'get-other-items', :id => '5109'
get 'api/get-other-items', :id => '5109'
이 나에게 bad argument(expected URI object or URI string)
을주고있다 :
나는 다음과 같은 시도Mon Jan 23$ rake routes | grep get_other_items
get_other_items /api/get-other-items(.:format) {:controller=>"api", :action=>"get_other_items"}
어떻게하면 간단하게 수행 할 수 있습니까?
들으
대답 한 의견에 대한 업데이 트 여기에 문제의 RSpec에 코드입니다 :
it "testing getting other items for menu item" do
get get_other_items_path(:id => '5109')
JSON.parse(response.body)
puts response.body
월 1월 23일 $ RSpec에 요청/get_other_items_spec.rb
F
Failures:
1) GetOtherItems testing getting other items for menu item
Failure/Error: JSON.parse(response.body)
JSON::ParserError:
743: unexpected token at 'this is not found '
# ./requests/get_other_items_spec.rb:19:in `block (2 levels) in <top (required)>'
Finished in 13.57 seconds
1 example, 1 failure
Failed examples:
thx하지만 여전히 오류가 발생하는 것은 내 404가 다시 돌아올 때 라우터에서 선택되지 않는 것 같습니다.'사용'할 라우트를 출력하는 방법이 있습니까 (즉, http 호출을하지 않는 것). – timpone
routes.rb 콘텐츠를 게시 할 수 있습니까? – eugen
thx -이 문제는 분명히 나와 일치합니다 : 'match'/ api/get-other-items '=>'api # get_other_items ', : as => : get_other_items' – timpone