test/rscm/revision_test.rb in rscm-0.4.5 vs test/rscm/revision_test.rb in rscm-0.5.0
- old
+ new
@@ -1,129 +1,34 @@
-require 'yaml'
-require 'rscm/revision_fixture'
+require File.dirname(__FILE__) + '/test_helper'
+require 'rscm/revision'
+require 'rscm/revision_file'
module RSCM
- class RevisionTest < Test::Unit::TestCase
- include RevisionFixture
-
- def setup
- setup_changes
- end
-
- def test_convert_changes_to_revisions_should_match_user_message_and_timestamp_
- revisions = Revisions.new
- revisions.add(@change1)
- revisions.add(@change2)
- revisions.add(@change3)
- revisions.add(@change4)
- revisions.add(@change5)
- revisions.add(@change6)
- revisions.add(@change7)
-
- revision_0 = Revision.new
- revision_0 << @change1
- revision_0 << @change2
+ class RevisionTest < Test::Unit::TestCase
+ def test_accepts_files_in_range_and_reports_min_and_max
+ revision = Revision.new
- revision_1 = Revision.new
- revision_1 << @change3
-
- revision_2 = Revision.new
- revision_2 << @change4
-
- revision_3 = Revision.new
- revision_3 << @change5
- revision_3 << @change6
- revision_3 << @change7
-
- assert_equal(4, revisions.length)
-
- expected_revisions = Revisions.new
- expected_revisions.add(revision_0)
- expected_revisions.add(revision_1)
- expected_revisions.add(revision_2)
- expected_revisions.add(revision_3)
-
- assert_equal(expected_revisions, revisions)
- end
-
- def test_revisions_can_add_individual_changes_and_group_in_revision_instances
- revisions = Revisions.new
- assert(0, revisions.length)
+ revision.add RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2004,11,11,12,12,12))
+ revision.add RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2004,11,11,12,13,12))
+ assert_raise(RuntimeError) do
+ revision.add RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2004,11,11,12,14,13))
+ end
- revisions.add(@change1)
- revisions.add(@change2)
- revisions.add(@change3)
- revisions.add(@change4)
- assert(3, revisions.length)
-
- tjo_bing_revision = revisions[0]
- hipp_hurra_revision = revisions[1]
- hipp_hurraX_revision = revisions[2]
- assert(2, tjo_bing_revision.length)
- assert(1, hipp_hurra_revision.length)
- assert(1, hipp_hurraX_revision.length)
-
- assert_same(@change1, tjo_bing_revision[0])
- assert_same(@change2, tjo_bing_revision[1])
- assert_same(@change3, hipp_hurra_revision[0])
- assert_same(@change4, hipp_hurraX_revision[0])
+ t12 = Time.utc(2004,11,11,12,12,12)
+ t13 = Time.utc(2004,11,11,12,13,12)
+ assert_equal(t12, revision.time(:min))
+ assert_equal(t13, revision.time(:max))
end
- def test_should_sort_by_time
- revisions = Revisions.new
- revisions.add(@change1)
- revisions.add(@change4)
- revisions.add(@change2)
- revisions.add(@change7)
- revisions.add(@change5)
- revisions.add(@change3)
- revisions.add(@change6)
-
- revisions = revisions.sort do |a,b|
- a.time <=> b.time
- end
- assert_equal(4, revisions.length)
-
- assert_equal(@change2.time, revisions[0].time)
- assert_equal(@change7.time, revisions[-1].time)
+ def test_should_be_equal_when_data_equal
+ assert_equal Revision.new, Revision.new
end
- def test_can_parse_revisions_from_yaml
- revisions = File.open(File.dirname(__FILE__) + "/revisions.yaml") do |io|
- YAML::load(io)
- end
- assert_equal("rinkrank", revisions[0][1].developer)
- assert_equal("En to\ntre buksa \nned\n", revisions[0][1].message)
- end
-
- def test_reports_timestamp_of_latest_change
- revision = Revision.new
- revision << RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2004))
- revision << RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2005))
- revision << RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2003))
- assert_equal(Time.utc(2005), revision.time)
- end
-
- def test_should_sort_revisions
- revisions = Revisions.new
- revisions.add(@change1)
- revisions.add(@change4)
- revisions.add(@change2)
- revisions.add(@change7)
- revisions.add(@change5)
- revisions.add(@change3)
- revisions.add(@change6)
+ def test_should_be_yamlable
+ r1 = Revision.new
+ r1.developer = "aslak"
- cs0 = revisions[0]
- cs1 = revisions[1]
- cs2 = revisions[2]
- cs3 = revisions[3]
-
- reversed = revisions.reverse
- assert_equal(cs0, reversed[3])
- assert_equal(cs1, reversed[2])
- assert_equal(cs2, reversed[1])
- assert_equal(cs3, reversed[0])
+ r2 = YAML::load(YAML::dump(r1))
+ assert_equal r1.developer, r2.developer
end
end
-
end