【发布时间】:2014-12-28 23:05:41
【问题描述】:
我有一个位于app/views/shared/_card_instance.html.haml 的视图。以下规范通过:
spec/views/_card_instance.html.haml_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)>'
为什么? RSpec 不应该根据路径将规范标识为视图规范吗?
(RSpec 3.1;Rails 3.2;Windows)
【问题讨论】:
标签: ruby-on-rails rspec rspec3