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

Fail fast and show an error if no spec files are found #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fail fast and show an error if no spec files are found #158

wants to merge 1 commit into from

Conversation

MarkVillacampa
Copy link
Member

If there are no spec files, when running rake spec, the app will crash at runtime with this error message:

2014-05-12 19:06:02.608 App[69351:70b] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'spec.rb:476:in `current_context': undefined method `[]' for nil:NilClass (NoMethodError)

Since new Rubymotion projects come with a main_spec.rb sample spec, this will not be a common problem. However this can be very helpful when using the files env variable to select only some spec files (I run into this all the time).

The previous error will still happen if we have empty spec files. This could be solved by checking at runtime if @contexts is empty in spec.rb. But I'm not sure if this is recommended/necessary.

@MarkVillacampa
Copy link
Member Author

I'm not 100% convinced of the error message. If accepted, message suggestions are welcome.

@jacklynrose
Copy link

Good idea, might the best message simply be "No specs found"?

@squidpunch
Copy link

This problem also arises if you happen to run rake spec files "blah blah blah" when "blah blah blah" happens to be an incorrect path or filename (due to typo, etc). So in that case it would be nice to tell them what files they tried to run, but were incorrect. I put together a PR for the same thing without seeing this here, but was trying to figure out how to report what files were the problem. This seems to be the perfect place for that.

Unsure if I should change up #208 to match how its done here or just wait on this to be merged since it existed before and solves the problem - but has been out here for almost a year.

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