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

Minitest tests no longer run after requiring 'email_spec' #112

Open
andyw8 opened this issue Sep 5, 2012 · 10 comments
Open

Minitest tests no longer run after requiring 'email_spec' #112

andyw8 opened this issue Sep 5, 2012 · 10 comments

Comments

@andyw8
Copy link

andyw8 commented Sep 5, 2012

I've added email_spec to my Gemfile. When I put require 'email_spec' in my test helper, and try to run the tests, I get this output:

0 tests, 0 passed, 0 failures, 0 errors, 0 skips, 0 assertions

When I remove the require 'email_spec' and re-run them all is fine.

I'm using Rails 3.0.8

@bmabey
Copy link
Collaborator

bmabey commented Sep 5, 2012

This is a feature that instantly gives you a green test suite. :)

Seriously though, I have no idea why requiring email-spec would do this since there is no minitest specific code in email-spec. I've never used minitest though so I don't even know where to begin looking. I don't think I'll have time to look into this so if a minitest expert (maybe @blowmage?) could shed some light on this I would appreciate it.

@blowmage
Copy link
Contributor

blowmage commented Sep 5, 2012

@andyw8 How are you configuring your app to test with Minitest? Are you using minitest-rails or are you configuring Minitest yourself?

@andyw8
Copy link
Author

andyw8 commented Sep 5, 2012

I'm using minitest-rails and minitest-rails-capybara. I suspect something is conflicting.

@blowmage
Copy link
Contributor

blowmage commented Sep 5, 2012

email-spec has a dependency on rspec-rails. So when you require it in your Gemfile it switches your app to use RSpec instead of Minitest. That is why no tests are getting run, because you don't have any (specs).

@bmabey
Copy link
Collaborator

bmabey commented Sep 6, 2012

I can't recall why email-spec relies on rspec-rails. It may not be necessary and could be removed. I'd be willing to merge in a patch that does that but I won't have time to it myself.

@blowmage
Copy link
Contributor

FWIW, the dependency that was problematic is the runtime dependency on rspec, not the development dependency on rspec-rails. Unfortunately, this gem uses RSpec::Matchers.define to define some matchers, so its not as simple as simply removing the runtime dependency. Some code will need to be changed in order to include the EmailSpec::Matchers module in MiniTest. Also, EmailSpec::Helpers has one call to RSpec's should method.

@blowmage
Copy link
Contributor

This can be resolved by #118, which adds support for MiniTest.

@Florent2
Copy link

I have email-spec (version 1.4.0) working with MiniTest (bundling minitest-matchers), except when using some helpers because of the call to RSpec's should method. Any way to avoid this issue?

@blowmage
Copy link
Contributor

Huh, I didn't realize there was a reverse dependency on the testing library in the helper. I guess one way to fix this is to place the call behind a conditional:

def parse_email_for_link(email, text_or_regex)
  if email.respond_to? :should
    email.should have_body_text(text_or_regex)
  elsif email.respond_to? :must
    email.must have_body_text(text_or_regex)
  end

Or, the other way is to remove the should call completely. As I read the code, the subsequent calls to parse_email_for_explicit_link and parse_email_for_anchor_text_link will return nil, which will cause the method to raise an error. So the behavior is essentially the same.

@bmabey What do you think?

@bmabey
Copy link
Collaborator

bmabey commented Jan 27, 2013

After looking at the file again I'm somewhat confused why the should is in there in the first place because a few lines down an exception is thrown if there is no match. It worth noting that this is the only helper with an assertion made as well. So right now I'm inclined to simply remove the line.

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

No branches or pull requests

4 participants