test/test_insert.rb in scaffolder-0.2.6 vs test/test_insert.rb in scaffolder-0.4.0

- old
+ new

@@ -1,59 +1,51 @@ require 'helper' class TestInsert < Test::Unit::TestCase - context Scaffolder::Insert do + context Scaffolder::Region::Insert do - setup do - @options = { - :start => 5, - :stop => 10, - :sequence => "ATGCGGGC" - } - end + context "attributes" do - should "correctly store the passed options" do - i = Scaffolder::Insert.new @options - assert_equal(i.start, @options[:start]) - assert_equal(i.stop, @options[:stop]) - assert_equal(i.sequence, @options[:sequence]) - end + should_have_attribute Scaffolder::Region::Insert, :source, :open, :close - should "reverse the sequence when passed the reverse tag" do - i = Scaffolder::Insert.new @options.merge(:reverse => true) - rev = Bio::Sequence::NA.new(@options[:sequence]).reverse_complement - assert_equal(i.sequence, rev.upcase) - end + setup do + @length = 15 + @insert = Scaffolder::Region::Insert.new + @insert.raw_sequence('N' * @length) + end - should "correctly generate the position" do - i = Scaffolder::Insert.new @options - assert_equal(i.position, (@options[:start]-1)..(@options[:stop]-1)) - end + should "return open plus sequence length as default close" do + @insert.open 5 + assert_equal(@insert.close,@insert.open + @length - 1) + end - should "estimate the sequence end position" do - @options.delete(:stop) - i = Scaffolder::Insert.new @options - assert_equal(i.stop, @options[:start] + @options[:sequence].length - 1) - end + should "return close minus sequence length as default open" do + @insert.close 20 + assert_equal(@insert.open,@insert.close - @length - 1) + end - should "estimate the sequence start position" do - @options.delete(:start) - i = Scaffolder::Insert.new @options - assert_equal(i.start, @options[:stop] - @options[:sequence].length - 1) - end + should "include the insert position" do + @insert.open 5 + @insert.close 10 + assert_equal(@insert.position,4..9) + end - should "throw error when neither start or stop are provided" do - @options.delete(:start) - @options.delete(:stop) - assert_raise ArgumentError do - Scaffolder::Insert.new @options + should "throw an error when neither open or close are provided" do + assert_raise(Scaffolder::Errors::CoordinateError){ @insert.position } end + end - should "be comparable by end position" do - a = Scaffolder::Insert.new @options - b = Scaffolder::Insert.new @options.merge(:stop => @options[:stop] + 1) - c = Scaffolder::Insert.new @options.merge(:stop => @options[:stop] + 2) + should "be comparable by close position" do + a = Scaffolder::Region::Insert.new + a.close 1 + + b = a.clone + b.close 2 + + c = b.clone + c.close 3 + assert_equal([c,a,b].sort, [a,b,c]) end end end