Skip to content

Commit

Permalink
Support "test/models" (since rails 4.0) in addition to "test/unit", #182
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-now committed May 26, 2014
1 parent d54e772 commit a49c038
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/annotate/annotate_models.rb
Expand Up @@ -10,6 +10,7 @@ module AnnotateModels
# File.join for windows reverse bar compat?
# I dont use windows, can`t test
UNIT_TEST_DIR = File.join("test", "unit")
MODEL_TEST_DIR = File.join("test", "models") # since rails 4.0
SPEC_MODEL_DIR = File.join("spec", "models")
FIXTURE_TEST_DIR = File.join("test", "fixtures")
FIXTURE_SPEC_DIR = File.join("spec", "fixtures")
Expand All @@ -32,6 +33,7 @@ module AnnotateModels

TEST_PATTERNS = [
File.join(UNIT_TEST_DIR, "%MODEL_NAME%_test.rb"),
File.join(MODEL_TEST_DIR, "%MODEL_NAME%_test.rb"),
File.join(SPEC_MODEL_DIR, "%MODEL_NAME%_spec.rb"),
]

Expand Down
5 changes: 5 additions & 0 deletions spec/integration/common_validation.rb
Expand Up @@ -38,6 +38,11 @@ def self.check_task_unittest(test_rig, annotation, place_before=true)
File.read("test/unit/task_test.rb").should == unittest
end

def self.check_task_modeltest(test_rig, annotation, place_before=true)
unittest = apply_annotation(test_rig, "test/models/task_test.rb", annotation, place_before)
File.read("test/models/task_test.rb").should == unittest
end

def self.check_task_factory(test_rig, annotation, place_before=true)
fixture = apply_annotation(test_rig, "test/factories/tasks.rb", annotation, place_before)
File.read("test/factories/tasks.rb").should == fixture
Expand Down
19 changes: 19 additions & 0 deletions spec/integration/rails_4.1.1/test/models/task_test.rb
@@ -0,0 +1,19 @@
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# content :string(255)
# status :integer
# created_at :datetime
# updated_at :datetime
#

require 'test_helper'

class TaskTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

0 comments on commit a49c038

Please sign in to comment.