DevSolo
DevSolo

Reputation: 697

Trouble w/ Rubymine and unit tests

DISCLAIMER: I am very new to ruby, still trying to get my feet wet, so this could be hugely stupid issue.

I'm trying to get a very simple project and one unit test working, and the Universe is throwing a LifeException (I just can't figure this out)

Using Rubymine 4.0.1 on Mac OS X, 10.7.3. Launched RubyMine and created a new project (not Rails) "TestExample" Created a new Ruby Class, file is my_class.rb.

class MyClass
   def say_hi
      puts "Hi!"
   end
end

my = MyClass.new
my.say_hi

Create a new TestUnit Test Template, file is "my_test.rb"

require "test/unit"

class MyTest < Test::Unit::TestCase
   def test_create
      #my = MyClass.new
   end
end

At this point I have two issues: 1. How do I 'require' my class in my tests? If I change the above test case to:

require "test/unit"
require "my_class"

class MyTest < Test::Unit::TestCase
   def test_create
      #my = MyClass.new
   end
end

and attempt to run my "All tests in: TestExample" configuration, I get a "Exception message: cannot load such a file -- my_class". The Tests folder and working directory are pointed to the location of the files. (every file is in the same folder)

  1. The other is a "Unable to attach test reporter to test framework".

I've googled and attempted to figure this out to no avail. I realize this is two questions in one, and if I could just get tests working, I'd be happy.

Thanks for any input and don't laugh to hard at my uber-ruby-noobness.

[Update] - This only happens when using the RVM: ruby-1-9.3-p125 SDK. If I use the ruby-1.8.7-p249(/usr/bin/ruby), it does work. This has to be some configuration issue.

Upvotes: 1

Views: 526

Answers (1)

Alan Midona
Alan Midona

Reputation: 125

For the first question, try:

require_relative 'my_class'

I can't answer the second.

Upvotes: 2

Related Questions