Commit 3401f954 by fistfvck

fix spec

parent a90dd234
...@@ -9,6 +9,7 @@ describe AnnotateModels do ...@@ -9,6 +9,7 @@ describe AnnotateModels do
require "tmpdir" require "tmpdir"
@dir = Dir.tmpdir + "/#{Time.now.to_i}" + "/annotate_models" @dir = Dir.tmpdir + "/#{Time.now.to_i}" + "/annotate_models"
FileUtils.mkdir_p(@dir) FileUtils.mkdir_p(@dir)
AnnotateModels.model_dir = @dir
end end
module ::ActiveRecord module ::ActiveRecord
...@@ -51,8 +52,7 @@ describe AnnotateModels do ...@@ -51,8 +52,7 @@ describe AnnotateModels do
# #
EOS EOS
AnnotateModels.model_dir = @dir
@user_file = create('user.rb', <<-EOS) @user_file = create('user.rb', <<-EOS)
class User < ActiveRecord::Base class User < ActiveRecord::Base
end end
...@@ -73,6 +73,7 @@ end ...@@ -73,6 +73,7 @@ end
end end
it "should write the schema before (default)" do it "should write the schema before (default)" do
ARGV.stub!(:dup).and_return []
AnnotateModels.stub!(:get_schema_info).and_return @schema_info AnnotateModels.stub!(:get_schema_info).and_return @schema_info
AnnotateModels.do_annotations AnnotateModels.do_annotations
File.read(@user_file).should eql(<<-EOF) File.read(@user_file).should eql(<<-EOF)
...@@ -91,6 +92,7 @@ EOF ...@@ -91,6 +92,7 @@ EOF
end end
it "should write the schema after" do it "should write the schema after" do
ARGV.stub!(:dup).and_return []
AnnotateModels.stub!(:get_schema_info).and_return @schema_info AnnotateModels.stub!(:get_schema_info).and_return @schema_info
AnnotateModels.do_annotations(:position => :after) AnnotateModels.do_annotations(:position => :after)
File.read(@user_file).should eql(<<-EOF) File.read(@user_file).should eql(<<-EOF)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment