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
fba0ca0a
Commit
fba0ca0a
authored
Aug 22, 2012
by
Jon Frisby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement namespaced models test.
parent
3689d9db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
CHANGELOG.rdoc
CHANGELOG.rdoc
+1
-0
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+19
-5
No files found.
CHANGELOG.rdoc
View file @
fba0ca0a
...
...
@@ -54,6 +54,7 @@
non-standard capitalization.
Note that this still requires that the inflector be configured to understand
the special case.
* Shore up test cases a bit.
* Merge against many of the older branches on Github whose functionality is
already reflected to reduce confusion about what is and is not implemented
here.
...
...
spec/annotate/annotate_models_spec.rb
View file @
fba0ca0a
...
...
@@ -295,7 +295,7 @@ end
describe
"annotating a file"
do
before
do
@model_dir
=
Dir
.
mktmpdir
(
'annotate_models'
)
write_model
"user.rb"
,
<<-
EOS
(
@model_file_name
,
@file_content
)
=
write_model
"user.rb"
,
<<-
EOS
class User < ActiveRecord::Base
end
EOS
...
...
@@ -308,9 +308,10 @@ end
end
def
write_model
file_name
,
file_content
@model_file_name
=
File
.
join
(
@model_dir
,
file_name
)
@file_content
=
file_content
File
.
open
(
@model_file_name
,
"wb"
)
{
|
f
|
f
.
write
@file_content
}
fname
=
File
.
join
(
@model_dir
,
file_name
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
fname
))
File
.
open
(
fname
,
"wb"
)
{
|
f
|
f
.
write
file_content
}
return
fname
,
file_content
end
def
annotate_one_file
options
=
{}
...
...
@@ -344,7 +345,20 @@ end
File
.
read
(
@model_file_name
).
should
==
"
#{
@file_content
}
\n
#{
another_schema_info
}
"
end
it
"works with namepaced models (i.e. models inside modules/subdirectories"
it
"works with namespaced models (i.e. models inside modules/subdirectories)"
do
(
model_file_name
,
file_content
)
=
write_model
"foo/user.rb"
,
<<-
EOS
class Foo::User < ActiveRecord::Base
end
EOS
klass
=
mock_class
(
:'foo_users'
,
:id
,
[
mock_column
(
:id
,
:integer
),
mock_column
(
:name
,
:string
,
:limit
=>
50
)
])
schema_info
=
AnnotateModels
.
get_schema_info
(
klass
,
"== Schema Info"
)
AnnotateModels
.
annotate_one_file
(
model_file_name
,
schema_info
,
:position
=>
:before
)
File
.
read
(
model_file_name
).
should
==
"
#{
schema_info
}#{
file_content
}
"
end
describe
"if a file can't be annotated"
do
before
do
...
...
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