Module: RSpecCoreTest

Defined in:
lib/spade/package/spec/support/core_test.rb

Instance Method Summary collapse

Instance Method Details

#run_core_tests(path, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/spade/package/spec/support/core_test.rb', line 28

def run_core_tests(path, &block)
  describe "#{path}" do
    rootdir = File.expand_path(File.join(__FILE__, '/../../../'));
    context = Spade::MainContext.new(:rootdir => rootdir) do |ctx|
      ctx['checkRSpec'] = lambda do |status, test_info, message|
        it "#{test_info.module.name}: #{test_info.name}" do
          if status == 'warnings' && message == "Not Yet Implemented"
            pending
          else
            [status.to_s, message.to_s].should be_ct_success
          end
        end
      end

      ctx.eval <<END
var Ct;
try {
Ct = require('core-test');
} catch (e) { }

if (Ct) {
RubyLogger = require('core-test/utils').extend(Ct.DefaultLogger, {
  add: function(status, testInfo, message){
    checkRSpec(status, testInfo, message);
  }
});
Ct.defaultLogger = new RubyLogger('ruby');

require('file:#{path}');

Ct.run();
} else {
console.log("CoreTest is not installed. Use `spade install core-test`.");
}
END
    end
  end
end