Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows metadata to override the type of Rails spec #807

Merged
merged 4 commits into from
Oct 28, 2013

Conversation

alindeman
Copy link
Contributor

[Fixes #801]

c.include RSpec::Rails::ControllerExampleGroup,
:type => :controller,
:example_group => lambda { |example_group, metadata|
metadata[:type].nil? && c.escaped_path(%w[spec controllers]) =~ example_group[:file_path]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about something like this:

  def c.match_example_group_by_path(path)
    lambda { |example_group, metadata|
      metadata[:type].nil? && escaped_path(path) =~ example_group[:file_path]
    }
  end

  c.include RSpec::Rails::ControllerExampleGroup,
    :type          => :controller,
    :example_group => c.match_example_group_by_path(%w[spec controllers])

@soulcutter
Copy link
Member

Really good job documenting the magic directories w/cucumber 🍰

@JonRowe
Copy link
Member

JonRowe commented Aug 20, 2013

Do we know why the build is failing on this? I started tackling this from the opposite end but this is a better approach. I suspect @alindeman will be too busy to look at this this week though...

@JonRowe
Copy link
Member

JonRowe commented Aug 20, 2013

Needs restarting once the have issue is taken care of...

@alindeman
Copy link
Contributor Author

@JonRowe, can you give some context around 817f47d? I reverted it because it isn't valid syntax in 1.8, and the build is green, so I'm worried I'm missing something.

@JonRowe
Copy link
Member

JonRowe commented Oct 27, 2013

No idea, it's been a while but maybe protecting against not being given metadata in some scenarios?

alindeman added a commit that referenced this pull request Oct 28, 2013
Allows metadata to override the type of Rails spec
@alindeman alindeman merged commit 6a8cc7f into master Oct 28, 2013
@alindeman alindeman deleted the issue-801-overridding-spec-types branch October 28, 2013 01:04
@alindeman
Copy link
Contributor Author

🆒 I think rspec-core's arity checking will make sure this holds up OK, but if you know of a specific circumstance it breaks down, let me know :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot override :type of specs in spec/routing in order to test external redirect scenarios
3 participants