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

Use rails/spring when available #72

Closed
glennfu opened this issue Jul 27, 2014 · 17 comments
Closed

Use rails/spring when available #72

glennfu opened this issue Jul 27, 2014 · 17 comments

Comments

@glennfu
Copy link

glennfu commented Jul 27, 2014

Spring (https://github.com/rails/spring) now comes default with Rails projects and with https://github.com/jonleighton/spring-commands-rspec you can now run bin/rspec spec/models/blah_spec.rb to very quickly run specs. It would be great if TextMate could take advantage of this.

@noniq
Copy link

noniq commented Jul 27, 2014

Please try https://github.com/die-antwort/rspec-tmbundle/tree/use-binstub-if-present and see if it works for you. If yes, I’ll make it into a PR.

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

I checked it out, switched to use-binstub-if-present branch, replaced my RSpec.tmbundle with it, reloaded TextMate, and tried running my spec file a few times. Each of 3 runs took 8 seconds (this project has a ton of gems) before the window appeared.

Running in console with bin/rspec it's less than a second after hitting "Enter" before the first spec has passed. With regular rspec it's about 7 seconds before the first spec passes.

I guess that means it didn't work.

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

Scratch that. I moved the old one to RSpec.old.tmbundle and I should have deleted it. Removing that one and just using yours fixed it. Hooray! Definitely submit this one.

On a side note, it still takes about 1.5 sec for the window to pop up. I remember in TextMate 1, the window would appear with a spinner immediately after sending the command. Might something similar be possible in this case? Sometimes I hit the command, and then I'm not sure I actually hit it because I don't see the window, so I hit it again, and a few seconds later I have 2 competing windows both running at the same time. If this is a hassle, no worries. Your current solution is fantastic for anyone using Spring.

@noniq
Copy link

noniq commented Jul 27, 2014

Hm. The relevant code is in Support/lib/rspec/mate.rb. If you add p use_binstub? in line 76 does it print true or false at the beginning of output when you run the specs?

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

Sorry guess you still only saw my first message. use_binstub? definitely works. However now I'm testing in an RSpec 3 project WITHOUT spring and getting an error: rspec/mate/runner.rb:84:inrun': undefined method string' for nil:NilClass (NoMethodError)

I'll debug it a bit and post back here in a few minutes.

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

For clarification, the successful run was using RSpec 2.14.1 with Spring. The unsuccessful with RSpec 3.0.3 without Spring.

@noniq
Copy link

noniq commented Jul 27, 2014

Seems like an exception happens inrunner.rb line 38 or 39 (before stderr gets set). I suspect something goes wrong in rspec3? (which is defined in mate.rb). Does this help to narrow it down?

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

In def rspec3? if I add puts "RSpec::Core: #{RSpec::Core}" I get uninitialized constant RSpec::Core

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

::RSpec is defined, ::RSpec::Core is not defined.

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

Here's a better clue: If I insert require 'rspec/core' on line 63 just after @rspec_version ||= begin then it works for both my projects.

@noniq
Copy link

noniq commented Jul 27, 2014

Thanks, I screwed up the conditionals when adding binstub support. I just updated https://github.com/jonleighton/spring-commands-rspec with a fix.

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

Do you mean this? die-antwort@d25204d

I just pulled and things look good.

@noniq
Copy link

noniq commented Jul 27, 2014

Yes of course, seems I copied the wrong link … time to go to bed, I suppose 😴

As said, I’ll prepare a PR for this soon.

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

Just checked out your fix-run-focussed-for-rspec3 branch as well and it works great! Hopefully you get all of these things out soon. In the meantime I’ve got a local merge of them and I’m very pleased and very grateful to you. Great job!

Glenn

On Jul 26, 2014, at 8:31 PM, Stefan Daschek notifications@github.com wrote:

Yes of course, seems I copied the wrong link … time to go to bed, I suppose 😴

As said, I’ll prepare a PR for this soon.


Reply to this email directly or view it on GitHub.

@glennfu
Copy link
Author

glennfu commented Jul 27, 2014

Another thought:

“Save Example file and remember” looks unbound, but it’s one of the only features about RubyMine that I feel is really nice. I changed my local behavior to automatically save the file whenever I run a spec file or a focused spec, and then bound the “Run Last Examples file” to ctrl+cmd+r. I also changed the “scope selector” of the bundle command to *. With that, I have a “retry” button from any file for whatever the last spec was that I ran from any file. Super handy! I can keep coding and changing and retrying as I go without actually needing to go back to the spec file.

Do you think this would make for good default behavior? I can almost submit a pull request, but I’m a bit stumped on the part where it saves the file, and I’d rather it save the file and the line number if it was run as a focused file. I’d have to write the relevant options to the file and not just the file name, and my first thought would be to store it as with .to_json and pull it out with JSON.parse, but the json library isn’t available in this context. Is there already a convention I should be using for this?

Thanks!
Glenn

On Jul 26, 2014, at 8:31 PM, Stefan Daschek notifications@github.com wrote:

Yes of course, seems I copied the wrong link … time to go to bed, I suppose 😴

As said, I’ll prepare a PR for this soon.


Reply to this email directly or view it on GitHub.

@noniq
Copy link

noniq commented Jul 27, 2014

PR for using binstubs: #75

@noniq
Copy link

noniq commented Jul 28, 2014

Closed with #75 :)

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

2 participants