如何使用 rspec 测试 (Bean)Stalker?
我有这个名为 jobs.rb 的文件
require File.expand_path("../environment", __FILE__)
job "do.stuff" do |args|
$value = 10
end
然后我有这个名为 jobs_spec.rb 的规范文件
require File.expand_path("../../spec_helper", __FILE__)
describe "some beanstalk jobs" do
it "should work" do
# What to do here?
$value.should eq(10)
end
end
如何测试 $value
变量?
I've this file called jobs.rb
require File.expand_path("../environment", __FILE__)
job "do.stuff" do |args|
$value = 10
end
Then I've this spec file called jobs_spec.rb
require File.expand_path("../../spec_helper", __FILE__)
describe "some beanstalk jobs" do
it "should work" do
# What to do here?
$value.should eq(10)
end
end
How do I test the $value
variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在运行测试的机器上运行 beanstalkd。
You have to run beanstalkd on the machine you are running the test on.
我会检查库本身如何运行它的测试:
https:// github.com/adamwiggins/stalker/blob/master/test/stalker_test.rb
请记住,这是使用 Test::Unit,但是您可以在 Rspec 中应用相同的技术。
I'd check out how the library itself runs it's test:
https://github.com/adamwiggins/stalker/blob/master/test/stalker_test.rb
Keep in mind that this is using Test::Unit, however you can apply the same techniques in Rspec.