spec/scaffolder/test/helpers_spec.rb in scaffolder-test-helpers-0.3.0 vs spec/scaffolder/test/helpers_spec.rb in scaffolder-test-helpers-0.4.0
- old
+ new
@@ -1,71 +1,114 @@
require File.join(File.dirname(__FILE__),'..','..','spec_helper')
describe Scaffolder::Test::Helpers, "#generate_scaffold_files method" do
- describe "pass an array with a single sequence" do
+ describe "#generate_scaffold_files" do
- before(:all) do
- entries = [Sequence.new(:name => 'c1',:sequence => 'ATG')]
- @scaf_file, @seq_file = described_class.generate_scaffold_files(entries)
- end
+ context "passed an array with a single sequence" do
- it "should create the corresponding scaffold file" do
- File.exists?(@scaf_file.path).should be_true
- scaffold = YAML.load(File.read(@scaf_file.path))
- scaffold.should == [{'sequence' => {'source' => 'c1'}}]
- end
+ before(:all) do
+ entries = [Sequence.new(:name => 'c1',:sequence => 'ATG')]
+ @scaf_file, @seq_file = described_class.generate_scaffold_files(entries)
+ end
- it "should create the corresponding sequence file" do
- File.exists?(@seq_file.path).should be_true
- sequence = File.read(@seq_file.path)
- sequence.should == ">c1\nATG\n"
+ it "should create the corresponding scaffold file" do
+ File.exists?(@scaf_file.path).should be_true
+ scaffold = YAML.load(File.read(@scaf_file.path))
+ scaffold.should == [{'sequence' => {'source' => 'c1'}}]
+ end
+
+ it "should create the corresponding sequence file" do
+ File.exists?(@seq_file.path).should be_true
+ sequence = File.read(@seq_file.path)
+ sequence.should == ">c1\nATG\n"
+ end
+
end
- end
+ context "passed an array with two sequences" do
- describe "pass an array with two sequences" do
+ before(:all) do
+ entries = [Sequence.new(:name => 'c1',:sequence => 'ATG'),
+ Sequence.new(:name => 'c2',:sequence => 'ATG')]
+ @scaf_file, @seq_file = described_class.generate_scaffold_files(entries)
+ end
- before(:all) do
- entries = [Sequence.new(:name => 'c1',:sequence => 'ATG'),
- Sequence.new(:name => 'c2',:sequence => 'ATG')]
- @scaf_file, @seq_file = described_class.generate_scaffold_files(entries)
- end
+ it "should create the corresponding scaffold file" do
+ File.exists?(@scaf_file.path).should be_true
+ scaffold = YAML.load(File.read(@scaf_file.path))
+ scaffold.should == [{'sequence' => {'source' => 'c1'}},
+ {'sequence' => {'source' => 'c2'}}]
+ end
- it "should create the corresponding scaffold file" do
- File.exists?(@scaf_file.path).should be_true
- scaffold = YAML.load(File.read(@scaf_file.path))
- scaffold.should == [{'sequence' => {'source' => 'c1'}},
- {'sequence' => {'source' => 'c2'}}]
+ it "should create the corresponding sequence file" do
+ File.exists?(@seq_file.path).should be_true
+ sequence = File.read(@seq_file.path)
+ sequence.should == ">c1\nATG\n>c2\nATG\n"
+ end
+
end
- it "should create the corresponding sequence file" do
- File.exists?(@seq_file.path).should be_true
- sequence = File.read(@seq_file.path)
- sequence.should == ">c1\nATG\n>c2\nATG\n"
+ context "passed an array with a sequence and an unresolved region" do
+
+ before(:all) do
+ entries = [Sequence.new(:name => 'c1',:sequence => 'ATG'),
+ Unresolved.new(:length => 5)]
+ @scaf_file, @seq_file = generate_scaffold_files(entries)
+ end
+
+ it "should create the corresponding scaffold file" do
+ File.exists?(@scaf_file.path).should be_true
+ scaffold = YAML.load(File.read(@scaf_file.path))
+ scaffold.should == [{'sequence' => {'source' => 'c1'}},
+ {'unresolved' => {'length' => 5}}]
+ end
+
+ it "should create the corresponding sequence file" do
+ File.exists?(@seq_file.path).should be_true
+ sequence = File.read(@seq_file.path)
+ sequence.should == ">c1\nATG\n"
+ end
+
end
end
- describe "pass an array with a sequence and an unresolved region" do
+ describe "#generate_gff3_file" do
- before(:all) do
- entries = [Sequence.new(:name => 'c1',:sequence => 'ATG'),
- Unresolved.new(:length => 5)]
- @scaf_file, @seq_file = generate_scaffold_files(entries)
+ subject do
+ described_class.generate_gff3_file(records)
end
- it "should create the corresponding scaffold file" do
- File.exists?(@scaf_file.path).should be_true
- scaffold = YAML.load(File.read(@scaf_file.path))
- scaffold.should == [{'sequence' => {'source' => 'c1'}},
- {'unresolved' => {'length' => 5}}]
+ context "passed an empty array" do
+
+ let(:records){ [] }
+
+ it "should create a file" do
+ File.exists?(subject.path).should be_true
+ end
+
+ it "should generate an empty gff3 file" do
+ File.read(subject.path).should == "##gff-version 3\n"
+ end
+
end
- it "should create the corresponding sequence file" do
- File.exists?(@seq_file.path).should be_true
- sequence = File.read(@seq_file.path)
- sequence.should == ">c1\nATG\n"
+ context "passed an array with a single record" do
+
+ let(:records){ [Annotation.new(
+ :seqname => 'c1', :start => 4, :end => 6, :strand => '+',:phase => 1)] }
+
+ it "should create a file" do
+ File.exists?(subject.path).should be_true
+ end
+
+ it "should generate an empty gff3 file" do
+ record = "c1\t.\tCDS\t4\t6\t.\t+\t1\t.\n"
+ File.read(subject.path).should == "##gff-version 3\n" + record
+ end
+
end
end
+
end