jstorimer / spin

Spin speeds up your Rails testing workflow by preloading your Rails environment.

Home Page:http://jstorimer.github.com/spin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

console

jstorimer opened this issue · comments

spin console

Since we already have the environment preloaded, why couldn't we use that to fork off a rails console?

I've done some tests and found out how to run a irb session, I didn't quite figure out yet how to implement it because I don't have a lot of experience with fork and how to handle that flow.

If you require environment instead of application you can call your models like you normally would in a Rails console.

These are the steps required to start a session:

require 'config/environment'       
# require 'config/application' # doesn't seem to load in everything correctly
require 'irb'
IRB.start

That would work, but I think it would be better to piggy back off of the actual rails command sources.

Have a look at https://github.com/rails/rails/blob/master/railties/lib/rails/commands/console.rb

We'd need something like:

require 'rails/commands/console'
require 'config/environment'
Rails::Console.start(Rails.application)

Yeah I wasn't quite sure if you wanted to go with the Rails approach or a more agnostic one, I thought I read somewhere you wanted to support non-Rails apps as well but I'm not quite sure where :)

The code you posted works and loads in everything correctly. But I have a feeling it might be better if the console session would start where you call spin console and not in the spin serve window. In my workflow now I have a split terminal with spin serve on the left that's showing me the test output, and I'm pushing on the right. If there's one place for user input without forcing to switch to the serve process that would be better in my opinion.

I saw dstrelau added some work that outputs the results in the push process, so perhaps we can use that. What do you think?

commenting to subscribe..

Don't mean to spam but you can actually subscribe to issues/pull requests via the link under the comment form:

Notifications for new comments on this Issue are off. Enable notifications for this Issue