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

Depend on guard #131

Closed

Conversation

deivid-rodriguez
Copy link
Contributor

Guard is a dependency of its plugins.

Guard is a dependency of its plugins.
@e2
Copy link
Contributor

e2 commented Jul 8, 2015

I'm sorry to say I have to reject this because of the way Minitest works - it breaks things in really, really obscure ways. In fact, the reason the dependency on Guard was removed in many places was because of Minitest.

It's maybe not intuitive, but plugins don't need to rely on Guard - they need to rely on Guard's API, not on Guard itself (since plugins don't use guard - they just inherit from Guard::Plugin).

This is why Guard::Compat was created (https://github.com/guard/guard-compat) - it's the "Guard API" that Guard plugins "depend on". This separation allows Guard plugins to be used while developing/testing other Guard plugins.

Also, theoretically, you could use Guard plugins without Guard in some cases other than specs/tests (e.g. Rake tasks - or simply reusing the code in the plugins).

The biggest problem is that Guard plugins use inheritance - it wasn't a good design decision, but there's no sane way out of this anymore (too many plugins - Guard::Compat is the best I could do to allow moving away from inheritance in the future - without breaking existing plugins).

So, in your Gemfiles you should have:

gem 'guard-minitest'
gem 'guard'

If this is causing problems (some undefined crashes or something) - do let me know, and I'll figure something out.

Thanks!

@e2 e2 closed this Jul 8, 2015
@deivid-rodriguez
Copy link
Contributor Author

No, the only reason for the PR was to prevent specifying both guard and guard-minitest in my Gemfile (seemed redundant and it didn't make sense to me to use the plugin without guard). I checked a few guard plugins and they all seemed to specify the dependency, but it seems there's a good reason not to do it in this case.

Thanks!

@e2
Copy link
Contributor

e2 commented Jul 9, 2015

Thanks for letting me know.

Yes - the plugins will work, but the tests for those plugins could fail miserably (AFAIR - what broke the most were plugins themselves using guard-minitest for testing - I didn't want make to life harder for plugin authors).

I made the same mistake of adding back the dependency a few times until I realized what was going on.

I think it's ok for most Guard plugins to actually depend on Guard - Guard::Minitest is the exception though.

The tradeoff to making Guard a dependency of Guard::Minitest would be - no other Guard plugin could use Guard::Minitest for testing (not hard, though I think a few plugin authors would prefer to stick to Minitest anyway).

I actually migrated the Guard::Minitest Minitest tests to RSpec, because of the conflicts (shhh - don't tell any Minitest fanatics! ;) ).

@deivid-rodriguez deivid-rodriguez deleted the depend_on_guard branch July 9, 2015 00:13
@e2 e2 mentioned this pull request Jul 13, 2015
@e2
Copy link
Contributor

e2 commented Jul 13, 2015

If anyone is interested in fixing this, it depends on this getting done first: guard/guard#713

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.

2 participants