spec/scaffolder/tool/sequence_spec.rb in scaffolder-tools-0.1.2 vs spec/scaffolder/tool/sequence_spec.rb in scaffolder-tools-0.1.3
- old
+ new
@@ -1,6 +1,6 @@
-require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
+require 'spec_helper'
describe Scaffolder::Tool::Sequence do
it "should inherit from Scaffolder::Tool" do
described_class.superclass.should == Scaffolder::Tool
@@ -9,32 +9,71 @@
it "should return the description of the tool" do
desc = "Generate the fasta output for the scaffold"
described_class.description.should == desc
end
- describe "execution when correctly instantiated" do
+ describe "command line argument" do
- before(:each) do
- entries = [{:name => 'seq1', :nucleotides => 'ATGC'}]
+ before do
+ cntg = Sequence.new(:name => 'seq1', :sequence => 'ATGC')
+ @scf_file, @seq_file = generate_scaffold_files([cntg])
+ end
- @scaffold_file = File.new("scaffold",'w').path
- @sequence_file = File.new("sequence",'w').path
+ subject do
+ Bio::FastaFormat.new(
+ StringIO.new(
+ described_class.new(
+ MockSettings.new(
+ @scf_file.path,
+ @seq_file.path,
+ settings)).execute).string)
+ end
- write_scaffold_file(entries,@scaffold_file)
- write_sequence_file(entries,@sequence_file)
- settings = mock_command_line_settings(@scaffold_file,@sequence_file,{
- :definition => nil,:no => nil})
+ describe "empty" do
- tool = described_class.new(settings)
- @output = StringIO.new(tool.execute)
+ let(:settings) do
+ {}
+ end
+
+ it "should set the fasta definition" do
+ subject.definition.should == ""
+ end
+
+ it "should return the expected sequence" do
+ subject.seq.should == 'ATGC'
+ end
+
end
- after(:each) do
- File.delete @scaffold_file, @sequence_file
+ describe "--definition" do
+
+ let(:settings) do
+ {:definition => 'name'}
+ end
+
+ it "should set the fasta definition" do
+ subject.definition.should == "name"
+ end
+
+ it "should return the expected sequence" do
+ subject.seq.should == 'ATGC'
+ end
+
end
- it "should return the expected sequence" do
- Bio::FlatFile.auto(@output).first.seq.should == 'ATGC'
+ describe "--with-sequence-digest" do
+ let(:settings) do
+ {:"with-sequence-digest" => true}
+ end
+
+ it "should set the fasta definition" do
+ header = "[sha1=627a3d8eb465be91696114803b3410ca92f59cc7]"
+ subject.definition.should == header
+ end
+
+ it "should return the expected sequence" do
+ subject.seq.should == 'ATGC'
+ end
end
end
end