Skip to content
This repository

Writing tests for inherited controllers #224

Closed
bricker opened this Issue August 28, 2012 · 7 comments

3 participants

Bryan Ricker Matt Wynne Col
Bryan Ricker

I have some basic inheritance for some controllers, and everything works as expected except the create method is simply not found by cucumber.

class BaseController < ApplicationController
  def index
    # ...
  end

  def edit
    #...
  end

  def create
    # ...
  end

  # And all of the other CRUD methods
end
class PostsController < BaseController
end
PostsController.instance_methods.include? :create # true

# Test object creation with Cucumber:
### Error: "The action 'create' could not be found
### for PostsController (AbstractController::ActionNotFound)"

To get around it, I am able to do:

class PostsController < BaseController
  def create; super; end
end

But this is obviously not ideal. To be clear: The inheritance of edit, update, delete, etc. all work fine. There is just something special about create that causes problems, but I am not sure what it is.

  • cucumber 1.2.1
  • cucumber-rails 1.3.0
  • rails 3.2.7
Matt Wynne
Owner

Please use this issue tracker for bugs and features, not for getting help. You can get help on the mailing list: cukes@googlegroups.com

Matt Wynne mattwynne closed this August 28, 2012
Bryan Ricker

I consider this a bug.

Matt Wynne mattwynne reopened this August 28, 2012
Matt Wynne
Owner

Fair enough. Please can you create a simple github repo that reproduces the problem, then I can clone it and take a look?

Bryan Ricker

Thank you for re-opening. I did put together an example application to demonstrate the issue after you requested it. Well, I should have done that before I even opened this issue - it turns out that this is actually an issue with factory_girl's create method polluting the controller's methods, only in Cucumber though (because in rspec those methods are being included into the rspec config).

I'll close this issue now. Sorry to have wasted your time! :)

Bryan Ricker bricker closed this August 28, 2012
Matt Wynne
Owner
Col

I'm having the same issue. Did you find an actual solution for this or just settle for the workaround?
This should really be submitted as an issue to FactoryGirl.

Bryan Ricker

@col The solution is to include the FactoryGirl::Syntax::Methods methods into Cucumber::World, instead of into Object (which is what happens if you just use include FactoryGirl::Syntax::Methods). In env.rb:

World(FactoryGirl::Syntax::Methods)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.