gpt4 book ai didi

ruby-on-rails - #
转载 作者:数据小太阳 更新时间:2023-10-29 08:33:21 25 4
gpt4 key购买 nike

我确定这在 stackoverflow 上的某个地方得到了回答,但就我的生活而言,我找不到为什么我的情况与已经写过的不同所以这里去。

使用带 capybara 的 rspec

  1) report_cards#index must have 'Report Cards Index'
Failure/Error: visit '/'
NoMethodError:
undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_4:0x007fcc3aa33960>
# ./spec/views/report_cards_view_spec.rb:7:in `block (2 levels) in <top (required)>'

/spec/views/report_cards_view_spec.rb 看起来像

require 'spec_helper'
describe "report_cards#index" do
it "must have 'Report Cards Index'" do
visit '/'
page.should have_content("something")
end
end

spec_helper.rb 的顶行看起来像

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'

gemfile 看起来像

`source 'https://rubygems.org'`
gem 'rails', '3.2.7'
gem 'jquery-rails'
gem 'pg', '~> 0.14.0'
gem 'devise', '~> 2.1.2'
gem "quiet_assets", "~> 1.0.1"
gem 'thin'
gem 'bourbon'
gem "haml-rails"
gem "httparty", "~> 0.8.3"
gem "activerecord-import", "~> 0.2.10"

group :test, :development do
gem "rspec-rails", "~> 2.0"
gem 'capybara', '~>1.1.2'
gem "fabrication", "~> 2.2.0"
gem "launchy", "~> 2.1.2"
end

group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end`

我还很初级,所以放轻松 :) - 谢谢!

最佳答案

capybara 不包含在 View 规范中,它用于集成测试。

尝试将您的规范文件移动到 spec/requests 目录中

关于ruby-on-rails - #<RSpec 的未定义方法 `visit',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12190159/

25 4 0

Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com