여기 약간 혼란 스럽습니다. 나는 TDD를하려고 노력 중이며 문제를 겪고있다. RSpec에 나에게 말하고 다음과 같은 -Rspec-nameError : 정의되지 않은 로컬 변수 또는 메서드`sammiches_path '
1) Sammiches GET /sammiches display some sammiches
Failure/Error: visit sammiches_path
NameError:
undefined local variable or method `sammiches_path' for #<RSpec::Core::ExampleGroup::Nested_4::Nested_1:0x007fa7afcfed70>
# ./spec/requests/sammiches_spec.rb:7:in `block (3 levels) in <top (required)>'
2) Sammiches GET /sammiches creates a new sammich
Failure/Error: visit sammiches_path
NameError:
undefined local variable or method `sammiches_path' for #<RSpec::Core::ExampleGroup::Nested_4::Nested_1:0x007fa7ae11e6f0>
# ./spec/requests/sammiches_spec.rb:12:in `block (3 levels) in <top (required)>'
내 경로가
require 'spec_helper'
describe "Sammiches" do
describe "GET /sammiches" do
it "display some sammiches" do
@sammich = Sammich.create :name => 'bacon'
visit sammiches_path
page.should have_content 'bacon'
end
it "creates a new sammich" do
visit sammiches_path
fill_in 'Sammich', :with => 'lechuga'
click_button 'add Sammich'
current_path.should = root_path
page.should have_content 'lechuga'
save_and_open_page
end
end
end
처럼이 내 사양 파일이 모습입니다 -
sammiches_index GET /sammiches/index(.:format) sammiches#index
Sammiches GET /Sammiches(.:format) Sammiches#index
POST /Sammiches(.:format) Sammiches#create
new_Sammich GET /Sammiches/new(.:format) Sammiches#new
edit_Sammich GET /Sammiches/:id/edit(.:format) Sammiches#edit
Sammich GET /Sammiches/:id(.:format) Sammiches#show
PUT /Sammiches/:id(.:format) Sammiches#update
DELETE /Sammiches/:id(.:format) Sammiches#destroy
root / Sammiches#index
Routes-
Sammiches::Application.routes.draw do
get "Sammiches/index"
resources :sammiches
root :to => 'Sammiches#index'
새로운 오류 -
1) Sammiches GET /sammiches creates a new sammich
Failure/Error: visit sammiches_path
ActionView::Template::Error:
undefined method `sammich' for #<Sammich:0x007fd0007d2f80>
# ./app/views/sammiches/index.html.erb:4:in `block in _app_views_sammiches_index_html_erb___2703584807867277870_70265660050820'
# ./app/views/sammiches/index.html.erb:2:in `_app_views_sammiches_index_html_erb___2703584807867277870_70265660050820'
# ./spec/requests/sammiches_spec.rb:12:in `block (3 levels) in <top (required)>'
2) Sammiches GET /sammiches display some sammiches
Failure/Error: visit sammiches_path
ActionView::Template::Error:
undefined method `sammich' for #<Sammich:0x007fd00006f4f0>
# ./app/views/sammiches/index.html.erb:4:in `block in _app_views_sammiches_index_html_erb___2703584807867277870_70265660050820'
# ./app/views/sammiches/index.html.erb:2:in `_app_views_sammiches_index_html_erb___2703584807867277870_70265660050820'
# ./spec/requests/sammiches_spec.rb:7:in `block (3 levels) in <top (required)>'
나는 약간의 손실이 있습니다. 모든 조언을 크게 주시면 감사하겠습니다.
감사합니다.
, 당신은 Sammich''에 대한 총액 불일치가있을 수 있습니다; routes.rb 파일의 내용은 무엇입니까? – rossta
내 경로 파일을 추가했습니다. 리소스 대소 문자를 변경했지만 지금은 새로운 오류가 발생합니다 ... 감사합니다! – DynastySS
새로운 오류는 app/views/sammiches/index.html.erb의 4 행에 있습니다. 정의되지 않은 변수/메소드'sammich'를 사용하려고합니다. – rossta