this tutorial 다음 RoR을 배우려고합니다. 현재 3 장에 있습니다. 내가 한 줄씩 따라 가면이 튜토리얼은 잘 작동합니다. 그러나이 자습서에서 사용 된 명령은 기본 테스트 생성을 억제합니다. 내가 그들을 지키려고 노력하고 아마도 내 프로젝트에서 그들을 사용할 때, 나는 항상 어딘가에 벽에 부딪쳤다.Rspec과 Capybara를 사용하여 새로운 RoR 프로젝트 설정하기
내가 뭘 잘못하고 있는지 말해 주실 수 있습니까?
$ rails new myproject
$ cd myproject/
$ echo "gem 'rspec'" >> Gemfile
$ echo "gem 'rspec-rails'" >> Gemfile
$ echo "gem 'capybara'" >> Gemfile
$ bundle install
$ bundle --binstubs
$ rails generate rspec:install
$ rails generate controller StaticPages home help about
은 그 때 나는 카피 바라가 작동하는지 테스트하려면
spec/views/static_pages/home.html.erb_spec.rb
파일을 편집 :
이 시점에서
bin/rspec
을 실행
require 'spec_helper'
#require 'capybara'
#require 'capybara/rails'
#require 'capybara/rspec'
describe "static_pages/home.html.erb" do
it 'should have a right title' do
visit '/static_pages/home'
page.should have_selector('title', :text => 'Home')
end
end
은 분명히 실패로 끝납니다. 음, 실패가 예상되었을 수 있습니다. 이러한 실패에 대한 하나의 이유 비록 더 놀랍다 :
1) static_pages/home.html.erb should have a right title
Failure/Error: visit '/static_pages/home'
NoMethodError:
undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_5:0x00000003dfd268>
# ./spec/views/static_pages/home.html.erb_spec.rb:7:in `block (2 levels) in <top (required)>'
AFAIK가 카피 바라의 일부인 visit
방법은 발견되지 않았다. home.html.erb_spec.rb
에있는 세 개의 추가 요구 사항에서 주석 처리를 제거해도 결과에는 아무 것도 변경되지 않습니다.
내가 잘못하고있는 아이디어가 있습니까? 아니면 내가 더 잘해야 할까?
레일 버전 : 3.2.6
'require capybara '를 spec_helper 파일로 옮기면 어떻게됩니까? – ScottJShea
@ScottJShea 같은, 나는 두려워. – kamilk