inherited_resources, remarkable: Stub "errors" received unexpected message :empty? with (no args)

165 views
Skip to first unread message

stephen

unread,
Jan 9, 2010, 10:10:53 AM1/9/10
to Remarkable
Hello,
when using inherited_resources and remarkable.

I try this spec:

###

require 'spec_helper'

describe Admin::SectionsController do
integrate_views
mock_model :section

describe :post => :create, :section => {'some' => 'params'} do
expects :new, :on => Section, :with => { 'some' =>
'params' } , :returns => section_proc

describe "with successful save" do
expects :save, :on => section_proc, :returns => true
should_assign_to :section, :with => section_proc
should_redirect_to { admin_sections_url }
end

end

end

####

It gives me the attached error when using an inherited resources
class:

###

class Admin::SectionsController < InheritedResources::Base
respond_to :html

def create
create!{ collection_path }
end

end

###

If I completely rewrite the create method the good old controller way.
My specs pass ...

###
class Admin::SectionsController < ActionController:Base

def create
@section = Section.new(params[:section])

respond_to do |wants|
if @section.save
flash[:notice] = 'Section was successfully created.'
wants.html { redirect_to(admin_sections_url) }
else
wants.html { render :action => "new" }
end
end
end

end

####

Is there something I might be missing?

Thanks, Stephen


################### Error Output ###################

Spec::Mocks::MockExpectationError in 'Admin::SectionsController
responding to #POST create with successful save should assign section'
Stub "errors" received unexpected message :empty? with (no args)
/Library/Ruby/Gems/1.8/gems/inherited_resources-1.0.1/lib/
inherited_resources/legacy/responder.rb:210:in `has_errors?'
/Library/Ruby/Gems/1.8/gems/inherited_resources-1.0.1/lib/
inherited_resources/legacy/responder.rb:146:in `navigation_behavior'
/Library/Ruby/Gems/1.8/gems/inherited_resources-1.0.1/lib/
inherited_resources/legacy/responder.rb:126:in `to_html'
/Library/Ruby/Gems/1.8/gems/responders-0.4.2/lib/responders/
flash_responder.rb:89:in `to_html'
/Library/Ruby/Gems/1.8/gems/inherited_resources-1.0.1/lib/
inherited_resources/legacy/responder.rb:117:in `send'
/Library/Ruby/Gems/1.8/gems/inherited_resources-1.0.1/lib/
inherited_resources/legacy/responder.rb:117:in `respond'
/Library/Ruby/Gems/1.8/gems/inherited_resources-1.0.1/lib/
inherited_resources/legacy/responder.rb:110:in `call'
/Library/Ruby/Gems/1.8/gems/inherited_resources-1.0.1/lib/
inherited_resources/legacy/respond_to.rb:67:in `respond_with'
/Library/Ruby/Gems/1.8/gems/inherited_resources-1.0.1/lib/
inherited_resources/base_helpers.rb:250:in `respond_with_dual_blocks'
/Library/Ruby/Gems/1.8/gems/inherited_resources-1.0.1/lib/
inherited_resources/actions.rb:37:in `create!'
/Users/stephen/Sites/swank/app/controllers/admin/
sections_controller.rb:5:in `create'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:1331:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:1331:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:617:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:610:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
rescue.rb:160:in `perform_action_without_flash'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
flash.rb:146:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:532:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:532:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:606:in `sass_old_process'
/Library/Ruby/Gems/1.8/gems/haml-2.2.12/rails/../lib/sass/plugin/
rails.rb:19:in `process_without_compass'
/Library/Ruby/Gems/1.8/gems/chriseppstein-compass-0.8.17/lib/compass/
app_integration/rails/action_controller.rb:7:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
test_process.rb:567:in `process_with_test'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
test_process.rb:447:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
test_process.rb:403:in `post'
/Library/Ruby/Gems/1.8/gems/remarkable_rails-3.1.11/lib/
remarkable_rails/action_controller/macro_stubs.rb:552:in `send'
/Library/Ruby/Gems/1.8/gems/remarkable_rails-3.1.11/lib/
remarkable_rails/action_controller/macro_stubs.rb:552:in `run_action!'
/Library/Ruby/Gems/1.8/gems/remarkable_rails-3.1.11/lib/
remarkable_rails/action_controller/base.rb:16:in `send'
/Library/Ruby/Gems/1.8/gems/remarkable_rails-3.1.11/lib/
remarkable_rails/action_controller/base.rb:16:in
`perform_action_with_macro_stubs'
/Library/Ruby/Gems/1.8/gems/remarkable-3.1.11/lib/remarkable/dsl/
callbacks.rb:65:in `send'
/Library/Ruby/Gems/1.8/gems/remarkable-3.1.11/lib/remarkable/dsl/
callbacks.rb:65:in `run_before_assert_callbacks'
/Library/Ruby/Gems/1.8/gems/remarkable-3.1.11/lib/remarkable/dsl/
callbacks.rb:61:in `each'
/Library/Ruby/Gems/1.8/gems/remarkable-3.1.11/lib/remarkable/dsl/
callbacks.rb:61:in `run_before_assert_callbacks'
/Library/Ruby/Gems/1.8/gems/remarkable-3.1.11/lib/remarkable/dsl/
assertions.rb:283:in `matches?'
/Library/Ruby/Gems/1.8/gems/remarkable-3.1.11/lib/remarkable/macros.rb:
28:in `send'
/Library/Ruby/Gems/1.8/gems/remarkable-3.1.11/lib/remarkable/macros.rb:
28:in `should_or_should_not_method_missing'
./spec/controllers/admin/sections_controller_spec.rb:12:
/Library/Ruby/Gems/1.8/gems/remarkable_rails-3.1.11/lib/
remarkable_rails/action_controller/macro_stubs.rb:390:in `describe'
./spec/controllers/admin/sections_controller_spec.rb:10:
/Library/Ruby/Gems/1.8/gems/remarkable_rails-3.1.11/lib/
remarkable_rails/action_controller/macro_stubs.rb:400:in
`instance_eval'
/Library/Ruby/Gems/1.8/gems/remarkable_rails-3.1.11/lib/
remarkable_rails/action_controller/macro_stubs.rb:400:in `describe'
/Library/Ruby/Gems/1.8/gems/remarkable_rails-3.1.11/lib/
remarkable_rails/action_controller/macro_stubs.rb:398:in `describe'
./spec/controllers/admin/sections_controller_spec.rb:7:
/Library/Ruby/Gems/1.8/gems/remarkable_rails-3.1.11/lib/
remarkable_rails/action_controller/macro_stubs.rb:390:in `describe'
./spec/controllers/admin/sections_controller_spec.rb:3:

José Valim

unread,
Jan 9, 2010, 10:56:17 AM1/9/10
to remarka...@googlegroups.com
This is rspec bug. Previously it was compatible with Inherited Resources with integrate_views, but not anymore.

However, it's kind odd to write tests for your controllers while they have less than 10 lines and they it's all tested in Inherited Resources test suite.

You should simply use integration specs to ensure it redirects to the proper place.

--
You received this message because you are subscribed to the Google Groups "Remarkable" group.
To post to this group, send email to remarka...@googlegroups.com.
To unsubscribe from this group, send email to remarkable-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/remarkable-core?hl=en.






--
José Valim

Director of Engineering - Plataforma Tecnologia
Know more about us: http://plataformatec.com.br/en/

Stephen Lumenta

unread,
Jan 9, 2010, 11:25:03 AM1/9/10
to remarka...@googlegroups.com
This is not a real life example - I'm not to keen on over-testing either. I was just struggling the whole day with remarkable or (rspec/inherited resources for that matter) and did some experiments:

* my innocent integration spec checking for the redirect kept on failing - after using "integrate_views true" it was working for me.

* then i went on to check if everything else in remarkable_rails works as expected, so I know I can rely on the tools if my code should get longer than 10 lines. My previous question is the result of that.

Thanks for the clarification anyways.

José Valim

unread,
Jan 9, 2010, 11:37:46 AM1/9/10
to remarka...@googlegroups.com
So it means that Rspec + Inherited Resources works, but when using Rspec + Remarkable Rails + Inherited Resources it does not?

--
You received this message because you are subscribed to the Google Groups "Remarkable" group.
To post to this group, send email to remarka...@googlegroups.com.
To unsubscribe from this group, send email to remarkable-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/remarkable-core?hl=en.



Stephen Lumenta

unread,
Jan 9, 2010, 11:50:02 AM1/9/10
to remarka...@googlegroups.com
No. It works as expected when not using inherited_resources. Sorry if my previous comment was misleading.
Reply all
Reply to author
Forward
0 new messages