Skip to content

Commit

Permalink
Made the date return an actual date object
Browse files Browse the repository at this point in the history
Improved tests
  • Loading branch information
subtleGradient committed Jul 25, 2008
1 parent cad1078 commit 6dae244
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
1 change: 0 additions & 1 deletion TODO
@@ -1,4 +1,3 @@
TODO:
Fix Rakefile with your name and contact info
Make the date return an actual date object
Make a to_s method that returns a basic pure-string sauce
4 changes: 4 additions & 0 deletions lib/sauce.rb
Expand Up @@ -61,6 +61,10 @@ def group
end

def date
Date.parse(date_raw)
end

def date_raw
@data[5]
end

Expand Down
39 changes: 20 additions & 19 deletions test/test_sauce.rb
Expand Up @@ -6,34 +6,35 @@
class TestSauce < Test::Unit::TestCase
def setup
@test_ansi = File.dirname(__FILE__) + '/sph_love.ans'
@sauce = Sauce.new @test_ansi
end
def teardown
end

def test_basic
s = Sauce.new @test_ansi
assert_equal '00' , @sauce.version
assert_equal 'ansilove menu' , @sauce.title
assert_equal 'sephiroth' , @sauce.author
assert_equal '' , @sauce.group

assert_equal 'sephiroth' , s.author
assert_equal '20051102' , s.group
assert_equal 'ansilove menu' , s.title
assert_equal '00' , s.version
# assert_equal Date.parse('06/03/96',true), s.date
assert_equal 0 , @sauce.comments
assert_equal 6396 , @sauce.filesize
assert_equal '' , @sauce.filler

assert_equal 0, s.comments
assert_equal 1, s.datatype_id
assert_equal '', s.filesize
assert_equal '', s.filetype_id
assert_equal '', s.filler
assert_equal '', s.flags_id
assert_equal '', s.sauce_id
assert_equal '', s.tinfo1
assert_equal '', s.tinfo2
assert_equal '', s.tinfo3
assert_equal '', s.tinfo4
assert_equal 1 , @sauce.datatype_id
assert_equal 1 , @sauce.filetype_id
assert_equal 0 , @sauce.flags_id
assert_equal 'SAUCE' , @sauce.sauce_id

assert_equal 80 , @sauce.tinfo1
assert_equal 25 , @sauce.tinfo2
assert_equal 0 , @sauce.tinfo3
assert_equal 0 , @sauce.tinfo4
end

def test_date
s = Sauce.new @test_ansi
assert_equal Date.parse('06/03/96',true), s.date
assert_equal '20051102', @sauce.date_raw
assert_equal Date.parse('2005-11-02'), @sauce.date
end

end

0 comments on commit 6dae244

Please sign in to comment.