Skip to content

Commit

Permalink
update spec to support file with dir
Browse files Browse the repository at this point in the history
  • Loading branch information
capripot committed Jan 15, 2015
1 parent 41d13a2 commit b2fbd90
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions spec/annotate/annotate_models_spec.rb 100644 → 100755
Expand Up @@ -136,17 +136,16 @@ 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
file_path
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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b2fbd90

Please sign in to comment.