spec/scaffolder/test/sequence_spec.rb in scaffolder-test-helpers-0.2.2 vs spec/scaffolder/test/sequence_spec.rb in scaffolder-test-helpers-0.3.0

- old
+ new

@@ -12,9 +12,95 @@ its(:to_fasta){should == ">contig1\nATGCCC"} its(:to_hash) {should == {'sequence' => {'source' => 'contig1'}} } end + describe "with an insert" do + + describe "added as a hash at initialisation" do + + subject do + described_class.new(:name => 'contig1',:sequence => 'ATGCCC',:inserts =>[{ + :open => 3, :close => 4, :sequence => 'TTT'}]) + end + + its(:name) {should == 'contig1'} + its(:sequence){should == 'ATGCCC'} + + its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT"} + its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [{ + 'open' => 3, 'close' => 4, 'source' => 'insert1'}]}} } + + end + + describe "added singularly to an existing contig" do + + subject do + contig = described_class.new(:name => 'contig1',:sequence => 'ATGCCC') + contig.inserts({:open => 3, :close => 4, :sequence => 'TTT'}) + end + + its(:name) {should == 'contig1'} + its(:sequence){should == 'ATGCCC'} + + its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT"} + its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [{ + 'open' => 3, 'close' => 4, 'source' => 'insert1'}]}} } + + end + + describe "added singularly to an existing contig" do + + subject do + contig = described_class.new(:name => 'contig1',:sequence => 'ATGCCC') + contig.inserts({:open => 3, :close => 4, :sequence => 'TTT'}) + end + + its(:name) {should == 'contig1'} + its(:sequence){should == 'ATGCCC'} + + its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT"} + its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [{ + 'open' => 3, 'close' => 4, 'source' => 'insert1'}]}} } + + end + + describe "added as an array to an existing contig" do + + subject do + contig = described_class.new(:name => 'contig1',:sequence => 'ATGCCC') + contig.inserts([{:open => 3, :close => 4, :sequence => 'TTT'}]) + end + + its(:name) {should == 'contig1'} + its(:sequence){should == 'ATGCCC'} + + its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT"} + its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [{ + 'open' => 3, 'close' => 4, 'source' => 'insert1'}]}} } + + end + + describe "added to an existing contig with one insert" do + + subject do + contig = described_class.new(:name => 'contig1',:sequence => 'ATGCCC', + :inserts =>[{:open => 3, :close => 4, :sequence => 'TTT'}]) + contig.inserts([{:open => 3, :close => 4, :sequence => 'TTT'}]) + end + + its(:name) {should == 'contig1'} + its(:sequence){should == 'ATGCCC'} + + its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT\n>insert2\nTTT"} + its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [ + {'open' => 3, 'close' => 4, 'source' => 'insert1'}, + {'open' => 3, 'close' => 4, 'source' => 'insert2'} + ]}}} + + end + end + [:start,:stop,:reverse].each do |attribute| describe "instance with #{attribute} attribute" do let(:value){:value}