Commit b2fbd90a by capripot

update spec to support file with dir

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