add :type => :controller auto-mixes in ControllerExampleGroup #256

Closed
skippy opened this Issue Nov 3, 2010 · 1 comment

Comments

Projects
None yet
2 participants

skippy commented Nov 3, 2010

this is really handy if you have test code that doesn't reside in the default folders. For example, I have a bunch of controller level mixins that I keep in the lib folder (along with app-specific mix ins for models, etc). I test these at the lib level as they aren't full controllers, they just add specific logic.
so in spec/lib/* I would define define MyTestController, :type => :controller, and it worked just fine in rspec 1.x. This doesn't work in rspec 2.x because :type is not defined at this point...it is only defined for files that reside within a predefined folder.

I think this would be great to add back into rspec-rails 2. Right now I do this, in a file in the support folder (named it 1_rspec_exts so it loads first)

RSpec.configuration.include RSpec::Rails::ControllerExampleGroup, :type => :controller
RSpec.configuration.include RSpec::Rails::HelperExampleGroup, :type => :helper
RSpec.configuration.include RSpec::Rails::MailerExampleGroup, :type => :mailer
RSpec.configuration.include RSpec::Rails::ModelExampleGroup, :type => :model
RSpec.configuration.include RSpec::Rails::RequestExampleGroup, :type => :request
RSpec.configuration.include RSpec::Rails::RoutingExampleGroup, :type => :routing
RSpec.configuration.include RSpec::Rails::ViewExampleGroup, :type => :view

that way I can have any file anywhere, and jsut add :type => :controller|:model, etc, and it just works.

thanks!

Owner

dchelimsky commented Jan 1, 2011

Include rails-specific example group extensions based on :type key.

  • e.g. describe "something", :type => :controller do
  • reworked internal module inclusion functionality
  • include request spec extensions in spec/integration for ease of
    upgrade from rspec-rails-1.x
  • Closed by fc5cdbb.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment