Commit a49c0387 by cuong.tran

Support "test/models" (since rails 4.0) in addition to "test/unit", #182

parent d54e772a
...@@ -10,6 +10,7 @@ module AnnotateModels ...@@ -10,6 +10,7 @@ module AnnotateModels
# File.join for windows reverse bar compat? # File.join for windows reverse bar compat?
# I dont use windows, can`t test # I dont use windows, can`t test
UNIT_TEST_DIR = File.join("test", "unit") 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") SPEC_MODEL_DIR = File.join("spec", "models")
FIXTURE_TEST_DIR = File.join("test", "fixtures") FIXTURE_TEST_DIR = File.join("test", "fixtures")
FIXTURE_SPEC_DIR = File.join("spec", "fixtures") FIXTURE_SPEC_DIR = File.join("spec", "fixtures")
...@@ -32,6 +33,7 @@ module AnnotateModels ...@@ -32,6 +33,7 @@ module AnnotateModels
TEST_PATTERNS = [ TEST_PATTERNS = [
File.join(UNIT_TEST_DIR, "%MODEL_NAME%_test.rb"), 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"), File.join(SPEC_MODEL_DIR, "%MODEL_NAME%_spec.rb"),
] ]
......
...@@ -38,6 +38,11 @@ module Annotate ...@@ -38,6 +38,11 @@ module Annotate
File.read("test/unit/task_test.rb").should == unittest File.read("test/unit/task_test.rb").should == unittest
end 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) def self.check_task_factory(test_rig, annotation, place_before=true)
fixture = apply_annotation(test_rig, "test/factories/tasks.rb", annotation, place_before) fixture = apply_annotation(test_rig, "test/factories/tasks.rb", annotation, place_before)
File.read("test/factories/tasks.rb").should == fixture File.read("test/factories/tasks.rb").should == fixture
......
# == 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
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