Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use class instead of a module and add basic test
- Loading branch information
Lee Jarvis
committed
Apr 1, 2011
1 parent
a5103b8
commit c7630f5
Showing
3 changed files
with
15 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require 'hello/hello' | ||
|
||
module Hello | ||
class Hello | ||
VERSION = '0.0.1' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |