rails_artifactor 0.3.3

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.
Files changed (78) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/DESIGN_NOTES.textile +33 -0
  4. data/Gemfile +18 -0
  5. data/LICENSE +20 -0
  6. data/README.markdown +71 -0
  7. data/Rakefile +53 -0
  8. data/VERSION +1 -0
  9. data/lib/rails_artifactor/artifact/base.rb +59 -0
  10. data/lib/rails_artifactor/artifact/crud/create.rb +12 -0
  11. data/lib/rails_artifactor/artifact/crud/delete.rb +34 -0
  12. data/lib/rails_artifactor/artifact/crud/read.rb +47 -0
  13. data/lib/rails_artifactor/artifact/crud/update.rb +25 -0
  14. data/lib/rails_artifactor/artifact/crud.rb +32 -0
  15. data/lib/rails_artifactor/artifact/file_name/artifacts.rb +21 -0
  16. data/lib/rails_artifactor/artifact/file_name/migration.rb +54 -0
  17. data/lib/rails_artifactor/artifact/file_name/view.rb +172 -0
  18. data/lib/rails_artifactor/artifact/markers.rb +73 -0
  19. data/lib/rails_artifactor/artifact/migration.rb +11 -0
  20. data/lib/rails_artifactor/artifact/orm/active_record.rb +14 -0
  21. data/lib/rails_artifactor/artifact/orm/data_mapper.rb +22 -0
  22. data/lib/rails_artifactor/artifact/orm/mongo_mapper.rb +18 -0
  23. data/lib/rails_artifactor/artifact/orm/mongoid.rb +23 -0
  24. data/lib/rails_artifactor/artifact/orm/none.rb +16 -0
  25. data/lib/rails_artifactor/artifact/orm.rb +55 -0
  26. data/lib/rails_artifactor/artifact/view_artifact.rb +94 -0
  27. data/lib/rails_artifactor/artifact.rb +1 -0
  28. data/lib/rails_artifactor/base/crud/create.rb +62 -0
  29. data/lib/rails_artifactor/base/crud/delete.rb +35 -0
  30. data/lib/rails_artifactor/base/crud/read.rb +13 -0
  31. data/lib/rails_artifactor/base/crud/update.rb +66 -0
  32. data/lib/rails_artifactor/base/crud.rb +6 -0
  33. data/lib/rails_artifactor/base/file_name.rb +41 -0
  34. data/lib/rails_artifactor/base.rb +1 -0
  35. data/lib/rails_artifactor/macro.rb +2 -0
  36. data/lib/rails_artifactor/namespaces.rb +10 -0
  37. data/lib/rails_artifactor/rspec/configure.rb +7 -0
  38. data/lib/rails_artifactor/rspec.rb +1 -0
  39. data/lib/rails_artifactor/ruby_mutator.rb +11 -0
  40. data/lib/rails_artifactor/template_language/base.rb +14 -0
  41. data/lib/rails_artifactor/template_language/erb.rb +24 -0
  42. data/lib/rails_artifactor/template_language/haml.rb +32 -0
  43. data/lib/rails_artifactor/template_language/slim.rb +15 -0
  44. data/lib/rails_artifactor.rb +12 -0
  45. data/rails_artifactor.gemspec +163 -0
  46. data/spec/fixtures/app/views/account/edit.erb.html +3 -0
  47. data/spec/fixtures/app/views/account/edit.html.erb +3 -0
  48. data/spec/fixtures/app/views/layouts/application.erb.html +3 -0
  49. data/spec/fixtures/app/views/layouts/application.html.erb +16 -0
  50. data/spec/fixtures.rb +3 -0
  51. data/spec/rails_artifactor/artifact/base_spec.rb +17 -0
  52. data/spec/rails_artifactor/artifact/crud/controller_spec.rb +65 -0
  53. data/spec/rails_artifactor/artifact/crud/helper_spec.rb +64 -0
  54. data/spec/rails_artifactor/artifact/crud/mailer_spec.rb +62 -0
  55. data/spec/rails_artifactor/artifact/crud/migration_spec.rb +86 -0
  56. data/spec/rails_artifactor/artifact/crud/model_active_record_spec.rb +68 -0
  57. data/spec/rails_artifactor/artifact/crud/model_spec.rb +68 -0
  58. data/spec/rails_artifactor/artifact/crud/observer_spec.rb +65 -0
  59. data/spec/rails_artifactor/artifact/crud/permit_spec.rb +71 -0
  60. data/spec/rails_artifactor/artifact/crud/view_controller_action_spec.rb +92 -0
  61. data/spec/rails_artifactor/artifact/crud/view_file_spec.rb +31 -0
  62. data/spec/rails_artifactor/artifact/file_name/artifacts_spec.rb +33 -0
  63. data/spec/rails_artifactor/artifact/file_name/migration_spec.rb +32 -0
  64. data/spec/rails_artifactor/artifact/file_name/view_spec.rb +38 -0
  65. data/spec/rails_artifactor/artifact/markers_spec.rb +93 -0
  66. data/spec/rails_artifactor/artifact/migration_spec.rb +0 -0
  67. data/spec/rails_artifactor/artifact/orm/active_record_spec.rb +37 -0
  68. data/spec/rails_artifactor/artifact/orm/data_mapper_spec.rb +37 -0
  69. data/spec/rails_artifactor/artifact/orm/mongo_mapper_spec.rb +67 -0
  70. data/spec/rails_artifactor/artifact/orm/mongoid_spec.rb +67 -0
  71. data/spec/rails_artifactor/artifact/orm/none_spec.rb +36 -0
  72. data/spec/rails_artifactor/base/crud/create_spec.rb +31 -0
  73. data/spec/rails_artifactor/base/crud/delete_spec.rb +49 -0
  74. data/spec/rails_artifactor/base/crud/read_spec.rb +80 -0
  75. data/spec/rails_artifactor/base/crud/update_spec.rb +74 -0
  76. data/spec/rails_artifactor/base/file_name_spec.rb +23 -0
  77. data/spec/spec_helper.rb +9 -0
  78. metadata +234 -0
@@ -0,0 +1,15 @@
1
+ module RailsAssist
2
+ module TemplateLanguage
3
+ class Slim < Base
4
+ def insert_ruby_statement statement, options = {}
5
+ "\n= #{statement}"
6
+ end
7
+
8
+ def insert_ruby_block statement, options = {}, &block
9
+ end
10
+
11
+ def insert_tag tag, css, options= {}, &block
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ require 'require_all'
2
+ require 'sugar-high/file'
3
+ require 'sugar-high/alias'
4
+ require 'sugar-high/regexp'
5
+ require 'sugar-high/module'
6
+
7
+ require 'rails_artifactor/namespaces'
8
+ require 'rails_artifactor/artifact/base'
9
+ require 'rails_artifactor/artifact/markers'
10
+ require 'rails_artifactor/base'
11
+ require 'rails_artifactor/artifact'
12
+ require 'rails_artifactor/macro'
@@ -0,0 +1,163 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rails_artifactor}
8
+ s.version = "0.3.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kristian Mandrup"]
12
+ s.date = %q{2011-03-04}
13
+ s.description = %q{Helpers for handling Rails 3 artifacts in general, such as CRUD operations etc.}
14
+ s.email = %q{kmandrup@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.markdown"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "DESIGN_NOTES.textile",
23
+ "Gemfile",
24
+ "LICENSE",
25
+ "README.markdown",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/rails_artifactor.rb",
29
+ "lib/rails_artifactor/artifact.rb",
30
+ "lib/rails_artifactor/artifact/base.rb",
31
+ "lib/rails_artifactor/artifact/crud.rb",
32
+ "lib/rails_artifactor/artifact/crud/create.rb",
33
+ "lib/rails_artifactor/artifact/crud/delete.rb",
34
+ "lib/rails_artifactor/artifact/crud/read.rb",
35
+ "lib/rails_artifactor/artifact/crud/update.rb",
36
+ "lib/rails_artifactor/artifact/file_name/artifacts.rb",
37
+ "lib/rails_artifactor/artifact/file_name/migration.rb",
38
+ "lib/rails_artifactor/artifact/file_name/view.rb",
39
+ "lib/rails_artifactor/artifact/markers.rb",
40
+ "lib/rails_artifactor/artifact/migration.rb",
41
+ "lib/rails_artifactor/artifact/orm.rb",
42
+ "lib/rails_artifactor/artifact/orm/active_record.rb",
43
+ "lib/rails_artifactor/artifact/orm/data_mapper.rb",
44
+ "lib/rails_artifactor/artifact/orm/mongo_mapper.rb",
45
+ "lib/rails_artifactor/artifact/orm/mongoid.rb",
46
+ "lib/rails_artifactor/artifact/orm/none.rb",
47
+ "lib/rails_artifactor/artifact/view_artifact.rb",
48
+ "lib/rails_artifactor/base.rb",
49
+ "lib/rails_artifactor/base/crud.rb",
50
+ "lib/rails_artifactor/base/crud/create.rb",
51
+ "lib/rails_artifactor/base/crud/delete.rb",
52
+ "lib/rails_artifactor/base/crud/read.rb",
53
+ "lib/rails_artifactor/base/crud/update.rb",
54
+ "lib/rails_artifactor/base/file_name.rb",
55
+ "lib/rails_artifactor/macro.rb",
56
+ "lib/rails_artifactor/namespaces.rb",
57
+ "lib/rails_artifactor/rspec.rb",
58
+ "lib/rails_artifactor/rspec/configure.rb",
59
+ "lib/rails_artifactor/ruby_mutator.rb",
60
+ "lib/rails_artifactor/template_language/base.rb",
61
+ "lib/rails_artifactor/template_language/erb.rb",
62
+ "lib/rails_artifactor/template_language/haml.rb",
63
+ "lib/rails_artifactor/template_language/slim.rb",
64
+ "rails_artifactor.gemspec",
65
+ "spec/fixtures.rb",
66
+ "spec/fixtures/app/views/account/edit.erb.html",
67
+ "spec/fixtures/app/views/account/edit.html.erb",
68
+ "spec/fixtures/app/views/layouts/application.erb.html",
69
+ "spec/fixtures/app/views/layouts/application.html.erb",
70
+ "spec/rails_artifactor/artifact/base_spec.rb",
71
+ "spec/rails_artifactor/artifact/crud/controller_spec.rb",
72
+ "spec/rails_artifactor/artifact/crud/helper_spec.rb",
73
+ "spec/rails_artifactor/artifact/crud/mailer_spec.rb",
74
+ "spec/rails_artifactor/artifact/crud/migration_spec.rb",
75
+ "spec/rails_artifactor/artifact/crud/model_active_record_spec.rb",
76
+ "spec/rails_artifactor/artifact/crud/model_spec.rb",
77
+ "spec/rails_artifactor/artifact/crud/observer_spec.rb",
78
+ "spec/rails_artifactor/artifact/crud/permit_spec.rb",
79
+ "spec/rails_artifactor/artifact/crud/view_controller_action_spec.rb",
80
+ "spec/rails_artifactor/artifact/crud/view_file_spec.rb",
81
+ "spec/rails_artifactor/artifact/file_name/artifacts_spec.rb",
82
+ "spec/rails_artifactor/artifact/file_name/migration_spec.rb",
83
+ "spec/rails_artifactor/artifact/file_name/view_spec.rb",
84
+ "spec/rails_artifactor/artifact/markers_spec.rb",
85
+ "spec/rails_artifactor/artifact/migration_spec.rb",
86
+ "spec/rails_artifactor/artifact/orm/active_record_spec.rb",
87
+ "spec/rails_artifactor/artifact/orm/data_mapper_spec.rb",
88
+ "spec/rails_artifactor/artifact/orm/mongo_mapper_spec.rb",
89
+ "spec/rails_artifactor/artifact/orm/mongoid_spec.rb",
90
+ "spec/rails_artifactor/artifact/orm/none_spec.rb",
91
+ "spec/rails_artifactor/base/crud/create_spec.rb",
92
+ "spec/rails_artifactor/base/crud/delete_spec.rb",
93
+ "spec/rails_artifactor/base/crud/read_spec.rb",
94
+ "spec/rails_artifactor/base/crud/update_spec.rb",
95
+ "spec/rails_artifactor/base/file_name_spec.rb",
96
+ "spec/spec_helper.rb"
97
+ ]
98
+ s.homepage = %q{http://github.com/kristianmandrup/rails_artifactor}
99
+ s.require_paths = ["lib"]
100
+ s.rubygems_version = %q{1.6.1}
101
+ s.summary = %q{Helpers for handling Rails 3 artifacts}
102
+ s.test_files = [
103
+ "spec/fixtures.rb",
104
+ "spec/rails_artifactor/artifact/base_spec.rb",
105
+ "spec/rails_artifactor/artifact/crud/controller_spec.rb",
106
+ "spec/rails_artifactor/artifact/crud/helper_spec.rb",
107
+ "spec/rails_artifactor/artifact/crud/mailer_spec.rb",
108
+ "spec/rails_artifactor/artifact/crud/migration_spec.rb",
109
+ "spec/rails_artifactor/artifact/crud/model_active_record_spec.rb",
110
+ "spec/rails_artifactor/artifact/crud/model_spec.rb",
111
+ "spec/rails_artifactor/artifact/crud/observer_spec.rb",
112
+ "spec/rails_artifactor/artifact/crud/permit_spec.rb",
113
+ "spec/rails_artifactor/artifact/crud/view_controller_action_spec.rb",
114
+ "spec/rails_artifactor/artifact/crud/view_file_spec.rb",
115
+ "spec/rails_artifactor/artifact/file_name/artifacts_spec.rb",
116
+ "spec/rails_artifactor/artifact/file_name/migration_spec.rb",
117
+ "spec/rails_artifactor/artifact/file_name/view_spec.rb",
118
+ "spec/rails_artifactor/artifact/markers_spec.rb",
119
+ "spec/rails_artifactor/artifact/migration_spec.rb",
120
+ "spec/rails_artifactor/artifact/orm/active_record_spec.rb",
121
+ "spec/rails_artifactor/artifact/orm/data_mapper_spec.rb",
122
+ "spec/rails_artifactor/artifact/orm/mongo_mapper_spec.rb",
123
+ "spec/rails_artifactor/artifact/orm/mongoid_spec.rb",
124
+ "spec/rails_artifactor/artifact/orm/none_spec.rb",
125
+ "spec/rails_artifactor/base/crud/create_spec.rb",
126
+ "spec/rails_artifactor/base/crud/delete_spec.rb",
127
+ "spec/rails_artifactor/base/crud/read_spec.rb",
128
+ "spec/rails_artifactor/base/crud/update_spec.rb",
129
+ "spec/rails_artifactor/base/file_name_spec.rb",
130
+ "spec/spec_helper.rb"
131
+ ]
132
+
133
+ if s.respond_to? :specification_version then
134
+ s.specification_version = 3
135
+
136
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
137
+ s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
138
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
139
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
140
+ s.add_development_dependency(%q<rcov>, [">= 0"])
141
+ s.add_development_dependency(%q<generator-spec>, [">= 0.7.3"])
142
+ s.add_runtime_dependency(%q<sugar-high>, ["~> 0.4.0"])
143
+ s.add_runtime_dependency(%q<rails_assist>, ["~> 0.4.1"])
144
+ else
145
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
146
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
147
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
148
+ s.add_dependency(%q<rcov>, [">= 0"])
149
+ s.add_dependency(%q<generator-spec>, [">= 0.7.3"])
150
+ s.add_dependency(%q<sugar-high>, ["~> 0.4.0"])
151
+ s.add_dependency(%q<rails_assist>, ["~> 0.4.1"])
152
+ end
153
+ else
154
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
155
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
156
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
157
+ s.add_dependency(%q<rcov>, [">= 0"])
158
+ s.add_dependency(%q<generator-spec>, [">= 0.7.3"])
159
+ s.add_dependency(%q<sugar-high>, ["~> 0.4.0"])
160
+ s.add_dependency(%q<rails_assist>, ["~> 0.4.1"])
161
+ end
162
+ end
163
+
@@ -0,0 +1,3 @@
1
+
2
+ <h1><%= title %></h1>
3
+
@@ -0,0 +1,3 @@
1
+
2
+ <h1><%= title %></h1>
3
+
@@ -0,0 +1,3 @@
1
+
2
+ app layout
3
+
@@ -0,0 +1,16 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>App Layout</title>
6
+ <%= stylesheet_link_tag :all %>
7
+ <%= javascript_include_tag :defaults %>
8
+ <%= csrf_meta_tag %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
16
+
data/spec/fixtures.rb ADDED
@@ -0,0 +1,3 @@
1
+ def fixtures_dir
2
+ File.dirname(__FILE__) + '/fixtures'
3
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ class Helper
4
+ include RailsAssist::BaseHelper
5
+ end
6
+
7
+ describe 'BaseHelper' do
8
+ describe '#marker_option' do
9
+
10
+ it "should return marker option" do
11
+ helper = Helper.new
12
+ helper.stubs(:model_marker).returns 'Account'
13
+ res = helper.send :marker_option, :account, :type => :model
14
+ res[:after].should == 'Account'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'controller' do
4
+ use_helpers :controller
5
+
6
+ before :each do
7
+ RailsAssist::Directory.rails_root = fixtures_dir
8
+
9
+ remove_controller :account # if has_controller? :account
10
+ create_controller :account do
11
+ %q{
12
+ def index
13
+ end
14
+ }
15
+ end
16
+ end
17
+
18
+ after :each do
19
+ remove_controller :account
20
+ end
21
+
22
+ context "Non-existant controller(s)" do
23
+ it "should not fail trying to remove non-existant controllers" do
24
+ remove_controllers :person, :user
25
+ remove_artifacts :controller, :person, :user
26
+
27
+ remove_controller :person
28
+ remove_artifact :controller, :person
29
+
30
+ end
31
+
32
+ it "should not find a non-existant controller" do
33
+ controller_file :person do |person|
34
+ fail "should not find person controller!"
35
+ end
36
+
37
+ has_controller?(:person).should be_false
38
+ has_controllers?(:person, :user).should be_false
39
+ end
40
+
41
+ it "should not insert into non-existant controller" do
42
+ insert_into_controller(:person, :after => 'Hello', :content => 'Yes').should_not be_true
43
+ end
44
+
45
+ it "should not read from non-existant controller" do
46
+ read_controller :person do |content|
47
+ fail "should not find person content!"
48
+ end.should_not be_true
49
+ end
50
+ end
51
+
52
+ it "should have an account_controller file that contains an index method and two inserted comments" do
53
+ insert_into_controller :account, :content => '# hello'
54
+ insert_into_controller :account do
55
+ '# goodbye'
56
+ end
57
+ read_controller(:account).should have_comment 'hello'
58
+ puts read_controller(:account)
59
+ # root_dir.should have_controller :account do |controller_file|
60
+ # controller_file.should have_method :index
61
+ # controller_file.should have_comment 'hello'
62
+ # controller_file.should have_comment 'goodbye'
63
+ # end
64
+ end
65
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'helper' do
4
+ use_helpers :helper
5
+
6
+ before :each do
7
+ RailsAssist::Directory.rails_root = fixtures_dir
8
+
9
+ remove_helper :account
10
+ create_helper :account do
11
+ %q{
12
+ def index
13
+ end
14
+ }
15
+ end
16
+ end
17
+
18
+ after :each do
19
+ remove_helper :account
20
+ end
21
+
22
+ context "Non-existant helper(s)" do
23
+ it "should not fail trying to remove non-existant helpers" do
24
+ remove_helpers :person, :user
25
+ remove_artifacts :helper, :person, :user
26
+
27
+ remove_helper :person
28
+ remove_artifact :helper, :person
29
+ end
30
+
31
+ it "should not find a non-existant helper" do
32
+ helper_file :person do |person|
33
+ fail "should not find person helper!"
34
+ end
35
+
36
+ has_helper?(:person).should be_false
37
+ has_helpers?(:person, :user).should be_false
38
+ end
39
+
40
+ it "should not insert into non-existant helper" do
41
+ insert_into_helper(:person, :after => 'Hello', :content => 'Yes').should_not be_true
42
+ end
43
+
44
+ it "should not read from non-existant helper" do
45
+ read_helper :person do |content|
46
+ fail "should not find person content!"
47
+ end.should_not be_true
48
+ end
49
+ end
50
+
51
+ it "should have an account_helper file that contains an index method and two inserted comments" do
52
+ insert_into_helper :account, :content => '# hello'
53
+ insert_into_helper :account do
54
+ '# goodbye'
55
+ end
56
+ read_helper(:account).should have_comment 'hello'
57
+ # puts read_helper(:account)
58
+ # root_dir.should have_helper :account do |helper_file|
59
+ # helper_file.should have_method :index
60
+ # helper_file.should have_comment 'hello'
61
+ # helper_file.should have_comment 'goodbye'
62
+ # end
63
+ end
64
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'mailer' do
4
+ use_helpers :mailer
5
+
6
+ before :each do
7
+ RailsAssist::Directory.rails_root = fixtures_dir
8
+
9
+ remove_mailer :account if has_mailer? :account
10
+ create_mailer :account do
11
+ %q{ def mail_it
12
+ end}
13
+ end
14
+ end
15
+
16
+ after :each do
17
+ remove_mailer :account
18
+ end
19
+
20
+ context "Non-existant mailer(s)" do
21
+ it "should not fail trying to remove non-existant mailers" do
22
+ remove_mailers :person, :user
23
+ remove_artifacts :mailer, :person, :user
24
+
25
+ remove_mailer :person
26
+ remove_artifact :mailer, :person
27
+ end
28
+
29
+ it "should not find a non-existant mailer" do
30
+ mailer_file :person do |person|
31
+ fail "should not find person mailer!"
32
+ end
33
+
34
+ has_mailer?(:person).should be_false
35
+ has_mailers?(:person, :user).should be_false
36
+ end
37
+
38
+ it "should not insert into non-existant mailer" do
39
+ insert_into_mailer(:person, :after => 'Hello', :content => 'Yes').should_not be_true
40
+ end
41
+
42
+ it "should not read from non-existant mailer" do
43
+ read_mailer :person do |content|
44
+ fail "should not find person content!"
45
+ end.should_not be_true
46
+ end
47
+ end
48
+
49
+ it "should have an account_mailer file that contains a #mail_it method and two inserted comments" do
50
+ insert_into_mailer :account, :content => '# hello'
51
+ insert_into_mailer :account do
52
+ '# goodbye'
53
+ end
54
+ read_mailer(:account).should have_comment 'hello'
55
+ puts read_mailer(:account)
56
+ # root_dir.should have_mailer :account do |mailer_file|
57
+ # mailer_file.should have_method :index
58
+ # mailer_file.should have_comment 'hello'
59
+ # mailer_file.should have_comment 'goodbye'
60
+ # end
61
+ end
62
+ end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+ # require 'generator-spec'
3
+
4
+ Rails3::Migration::Assist.orm = :active_record
5
+
6
+ describe 'migration' do
7
+ use_orm :active_record
8
+ use_helpers :migration
9
+
10
+ before :each do
11
+ @root_dir = RailsAssist::Directory.rails_root = fixtures_dir
12
+
13
+ remove_migration :create_account if has_migration? :create_account
14
+
15
+ create_migration :create_account do
16
+ %q{
17
+ def self.up
18
+ end
19
+
20
+ def self.down
21
+ end
22
+ }
23
+ end
24
+ end
25
+
26
+ after :each do
27
+ remove_migration :create_account
28
+ end
29
+
30
+ context "Migration not there" do
31
+ it "should not fail trying to remove non-existant migrations" do
32
+ remove_migrations :person, :user
33
+ remove_artifacts :migration, :person, :user
34
+
35
+ remove_migration :person
36
+ remove_artifact :migration, :person
37
+ end
38
+
39
+ it "should not find a non-existant migration" do
40
+ migration_file :person do |person|
41
+ fail "should not find person migration!"
42
+ end
43
+
44
+ has_migration?(:person).should be_false
45
+ has_migrations?(:person, :user).should be_false
46
+ end
47
+
48
+ it "should not insert into non-existant migration" do
49
+ insert_into_migration(:person, :after => 'Hello', :content => 'Yes').should_not be_true
50
+ end
51
+
52
+ it "should not read from non-existant migration" do
53
+ read_migration :person do |content|
54
+ fail "should not find person content!"
55
+ end.should_not be_true
56
+ end
57
+ end
58
+
59
+ context "When migration does exist" do
60
+ before do
61
+ insert_into_migration :create_account, :content => '# hello'
62
+ insert_into_migration :create_account do
63
+ '# goodbye'
64
+ end
65
+ end
66
+
67
+ it "should have an :create_account migration file that contains an index method and two inserted comments" do
68
+ nil.should have_migration :create_account
69
+
70
+ read_migration(:create_account).should have_comment 'hello'
71
+ read_migration(:create_account).should match /ActiveRecord::Migration/
72
+ end
73
+
74
+ it "should not have migration blip" do
75
+ lambda {existing_migration_file :blip}.should raise_error
76
+ end
77
+
78
+ it "shoud have migraion a :create_account migration with basic setup" do
79
+ nil.should have_migration :create_account do |migration_file|
80
+ migration_file.should have_class_method :up
81
+ migration_file.should have_comment 'hello'
82
+ migration_file.should have_comment 'goodbye'
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'model without orm' do
4
+ use_orm :active_record
5
+
6
+ before :each do
7
+ RailsAssist::Directory.rails_root = fixtures_dir
8
+
9
+ delete_model(:account) # if has_model? :account
10
+ create_model :account do
11
+ %q{def index
12
+ end}
13
+ end
14
+ end
15
+
16
+ after :each do
17
+ remove_model :account
18
+ end
19
+
20
+ context "Non-existant model(s)" do
21
+ it "should not fail trying to remove non-existant models" do
22
+ remove_models :person, :user
23
+ remove_artifacts :model, :person, :user
24
+
25
+ remove_model :person
26
+ remove_artifact :model, :person
27
+ end
28
+
29
+ it "should not find a non-existant model" do
30
+ model_file :person do |person|
31
+ fail "should not find person model!"
32
+ end
33
+
34
+ has_model?(:person).should be_false
35
+ has_models?(:person, :user).should be_false
36
+ end
37
+
38
+ it "should not insert into non-existant model" do
39
+ insert_into_model(:person, :after => 'Hello', :content => 'Yes').should_not be_true
40
+ end
41
+
42
+ it "should not read from non-existant model" do
43
+ read_model :person do |content|
44
+ fail "should not find person content!"
45
+ end.should_not be_true
46
+ end
47
+ end
48
+
49
+ it 'should have #index method in :account model' do
50
+ read_model(:account).should have_method :index
51
+ end
52
+
53
+ it "should have an account_model file that contains an index method and two inserted comments" do
54
+ insert_into_model :account, :content => '# hello'
55
+ insert_into_model :account do
56
+ '# goodbye'
57
+ end
58
+ puts read_model(:account)
59
+ read_model(:account).should have_comment 'hello'
60
+
61
+ # root_dir.should have_model :account do |model_file|
62
+ # model_file.should have_method :index
63
+ # model_file.should have_comment 'hello'
64
+ # model_file.should have_comment 'goodbye'
65
+ # end
66
+ end
67
+ end
68
+
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'model without orm' do
4
+ use_orm :none
5
+
6
+ before :each do
7
+ RailsAssist::Directory.rails_root = fixtures_dir
8
+
9
+ delete_model(:account) # if has_model? :account
10
+ create_model :account do
11
+ %q{def index
12
+ end}
13
+ end
14
+ end
15
+
16
+ after :each do
17
+ remove_model :account
18
+ end
19
+
20
+ context "Non-existant model(s)" do
21
+ it "should not fail trying to remove non-existant models" do
22
+ remove_models :person, :user
23
+ remove_artifacts :model, :person, :user
24
+
25
+ remove_model :person
26
+ remove_artifact :model, :person
27
+ end
28
+
29
+ it "should not find a non-existant model" do
30
+ model_file :person do |person|
31
+ fail "should not find person model!"
32
+ end
33
+
34
+ has_model?(:person).should be_false
35
+ has_models?(:person, :user).should be_false
36
+ end
37
+
38
+ it "should not insert into non-existant model" do
39
+ insert_into_model(:person, :after => 'Hello', :content => 'Yes').should_not be_true
40
+ end
41
+
42
+ it "should not read from non-existant model" do
43
+ read_model :person do |content|
44
+ fail "should not find person content!"
45
+ end.should_not be_true
46
+ end
47
+ end
48
+
49
+ it 'should have #index method in :account model' do
50
+ read_model(:account).should have_method :index
51
+ end
52
+
53
+ it "should have an account_model file that contains an index method and two inserted comments" do
54
+ insert_into_model :account, :content => '# hello'
55
+ insert_into_model :account do
56
+ '# goodbye'
57
+ end
58
+ puts read_model(:account)
59
+ read_model(:account).should have_comment 'hello'
60
+
61
+ # root_dir.should have_model :account do |model_file|
62
+ # model_file.should have_method :index
63
+ # model_file.should have_comment 'hello'
64
+ # model_file.should have_comment 'goodbye'
65
+ # end
66
+ end
67
+ end
68
+