David Chelimsky wrote in post #985199:
> On Mar 3, 2011, at 1:36 AM, Jiang Guimin wrote:
>>   end
>>      controller.should_receive(:save_u_and_node).with(table,
>>
>> When I run the test, unfortunately rspec told me that "controller"  is
>> nil, I got a fail test.
>> So, I want to konw how to get the correct "controller" object.
>
> Please run it again with the --backtrace flag and post the output.



Ok, I run it again then rspec told me so mush, and I noted the message
 "An expectation of :save_u_and_node was set on nil", is it said that
controller is nil?
Why rspec can't get controller in requests test for this spec?

No DRb server is running. Running in local process instead ...
..An expectation of :save_u_and_node was set on nil. Called from
/home/yang/workspace/trunk/ent_os/spec/requests/workflows/dynamic_flows_spec.rb:57:in
`block (3 levels) in <top (required)>'. Use
allow_message_expectations_on_nil to disable warnings.
F

Failures:

  1) 运行报表 save attachment should be successful
     Failure/Error: click_button "提交"
     NoMethodError:
       You have a nil object when you didn't expect it!
       You might have expected an instance of Array.
       The error occurred while evaluating nil.each
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in
`transaction'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:204:in
`transaction'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_controller/metal/implicit_render.rb:4:in
`send_action'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:151:in
`process_action'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_controller/metal/rendering.rb:11:in
`process_action'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/abstract_controller/callbacks.rb:18:in
`block in process_action'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:435:in
`_run__33140632__process_action__340421511__callbacks'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:409:in
`_run_process_action_callbacks'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:93:in
`run_callbacks'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/abstract_controller/callbacks.rb:17:in
`process_action'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:30:in
`block in process_action'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in
`block in instrument'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21:in
`instrument'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in
`instrument'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:29:in
`process_action'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_controller/metal/rescue.rb:17:in
`process_action'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:120:in
`process'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:40:in
`process'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_controller/metal.rb:138:in
`dispatch'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_controller/metal/rack_delegation.rb:14:in
`dispatch'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_controller/metal.rb:178:in
`block in action'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:62:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:62:in
`dispatch'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:27:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-mount-0.6.13/lib/rack/mount/route_set.rb:148:in
`block in call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:93:in
`block in recognize'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:89:in
`optimized_each'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:92:in
`recognize'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-mount-0.6.13/lib/rack/mount/route_set.rb:139:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:492:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/best_standards_support.rb:17:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/head.rb:14:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/methodoverride.rb:24:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/params_parser.rb:21:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/flash.rb:182:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/session/abstract_store.rb:149:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/cookies.rb:295:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:32:in
`block in call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:28:in
`cache'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:12:in
`cache'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:31:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/callbacks.rb:46:in
`block in call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:415:in
`_run_call_callbacks'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/callbacks.rb:44:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/sendfile.rb:107:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/remote_ip.rb:48:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/rack/logger.rb:13:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/runtime.rb:17:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/cache/strategy/local_cache.rb:72:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/lock.rb:11:in
`block in call'
     # <internal:prelude>:10:in `synchronize'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/lock.rb:11:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/static.rb:30:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/application.rb:168:in
`call'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-test-0.5.6/lib/rack/mock_session.rb:30:in
`request'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-test-0.5.6/lib/rack/test.rb:209:in
`process_request'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rack-test-0.5.6/lib/rack/test.rb:66:in
`post'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/webrat-0.7.3/lib/webrat/core/session.rb:278:in
`process_request'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/webrat-0.7.3/lib/webrat/core/session.rb:119:in
`request_page'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/webrat-0.7.3/lib/webrat/core/elements/form.rb:20:in
`submit'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/webrat-0.7.3/lib/webrat/core/elements/field.rb:193:in
`click'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/webrat-0.7.3/lib/webrat/core/scope.rb:291:in
`click_button'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/webrat-0.7.3/lib/webrat/core/methods.rb:7:in
`click_button'
     # ./spec/requests/workflows/dynamic_flows_spec.rb:62:in `block (3
levels) in <top (required)>'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/hooks.rb:29:in
`instance_eval'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/hooks.rb:29:in
`run_in'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/hooks.rb:60:in
`block in run_all'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/hooks.rb:60:in
`each'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/hooks.rb:60:in
`run_all'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/hooks.rb:106:in
`run_hook'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:190:in
`block in eval_before_eachs'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:190:in
`each'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:190:in
`eval_before_eachs'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example.rb:136:in
`run_before_each'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example.rb:48:in
`block (2 levels) in run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example.rb:98:in
`with_around_hooks'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example.rb:46:in
`block in run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example.rb:91:in
`block in with_pending_capture'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example.rb:90:in
`catch'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example.rb:90:in
`with_pending_capture'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example.rb:45:in
`run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:261:in
`block in run_examples'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:257:in
`map'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:257:in
`run_examples'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:231:in
`run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:232:in
`block in run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:232:in
`map'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/example_group.rb:232:in
`run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:27:in
`block (2 levels) in run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:27:in
`map'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:27:in
`block in run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/reporter.rb:12:in
`report'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:24:in
`run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in
`run_in_process'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:44:in
`run'
     #
/home/yang/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in
`block in autorun'

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to