From b2fbd90a359dbeb9516f7da11a8c46451eafea4f Mon Sep 17 00:00:00 2001 From: capripot Date: Wed, 14 Jan 2015 19:54:18 -0500 Subject: [PATCH] update spec to support file with dir --- spec/annotate/annotate_models_spec.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) mode change 100644 => 100755 spec/annotate/annotate_models_spec.rb diff --git a/spec/annotate/annotate_models_spec.rb b/spec/annotate/annotate_models_spec.rb old mode 100644 new mode 100755 index 27d228877..d21c1cf41 --- a/spec/annotate/annotate_models_spec.rb +++ b/spec/annotate/annotate_models_spec.rb @@ -136,9 +136,8 @@ def self.has_many name # 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 @@ def create(file, body="hi") 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 @@ class LoadedClass < ActiveRecord::Base 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 @@ class User < ActiveRecord::Base 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 @@ class User < ActiveRecord::Base 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