Controller specs should automatically have type #38

Closed
iain opened this Issue Apr 25, 2010 · 6 comments

Comments

Projects
None yet
2 participants
Contributor

iain commented Apr 25, 2010

When describing a controller it has no type, so Rspec.configuration.include(Foo, :type => :controller) doesn't work.
While it is possible to specify it by hand, it would be nice if controllers have a type automatically (or the manual type declaration is generated in the file).

Owner

dchelimsky commented Apr 25, 2010

What do you mean "specify it by hand"?

Contributor

iain commented Apr 25, 2010

Like this:

describe UsersController, :type => :controller do
end
Owner

dchelimsky commented Apr 25, 2010

You can get that like this now:

Rspec.configure do |c|
  c.include Foo, :example_group => {
    :describes => lambda {|described| described < ActionController::Base }
  }
end

Make sense?

Contributor

iain commented Apr 25, 2010

I can follow what you're doing. Is this a conscious design decision, or just a more global approach or workaround?

Owner

dchelimsky commented Apr 25, 2010

rspec-2 is based on Micronaut, which is a complete re-write of the runner. This sort of filtering is built-in, so I'm hesitant to add other ways to do the same thing.

This will be well documented by the time we go 2.0.0-final, but there are a lot of other priorities right now.

I'll leave this open for now and we'll see how it goes.

Owner

dchelimsky commented Jul 11, 2010

Add :type => :xxx to metadata for each specialized example group.

  • controller
  • helper
  • mailer
  • request
  • routing
  • view

This supports attaching behaviour to a subset of example groups in a
config block:

RSpec.configure do |c|
  before(:each, :type => :controller) do
    # do something
  end
end

Note that this is not mean you can attach controller spec behaviour to a
group like this:

DOES NOT WORK

describe "something", :type => :controller do

Closed by b3ab2bc.

jamesottaway pushed a commit to jamesottaway/rspec-rails that referenced this issue Mar 30, 2015

Add :type => :xxx to metadata for each specialized example group.
- controller
- helper
- mailer
- request
- routing
- view

This supports attaching behaviour to a subset of example groups in a
config block:

    RSpec.configure do |c|
      before(:each, :type => :controller) do
        # do something
      end
    end

Note that this is not mean you can attach controller spec behaviour to a
group like this:

  # DOES NOT WORK
  describe "something", :type => :controller do

Closes #38.

This issue was closed.

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