假设我在application_helper.rb中有以下代码:
def do_something
if action_name == 'index'
'do'
else
'dont'
end
end
Run Code Online (Sandbox Code Playgroud)
如果在索引操作中调用,它将执行某些操作.
问:如何在application_helper_spec.rb中重写辅助规范以模拟来自'index'动作的调用?
describe 'when called from "index" action' do
it 'should do' do
helper.do_something.should == 'do' # will always return 'dont'
end
end
describe 'when called from "other" action' do
it 'should do' do
helper.do_something.should == 'dont'
end
end
Run Code Online (Sandbox Code Playgroud) 为此搜索了stackoverflow并找不到答案
来自Ruby On Rails和Rspec,我需要一个像rspec这样的工具(更容易过渡).通过PEAR安装并试图运行它但是它还没有工作(还)
只是想问周围是否有人使用它有同样的问题,因为它根本没有运行
尝试使用手册中的示例运行它 - http://dev.phpspec.org/manual/en/before.writing.code.specify.its.required.behaviour.html
phpspec NewFileSystemLoggerSpec
Run Code Online (Sandbox Code Playgroud)
没有回报
甚至跑步
phpspec some_dummy_value
Run Code Online (Sandbox Code Playgroud)
没有回报