> Yeah has anyone figured this out? I cannot test my namespace
> controllers.
> On Mar 30, 4:47 am, MRoderick <roderick.mor...@gmail.com> wrote:
>> I am having some trouble getting should_be_restful to work for
>> namespaced controllers (admin controllers), Shoulda 4.0.1, Rails
>> 2.0.2.
>> As far as I can tell, James Golicks patch fromhttp://groups.google.com/group/shoulda/browse_thread/thread/de802b1c7
>> ...
>> never got implemented in Shoulda.
>> I've tried handpatching Shoulda 4.0.1, but am still getting the exact
>> same errors .... it's probably just me, as I am still struggling with
>> testing.
>> Here's the error I get for my show action for
>> Admin::ProductsController
>> ruby test/functional/admin/products_controller_test.rb
>> Loaded suite test/functional/admin/products_controller_test
>> Started
>> ....F.FF
>> Finished in 0.540747 seconds.
>> 1) Failure:
>> test: Admin users on GET to :show should assign @product.
>> (Admin::ProductsControllerTest)
>> [/Users/morgan/mysecretsite/vendor/plugins/shoulda/lib/shoulda/
>> controller_tests/controller_tests.rb:344
>> /Users/morgan/mysecretsite/vendor/plugins/shoulda/lib/shoulda/
>> gem/
>> shoulda.rb:190
>> /Users/morgan/mysecretsite/vendor/plugins/shoulda/lib/shoulda/
>> gem/
>> shoulda.rb:190
>> test/functional/admin/products_controller_test.rb:14]:
>> The action isn't assigning to @product.
>> <nil> is not true.
>> 2) Failure:
>> test: Admin users on GET to :show should render 'show' template.
>> (Admin::ProductsControllerTest)
>> [/Users/morgan/mysecretsite/vendor/plugins/shoulda/lib/shoulda/
>> controller_tests/controller_tests.rb:375
>> /Users/morgan/mysecretsite/vendor/plugins/shoulda/lib/shoulda/
>> gem/
>> shoulda.rb:190
>> /Users/morgan/mysecretsite/vendor/plugins/shoulda/lib/shoulda/
>> gem/
>> shoulda.rb:190
>> test/functional/admin/products_controller_test.rb:14]:
>> expecting <"show"> but rendering with <"diagnostics.erb">
>> 3) Failure:
>> test: Admin users on GET to :show should respond with success.
>> (Admin::ProductsControllerTest)
>> [/Users/morgan/mysecretsite/vendor/plugins/shoulda/lib/shoulda/
>> controller_tests/controller_tests.rb:365
>> /Users/morgan/mysecretsite/vendor/plugins/shoulda/lib/shoulda/
>> gem/
>> shoulda.rb:190
>> /Users/morgan/mysecretsite/vendor/plugins/shoulda/lib/shoulda/
>> gem/
>> shoulda.rb:190
>> test/functional/admin/products_controller_test.rb:14]:
>> Expected response to be a <:success>, but was <404>
>> 8 tests, 16 assertions, 3 failures, 0 errors
>> The fact that I get 404 and diagnostics.erb, tells me that the
>> request
>> to show is probably going to an undefined route, or is going to the
>> public routes, which are very different.
>> For the index action, everything seems to be working just fine.
>> Now, there's nothing really interesting in the show action:
>> def show
>> @product = Product.find(params[:id])
>> respond_to do |format|
>> format.html # show.html.erb
>> format.xml { render :xml => @product }
>> end
>> end
>> For completeness, here's my test:
>> require File.dirname(__FILE__) + '/../../test_helper'
>> class Admin::ProductsControllerTest < Test::Unit::TestCase
>> fixtures :categories, :products
>> def setup
>> @controller = Admin::ProductsController.new
>> @request = ActionController::TestRequest.new
>> @response = ActionController::TestResponse.new
>> @product = Product.find(:first)
>> end
>> context "Admin users" do
>> should_be_restful do |resource|
>> setup do
>> login
>> end
>> resource.klass = Product
>> resource.actions = [:index, :show]
>> # :new, :edit, :update, :create, :destroy]
>> resource.formats = [:html]
>> resource.create.params = {
>> :name => "my first product",
>> :description => "my first
>> description",
>> :price => 100.76,
>> :category_id => 1,
>> }
>> resource.update.params = {
>> :name => "updated product name",
>> :description => "my second
>> description",
>> :price => 1234.56,
>> :category_id => 1
>> }
>> resource.create.redirect =
>> "admin_product_url( @product )"
>> resource.update.redirect =
>> "admin_product_url( @product )"
>> resource.destroy.redirect =
>> "admin_products_url"
>> resource.create.flash = /created/i
>> resource.update.flash = /updated/i
>> resource.destroy.flash = nil
>> end
>> end
>> end
>> Is Shoulda 4.0.1 supposed to be able to handle namespaced
>> controllers?