Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
annotate
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
annotate
Commits
f89bbf2a
Commit
f89bbf2a
authored
Jun 10, 2015
by
Joshua Plicque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Annotate nested fixtures
parent
c479e5af
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
annotate_models.rb
lib/annotate/annotate_models.rb
+3
-0
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+29
-0
No files found.
lib/annotate/annotate_models.rb
View file @
f89bbf2a
...
...
@@ -48,6 +48,8 @@ module AnnotateModels
FIXTURE_PATTERNS
=
[
File
.
join
(
FIXTURE_TEST_DIR
,
"%TABLE_NAME%.yml"
),
File
.
join
(
FIXTURE_SPEC_DIR
,
"%TABLE_NAME%.yml"
),
File
.
join
(
FIXTURE_TEST_DIR
,
"%PLURALIZED_MODEL_NAME%.yml"
),
File
.
join
(
FIXTURE_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%.yml"
),
]
FACTORY_PATTERNS
=
[
...
...
@@ -527,6 +529,7 @@ module AnnotateModels
def
resolve_filename
(
filename_template
,
model_name
,
table_name
)
return
filename_template
.
gsub
(
'%MODEL_NAME%'
,
model_name
).
gsub
(
'%PLURALIZED_MODEL_NAME%'
,
model_name
.
pluralize
).
gsub
(
'%TABLE_NAME%'
,
table_name
||
model_name
.
pluralize
)
end
...
...
spec/annotate/annotate_models_spec.rb
View file @
f89bbf2a
...
...
@@ -435,6 +435,35 @@ end
end
end
describe
'#resolve_filename'
do
it
'should return the test path for a model'
do
filename_template
=
'test/unit/%MODEL_NAME%_test.rb'
model_name
=
'example_model'
table_name
=
'example_models'
filename
=
AnnotateModels
.
resolve_filename
(
filename_template
,
model_name
,
table_name
)
expect
(
filename
).
to
eq
'test/unit/example_model_test.rb'
end
it
'should return the fixture path for a model'
do
filename_template
=
'test/fixtures/%TABLE_NAME%.yml'
model_name
=
'example_model'
table_name
=
'example_models'
filename
=
AnnotateModels
.
resolve_filename
(
filename_template
,
model_name
,
table_name
)
expect
(
filename
).
to
eq
'test/fixtures/example_models.yml'
end
it
'should return the fixture path for a nested model'
do
filename_template
=
'test/fixtures/%PLURALIZED_MODEL_NAME%.yml'
model_name
=
'parent/child'
table_name
=
'parent_children'
filename
=
AnnotateModels
.
resolve_filename
(
filename_template
,
model_name
,
table_name
)
expect
(
filename
).
to
eq
'test/fixtures/parent/children.yml'
end
end
describe
"annotating a file"
do
before
do
@model_dir
=
Dir
.
mktmpdir
(
'annotate_models'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment