【发布时间】:2012-02-10 09:19:00
【问题描述】:
我的 java web 应用程序在 http://localhost:8080/tomcat 上运行
编写我的第一个规范,home_spec:
require 'spec_helper'
describe "home" do
it "should render the home page" do
visit "/"
page.should have_content("hello world")
end
end
并运行:
rspec
我明白了:
F
Failures:
1) home should render the home page
Failure/Error: visit "/"
NoMethodError:
undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1:0x242870b7>
# ./spec/home/home_spec.rb:7:in `(root)'
Finished in 0.012 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/home/home_spec.rb:6 # home should render the home page
不应该因为我在 spec_helper 中包含 capybara 而工作吗?
它如何知道访问正确的 url?如果我的 url 是 localhost:3030 或 localhost:8080 怎么办?
我的宝石文件:
source 'http://rubygems.org'
gem "activerecord"
gem "rspec"
gem "capybara"
gem "activerecord-jdbcmysql-adapter"
我的 spec_helper:
require 'capybara/rspec'
【问题讨论】:
标签: ruby-on-rails rspec jruby