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
eac9f453
Commit
eac9f453
authored
Feb 05, 2010
by
Scott Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a spec annotating a file
parent
57a04a40
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+23
-0
No files found.
spec/annotate/annotate_models_spec.rb
View file @
eac9f453
...
...
@@ -2,8 +2,11 @@ require File.dirname(__FILE__) + '/../spec_helper.rb'
require
'annotate/annotate_models'
require
'rubygems'
require
'activesupport'
require
'fakefs/spec_helpers'
describe
AnnotateModels
do
include
FakeFS
::
SpecHelpers
def
mock_class
(
table_name
,
primary_key
,
columns
)
options
=
{
:connection
=>
mock
(
"Conn"
,
:indexes
=>
[]),
...
...
@@ -93,4 +96,24 @@ EOS
end
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
,
[
mock_column
(
:id
,
:integer
),
mock_column
(
:name
,
:string
,
:limit
=>
50
)
])
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
"
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