使用 RSpec2 和 Rails3.0.4,如何从 XML 测试像 admin_controller.rb 这样的通用控制器
这是什么问题
我想测试一个 before 过滤器,如果失败,它会在 XML 和 JSON 中呈现错误, 。 当从经典控制器测试它时,它工作得很好,当从 ApplicationController 直接失败。
代码的精简版
specs/controller/admin_controller_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminController do
controller(AdminController) do
def index
render :text => 'ok'
end
end
it "should include errors properly formated" do
get :index, :format => 'xml'
response.body.should == "block"
end
end
app/controller/admin_controller.rb
class AdminController < ApplicationController
before_filter :block_something
protected
def block_something
respond_to do |wants|
wants.xml {
render :text => 'block'
}
end
end
end
测试错误
Failure/Error: get :index, :format => format
TypeError:
can't convert nil into String
更新,其中backtrace :感谢 Ryan Bigg 的推荐
它提供了与上面示例不同的控制器和过滤器名称。该应用程序使用 admin_controller.rb 和 block_suspended 过滤器。
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:61:in `<<'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:61:in `build_path'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:54:in `find_templates'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:20:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:39:in `cached'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:19:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:21:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `each'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:21:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `each'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:28:in `exists?'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/lookup_context.rb:90:in `template_exists?'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/view_paths.rb:11:in `__send__'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/view_paths.rb:11:in `template_exists?'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:272:in `_layout'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:345:in `_default_layout'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:323:in `_layout_for_option'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:290:in `_normalize_options'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/rendering.rb:41:in `_normalize_options'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/compatibility.rb:50:in `_normalize_options'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/rendering.rb:101:in `render_to_string'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/rendering.rb:93:in `render'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/rendering.rb:17:in `render'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/core_ext/benchmark.rb:5:in `ms'
# /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/core_ext/benchmark.rb:5:in `ms'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
# /Library/Ruby/Gems/1.8/gems/activerecord-3.0.4/lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:39:in `render_without_wicked_pdf'
# ./app/controllers/admin_controller.rb:36:in `block_suspended'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/mime_responds.rb:192:in `call'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/mime_responds.rb:192:in `respond_to'
# ./app/controllers/admin_controller.rb:33:in `block_suspended'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:466:in `_run__1727617933__process_action__199225275__callbacks'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:409:in `send'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:93:in `send'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:93:in `run_callbacks'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/callbacks.rb:17:in `process_action'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications.rb:52:in `instrument'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications.rb:52:in `instrument'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/rescue.rb:17:in `process_action'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/base.rb:119:in `process'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/rendering.rb:41:in `process'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/test_case.rb:412:in `process'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/test_case.rb:47:in `process'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/test_case.rb:350:in `get'
# ./spec/controllers/admin_controller_spec.rb:272
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:29:in `instance_eval'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:29:in `run_in'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:64:in `run_all'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:64:in `each'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:64:in `run_all'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:110:in `run_hook'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:191:in `eval_before_eachs'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:191:in `each'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:191:in `eval_before_eachs'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:144:in `run_before_each'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:48:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:106:in `with_around_hooks'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:46:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:99:in `with_pending_capture'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:98:in `catch'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:98:in `with_pending_capture'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:45:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:262:in `run_examples'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:258:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:258:in `run_examples'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:232:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:27:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:27:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:27:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/reporter.rb:12:in `report'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:24:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in `run_in_process'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in `autorun'
# /usr/bin/rspec:19
有想过为什么要附加这个吗?如果不是正确的测试方法,如何测试这种行为?
What's the problem
I wanna test a before filter that render errors in XML and JSON if failing.
When testing it from a classic controller it works fine, when testing from
the ApplicationController directly it fails.
A light version of the code
specs/controller/admin_controller_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminController do
controller(AdminController) do
def index
render :text => 'ok'
end
end
it "should include errors properly formated" do
get :index, :format => 'xml'
response.body.should == "block"
end
end
app/controller/admin_controller.rb
class AdminController < ApplicationController
before_filter :block_something
protected
def block_something
respond_to do |wants|
wants.xml {
render :text => 'block'
}
end
end
end
Error from tests
Failure/Error: get :index, :format => format
TypeError:
can't convert nil into String
Update, with backtrace : thanks Ryan Bigg for the recommendation
It gives different controller and filter names than the example above. The app use admin_controller.rb and block_suspended filter.
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:61:in `<<'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:61:in `build_path'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:54:in `find_templates'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:20:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:39:in `cached'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:19:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:21:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `each'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:21:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `each'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `find_all'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:28:in `exists?'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/lookup_context.rb:90:in `template_exists?'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/view_paths.rb:11:in `__send__'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/view_paths.rb:11:in `template_exists?'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:272:in `_layout'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:345:in `_default_layout'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:323:in `_layout_for_option'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:290:in `_normalize_options'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/rendering.rb:41:in `_normalize_options'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/compatibility.rb:50:in `_normalize_options'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/rendering.rb:101:in `render_to_string'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/rendering.rb:93:in `render'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/rendering.rb:17:in `render'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/core_ext/benchmark.rb:5:in `ms'
# /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/core_ext/benchmark.rb:5:in `ms'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
# /Library/Ruby/Gems/1.8/gems/activerecord-3.0.4/lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:39:in `render_without_wicked_pdf'
# ./app/controllers/admin_controller.rb:36:in `block_suspended'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/mime_responds.rb:192:in `call'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/mime_responds.rb:192:in `respond_to'
# ./app/controllers/admin_controller.rb:33:in `block_suspended'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:466:in `_run__1727617933__process_action__199225275__callbacks'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:409:in `send'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:93:in `send'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:93:in `run_callbacks'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/callbacks.rb:17:in `process_action'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications.rb:52:in `instrument'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
# /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications.rb:52:in `instrument'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/rescue.rb:17:in `process_action'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/base.rb:119:in `process'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/rendering.rb:41:in `process'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/test_case.rb:412:in `process'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/test_case.rb:47:in `process'
# /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/test_case.rb:350:in `get'
# ./spec/controllers/admin_controller_spec.rb:272
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:29:in `instance_eval'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:29:in `run_in'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:64:in `run_all'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:64:in `each'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:64:in `run_all'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:110:in `run_hook'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:191:in `eval_before_eachs'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:191:in `each'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:191:in `eval_before_eachs'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:144:in `run_before_each'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:48:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:106:in `with_around_hooks'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:46:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:99:in `with_pending_capture'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:98:in `catch'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:98:in `with_pending_capture'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:45:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:262:in `run_examples'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:258:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:258:in `run_examples'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:232:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:27:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:27:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:27:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/reporter.rb:12:in `report'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:24:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in `run_in_process'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in `autorun'
# /usr/bin/rspec:19
Any thought on why this appends? If not the right way to test it, how to test such behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我现在已升级到 ruby 1.9.2,所有规格均通过,无需任何更改。
看起来像是 Ruby 1.8.7 的限制,需要额外的解决方法。
I've now upgraded to ruby 1.9.2 and all specs passes without any changes required.
Looks like a limitation of Ruby 1.8.7 that would need extra workarounds.