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
02f07cef
Commit
02f07cef
authored
Feb 05, 2010
by
Scott Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor specs
parent
f50b4cca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
24 deletions
+19
-24
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+19
-24
No files found.
spec/annotate/annotate_models_spec.rb
View file @
02f07cef
...
...
@@ -97,42 +97,37 @@ EOS
end
describe
"annotating a file"
do
it
"should annotate the file before the model if position == 'before'"
do
file_content
=
"class User < ActiveRecord::Base; end"
File
.
open
(
"user.rb"
,
"w"
)
do
|
f
|
f
<<
file_content
end
klass
=
mock_class
(
:users
,
:id
,
[
before
do
@file_name
=
"user.rb"
@file_content
=
"class User < ActiveRecord::Base; end"
@klass
=
mock_class
(
:users
,
:id
,
[
mock_column
(
:id
,
:integer
),
mock_column
(
:name
,
:string
,
:limit
=>
50
)
])
end
schema_info
=
AnnotateModels
.
get_schema_info
(
klass
,
"Schema Info"
)
def
write_file
File
.
open
(
"user.rb"
,
"w"
)
do
|
f
|
f
<<
@file_content
end
end
it
"should annotate the file before the model if position == 'before'"
do
write_file
schema_info
=
AnnotateModels
.
get_schema_info
(
@klass
,
"Schema Info"
)
AnnotateModels
.
annotate_one_file
(
"user.rb"
,
schema_info
,
{
:position
=>
"before"
})
File
.
read
(
"user.rb"
).
should
==
"
#{
schema_info
}#{
file_content
}
\n
"
File
.
read
(
"user.rb"
).
should
==
"
#{
schema_info
}#{
@
file_content
}
\n
"
end
it
"should annotate before if given :position => :before"
do
file_content
=
"class User < ActiveRecord::Base; end"
File
.
open
(
"user.rb"
,
"w"
)
do
|
f
|
f
<<
file_content
end
klass
=
mock_class
(
:users
,
:id
,
[
mock_column
(
:id
,
:integer
),
mock_column
(
:name
,
:string
,
:limit
=>
50
)
])
schema_info
=
AnnotateModels
.
get_schema_info
(
klass
,
"Schema Info"
)
write_file
schema_info
=
AnnotateModels
.
get_schema_info
(
@klass
,
"Schema Info"
)
AnnotateModels
.
annotate_one_file
(
"user.rb"
,
schema_info
,
{
:position
=>
:before
})
AnnotateModels
.
annotate_one_file
(
@file_name
,
schema_info
,
{
:position
=>
:before
})
File
.
read
(
"user.rb"
).
should
==
"
#{
schema_info
}#{
file_content
}
\n
"
File
.
read
(
"user.rb"
).
should
==
"
#{
schema_info
}#{
@
file_content
}
\n
"
end
end
end
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