Skip to content

Commit

Permalink
use class instead of a module and add basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Jarvis committed Apr 1, 2011
1 parent a5103b8 commit c7630f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
13 changes: 6 additions & 7 deletions ext/hello/hello.c
@@ -1,15 +1,14 @@
#include "ruby.h"

VALUE hello_world(VALUE self)
{
return rb_str_new2("Hello, World!");
}

VALUE Hello;
VALUE hello_world(VALUE self);

void Init_hello()
{
Hello = rb_define_module("Hello");
Hello = rb_define_class("Hello", rb_cObject);
rb_define_method(Hello, "world", hello_world, 0);
}

VALUE hello_world(VALUE self)
{
return rb_str_new2("Hello, World!");
}
2 changes: 1 addition & 1 deletion lib/hello.rb
@@ -1,5 +1,5 @@
require 'hello/hello'

module Hello
class Hello
VERSION = '0.0.1'
end
8 changes: 8 additions & 0 deletions test/hello_test.rb
@@ -0,0 +1,8 @@
require 'minitest/autorun'
require 'hello/hello'

class HelloTest < MiniTest::Unit::TestCase
def test_sanity
assert_equal 'Hello, World!', Hello.new.world
end
end

0 comments on commit c7630f5

Please sign in to comment.