【发布时间】:2015-10-27 03:20:10
【问题描述】:
我正在从我的小网站编写规范,但遇到了一个小问题。
我有一些规范辅助方法,例如:
def is_logged_in?(spec = :feature)
if spec == :feature
page.has_selector?('#user-menu')
else
!session[:user_id].nil?
end
end
但是我厌倦了传递“spec”参数,我认为有更好的解决方案,比如:if current_spec.type == :feature ...。
有没有办法从辅助方法中了解当前运行规范的类型?
【问题讨论】:
标签: ruby-on-rails rspec tdd integration-testing bdd