senny / cabbage

get the maximum out of emacs
http://senny.github.com/cabbage/
155 stars 21 forks source link

ruby: run *_test.rb files inside emacs #186

Closed tonini closed 11 years ago

tonini commented 11 years ago

What do you guys think about running *_test.rb files under emacs like it does for *_spec.rb files already?

cheers

/cc @senny

senny commented 11 years ago

definitely :+1: on this one! Do you have a working solution already?

tonini commented 11 years ago

I haven't. There're still some question I have about how to require liberiers.

require_relative 'test_helper'
require_relative '../lib/tiny_db'

class TinyDBTest < MiniTest::Unit::TestCase
  def setup
    @db = TinyDB.new
  end
end

as an example In the case like above I just run ruby test/tiny_db_test.rb.

require_relative 'test_helper'
require 'tiny_db'

class TinyDBTest < MiniTest::Unit::TestCase
  def setup
    @db = TinyDB.new
  end
end

command usage like ruby -I lib test/test_db_test.rb as example

what do you think?

senny commented 11 years ago

I think the test_helper must ensure that the lib environment works. I wouldn't supply -Ilib to the ruby binary. I think there should be a mode out already to run test-unit tests. I'll have a look at this one later on.

tonini commented 11 years ago

ok, thank you.

tonini commented 11 years ago

@senny Do you know quickrun.el -> https://github.com/syohex/emacs-quickrun ?

What do you think about integrating it into cabbage?

senny commented 11 years ago

I'm not too keen on adding dependencies just to use a single function. I can see the use of it but running a ruby buffer can easily be achieved with ruby-compilation-this-buffer.

senny commented 11 years ago

There is also ruby-compilation-this-test which, seems to be able to run a single test-unit test. combining these functions with the testing API already in cabbage should yield a similar result as the rspec-mode

tonini commented 11 years ago

I see the point and I agree with it. As you already said ruby-compilation-this-test is what we need. I'm using ruby-compilation-this-buffer at the moment. The thing we have to work out is that every compilation function in ruby-compilation.el doesn't clear the buffer after a run. Otherwise, I quite like it. :+1:

tonini commented 11 years ago

I would like to kill the test report buffer if exists, as I mentioned before. Something like this:

(just an example)

(defun cabbage--run-single-ruby-file ()
  (interactive)
  (let* ((name (file-name-nondirectory (car (split-string (buffer-file-name)))))
         (name-buffer (format "*%s*" name)))
    (if (get-buffer name-buffer)
        (kill-buffer name-buffer))
    (ruby-compilation-run (buffer-file-name))))
tonini commented 11 years ago

implemented d3529a942932757fcc596554344bbe63608a8e7e