maltize / sublime-text-2-ruby-tests

Sublime Text 2 plugin for running ruby tests! (Unit, RSpec, Cucumber)
722 stars 119 forks source link

Support Minitest::Spec #64

Open runlevel5 opened 12 years ago

runlevel5 commented 12 years ago

It seems to me Minitest::Spec specs are not support by Cmd+Shift R.

gs commented 12 years ago

Hi,

Could you provide more info? Check the console output CTRL+`

Br, Grzegorz

s01ipsist commented 12 years ago

Given a simple minitest file at test/unit/my_test.rb

require 'minitest_helper'

describe MyTest do

  describe 'the test' do
    it 'should be true' do
        true.must_equal true
    end
  end
end

The message returned from ctrl-shift-r (inside the 'should be true' block) is "No test name!"

ctrl-shift-t works just fine...

gs commented 12 years ago

Hi,

problem here is that test file name is exact same as unit tests (my_test.rb) For cucumber and rspec it was easier as they are subfixes as _spec, ..._feature Therefor we would need to extend regexp of unit tests.

We will try to figure it out.

Br, Grzegorz

s01ipsist commented 12 years ago

The regex to capture the test name is easy enough (within UnitTest)

      if not match_obj:
        match_obj = re.search('\s?([\"\'][a-zA-Z_\s\d]+[\"\'])\s+ti', test_file_content) # 3rd search for 'it "name"' - Minitest::Spec

However the test_name variable needs a counter prepended representing it's position within that spec. http://bfts.rubyforge.org/minitest/MiniTest/Spec.html E.g. The test names from

  describe 'the first test' do
    it 'should definitely be true' do
        true.must_equal true
    end
  end
  describe 'the test' do
    it 'should be true' do
        true.must_equal true
    end
    it 'should be false' do
        false.must_equal false
    end
  end

are

test_0001_should_definitely_be_true
test_0001_should_be_true
test_0002_should_be_false

which is tricky...

runlevel5 commented 12 years ago

@gs: there is no convention of using the naming _spec for the test specs though.

garymh commented 11 years ago

I would love this too, if you're still looking into it!

deadprogram commented 11 years ago

Anything ever happen on this?

nTraum commented 11 years ago

:+1:

evgenyneu commented 11 years ago

I have the same problem.

benwoodward commented 10 years ago

:+1: This is a problem for me too.

andreionut commented 9 years ago

I've created a PR to add support for Minitest: https://github.com/maltize/sublime-text-2-ruby-tests/pull/254 Let me know if it works