Skip to content

Commit a49c038

Browse files
committed
Support "test/models" (since rails 4.0) in addition to "test/unit", #182
1 parent d54e772 commit a49c038

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

lib/annotate/annotate_models.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module AnnotateModels
1010
# File.join for windows reverse bar compat?
1111
# I dont use windows, can`t test
1212
UNIT_TEST_DIR = File.join("test", "unit")
13+
MODEL_TEST_DIR = File.join("test", "models") # since rails 4.0
1314
SPEC_MODEL_DIR = File.join("spec", "models")
1415
FIXTURE_TEST_DIR = File.join("test", "fixtures")
1516
FIXTURE_SPEC_DIR = File.join("spec", "fixtures")
@@ -32,6 +33,7 @@ module AnnotateModels
3233

3334
TEST_PATTERNS = [
3435
File.join(UNIT_TEST_DIR, "%MODEL_NAME%_test.rb"),
36+
File.join(MODEL_TEST_DIR, "%MODEL_NAME%_test.rb"),
3537
File.join(SPEC_MODEL_DIR, "%MODEL_NAME%_spec.rb"),
3638
]
3739

spec/integration/common_validation.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def self.check_task_unittest(test_rig, annotation, place_before=true)
3838
File.read("test/unit/task_test.rb").should == unittest
3939
end
4040

41+
def self.check_task_modeltest(test_rig, annotation, place_before=true)
42+
unittest = apply_annotation(test_rig, "test/models/task_test.rb", annotation, place_before)
43+
File.read("test/models/task_test.rb").should == unittest
44+
end
45+
4146
def self.check_task_factory(test_rig, annotation, place_before=true)
4247
fixture = apply_annotation(test_rig, "test/factories/tasks.rb", annotation, place_before)
4348
File.read("test/factories/tasks.rb").should == fixture
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# == Schema Information
2+
#
3+
# Table name: tasks
4+
#
5+
# id :integer not null, primary key
6+
# content :string(255)
7+
# status :integer
8+
# created_at :datetime
9+
# updated_at :datetime
10+
#
11+
12+
require 'test_helper'
13+
14+
class TaskTest < ActiveSupport::TestCase
15+
# Replace this with your real tests.
16+
test "the truth" do
17+
assert true
18+
end
19+
end

0 commit comments

Comments
 (0)