Commit b2fbd90a by capripot

update spec to support file with dir

parent 41d13a25
......@@ -136,9 +136,8 @@ EOS
# todo: use 'files' gem instead
def create(file, body="hi")
file_path = File.join(AnnotateModels.model_dir, file)
file_path = File.join(AnnotateModels.model_dir[0], file)
FileUtils.mkdir_p(File.dirname(file_path))
File.open(file_path, "wb") do |f|
f.puts(body)
end
......@@ -146,7 +145,7 @@ EOS
end
def check_class_name(file, class_name)
klass = AnnotateModels.get_model_class(file)
klass = AnnotateModels.get_model_class(File.join(AnnotateModels.model_dir[0], file))
expect(klass).not_to eq(nil)
expect(klass.name).to eq(class_name)
......@@ -294,7 +293,7 @@ EOS
CONSTANT = 1
end
EOS
path = File.expand_path("#{AnnotateModels.model_dir}/loaded_class")
path = File.expand_path('loaded_class', AnnotateModels.model_dir[0])
Kernel.load "#{path}.rb"
expect(Kernel).not_to receive(:require).with(path)
......@@ -557,7 +556,7 @@ end
it "displays an error message" do
expect(capturing(:stdout) {
AnnotateModels.do_annotations :model_dir => @model_dir, :is_rake => true
}).to include("Unable to annotate user.rb: oops")
}).to include("Unable to annotate #{@model_dir}/user.rb: oops")
end
it "displays the full stack trace with --trace" do
......@@ -587,7 +586,7 @@ end
it "displays an error message" do
expect(capturing(:stdout) {
AnnotateModels.remove_annotations :model_dir => @model_dir, :is_rake => true
}).to include("Unable to deannotate user.rb: oops")
}).to include("Unable to deannotate #{@model_dir}/user.rb: oops")
end
it "displays the full stack trace" do
......
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