spec/scaffolder/test/helpers_spec.rb in scaffolder-test-helpers-0.1.0 vs spec/scaffolder/test/helpers_spec.rb in scaffolder-test-helpers-0.2.0

- old
+ new

@@ -1,14 +1,71 @@ require File.join(File.dirname(__FILE__),'..','..','spec_helper') -describe Scaffolder::Test::Helpers do +describe Scaffolder::Test::Helpers, "#generate_scaffold_files method" do - it{ described_class.class.should == Module } + describe "pass an array with a single sequence" do - describe "namespace loading" do + before(:all) do + entries = [Sequence.new(:name => 'c1',:sequence => 'ATG')] + @scaf_file, @seq_file = described_class.generate_scaffold_files(entries) + end - it{ Scaffolder.class.should == Class } - it{ Scaffolder.methods.should include("update_with_sequence") } + it "should create the corresponding scaffold file" do + File.exists?(@scaf_file).should be_true + scaffold = YAML.load(File.read(@scaf_file)) + scaffold.should == [{'sequence' => {'source' => 'c1'}}] + end + it "should create the corresponding sequence file" do + File.exists?(@seq_file).should be_true + sequence = File.read(@seq_file) + sequence.should == ">c1\nATG\n" + end + end + 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 + + it "should create the corresponding scaffold file" do + File.exists?(@scaf_file).should be_true + scaffold = YAML.load(File.read(@scaf_file)) + scaffold.should == [{'sequence' => {'source' => 'c1'}}, + {'sequence' => {'source' => 'c2'}}] + end + + it "should create the corresponding sequence file" do + File.exists?(@seq_file).should be_true + sequence = File.read(@seq_file) + sequence.should == ">c1\nATG\n>c2\nATG\n" + end + + end + + describe "pass 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).should be_true + scaffold = YAML.load(File.read(@scaf_file)) + scaffold.should == [{'sequence' => {'source' => 'c1'}}, + {'unresolved' => {'length' => 5}}] + end + + it "should create the corresponding sequence file" do + File.exists?(@seq_file).should be_true + sequence = File.read(@seq_file) + sequence.should == ">c1\nATG\n" + end + + end end