Ruby on rails RSpec不';t自动确定视图等级库类型
我在Ruby on rails RSpec不';t自动确定视图等级库类型,ruby-on-rails,rspec,rspec3,Ruby On Rails,Rspec,Rspec3,我在app/views/shared/\u card\u instance.html.haml上有一个视图。以下规格通过: spec/views/\u card\u instance.html.haml\u spec.rb require 'spec_helper' describe 'card_instance partial', type: :view do it 'should just display the missing slot if present' do card
app/views/shared/\u card\u instance.html.haml
上有一个视图。以下规格通过:
spec/views/\u card\u instance.html.haml\u spec.rb
require 'spec_helper'
describe 'card_instance partial', type: :view do
it 'should just display the missing slot if present' do
card = double(:card, missing_slot: 'Rare')
render 'shared/card_instance', card: card
expect(rendered).to have_css('.card', text: 'Rare')
end
end
但是,如果我删除type::view
,它将失败:
Failures:
1) card_instance partial should just display the missing slot if present
Failure/Error: render 'shared/card_instance', card: card
NoMethodError:
undefined method `render' for #<RSpec::ExampleGroups::CardInstancePartial:0x5d02b50>
# ./spec/views/_card_instance.html.haml_spec.rb:6:in `block (2 levels) in <top (required)>'
故障:
1) 卡\u实例部分应仅显示丢失的插槽(如果存在)
失败/错误:呈现“共享/card_实例”,card:card
命名错误:
未定义的方法“render”#
#./spec/views/\u card\u instance.html.haml\u spec.rb:6:in'block(2层)in'
为什么??RSpec不应该根据其路径将等级库标识为视图等级库吗
(RSpec 3.1;Rails 3.2;Windows)我相信这种行为已经改变:
啊哈!这也解释了我在获得助手规范时遇到的问题。谢谢