IPGlider-annotate 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+ require 'annotate/annotate_models'
3
+
4
+ describe AnnotateModels do
5
+
6
+ def mock_klass(stubs={})
7
+ @mock_file ||= mock("Klass", stubs)
8
+ end
9
+
10
+ def mock_column(stubs={})
11
+ @mock_column ||= mock("Column", stubs)
12
+ end
13
+
14
+ it { AnnotateModels.quote(nil).should eql("NULL") }
15
+ it { AnnotateModels.quote(true).should eql("TRUE") }
16
+ it { AnnotateModels.quote(false).should eql("FALSE") }
17
+ it { AnnotateModels.quote(25).should eql("25") }
18
+ it { AnnotateModels.quote(25.6).should eql("25.6") }
19
+ it { AnnotateModels.quote(1e-20).should eql("1.0e-20") }
20
+
21
+ it "should get schema info" do
22
+
23
+ AnnotateModels.get_schema_info(mock_klass(
24
+ :table_name => "users",
25
+ :primary_key => "id",
26
+ :column_names => ["id","login"],
27
+ :columns => [
28
+ mock_column(:type => "integer", :default => nil, :null => false, :name => "id", :limit => nil),
29
+ mock_column(:type => "string", :default => nil, :null => false, :name => "name", :limit => 50)
30
+ ]), "Hello").should eql("# Hello\n#\n# Table name: users\n#\n# id :integer not null, primary key\n# id :integer not null, primary key\n#\n\n")
31
+
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+ require 'annotate/annotate_routes'
3
+
4
+ describe AnnotateRoutes do
5
+
6
+ def mock_file(stubs={})
7
+ @mock_file ||= mock(File, stubs)
8
+ end
9
+
10
+ describe "Annotate Job" do
11
+
12
+ before(:each) do
13
+ File.should_receive(:join).with("config", "routes.rb").and_return("config/routes.rb")
14
+ end
15
+
16
+ it "should check if routes.rb exists" do
17
+ File.should_receive(:exists?).with("config/routes.rb").and_return(false)
18
+ AnnotateRoutes.should_receive(:puts).with("Can`t find routes.rb")
19
+ AnnotateRoutes.do_annotate
20
+ end
21
+
22
+ describe "When Annotating" do
23
+
24
+ before(:each) do
25
+ File.should_receive(:exists?).with("config/routes.rb").and_return(true)
26
+ AnnotateRoutes.should_receive(:`).with("rake routes").and_return("bad line\ngood line")
27
+ File.should_receive(:open).with("config/routes.rb", "wb").and_yield(mock_file)
28
+ AnnotateRoutes.should_receive(:puts).with("Route map annotated.")
29
+ end
30
+
31
+ it "should annotate and add a newline!" do
32
+ File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo")
33
+ @mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n#== Route Map\n# Generated on .*\n#\n# good line/)
34
+ AnnotateRoutes.do_annotate
35
+ end
36
+
37
+ it "should not add a newline if there are empty lines" do
38
+ File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo\n")
39
+ @mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n#== Route Map\n# Generated on .*\n#\n# good line/)
40
+ AnnotateRoutes.do_annotate
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe Annotate do
4
+
5
+ it "should have a version" do
6
+ Annotate::VERSION.should be_instance_of(String)
7
+ end
8
+
9
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'annotate'
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: IPGlider-annotate
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.2.6
5
+ platform: ruby
6
+ authors:
7
+ - Marcos Piccinini
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-14 00:00:00 -08:00
13
+ default_executable: annotate
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: newgem
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0
34
+ version:
35
+ description: Annotates Rails Models and Routes
36
+ email:
37
+ - x@nofxx.com
38
+ executables:
39
+ - annotate
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - History.txt
44
+ - License.txt
45
+ - Manifest.txt
46
+ - README.rdoc
47
+ files:
48
+ - History.txt
49
+ - License.txt
50
+ - Manifest.txt
51
+ - README.rdoc
52
+ - Rakefile
53
+ - annotate.gemspec
54
+ - bin/annotate
55
+ - lib/annotate.rb
56
+ - lib/annotate/annotate_models.rb
57
+ - lib/annotate/annotate_routes.rb
58
+ - lib/tasks/annotate_models.rake
59
+ - lib/tasks/annotate_routes.rake
60
+ - script/console
61
+ - script/destroy
62
+ - script/generate
63
+ - setup.rb
64
+ - spec/annotate/annotate_models_spec.rb
65
+ - spec/annotate/annotate_routes_spec.rb
66
+ - spec/annotate_spec.rb
67
+ - spec/spec.opts
68
+ - spec/spec_helper.rb
69
+ - tasks/rspec.rake
70
+ has_rdoc: true
71
+ homepage: http://github.com/nofxx/annotate
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --main
75
+ - README.rdoc
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project: annotate
93
+ rubygems_version: 1.2.0
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: Annotates Rails Models and Routes
97
+ test_files: []
98
+