rails_artifactor 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
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,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'observer' do
4
+ use_helpers :observer
5
+
6
+ before :each do
7
+ RailsAssist::Directory.rails_root = fixtures_dir
8
+
9
+ remove_observer :account if has_observer? :account
10
+ create_observer :account do
11
+ %q{
12
+ def index
13
+ end
14
+ }
15
+ end
16
+ end
17
+
18
+ after :each do
19
+ remove_observer :account
20
+ end
21
+
22
+ context "Non-existant observer(s)" do
23
+ it "should not fail trying to remove non-existant observers" do
24
+ remove_observers :person, :user
25
+ remove_artifacts :observer, :person, :user
26
+
27
+ remove_observer :person
28
+ remove_artifact :observer, :person
29
+ end
30
+
31
+ it "should not find a non-existant observer" do
32
+ observer_file :person do |person|
33
+ fail "should not find person observer!"
34
+ end
35
+
36
+ has_observer?(:person).should be_false
37
+ has_observers?(:person, :user).should be_false
38
+ end
39
+
40
+ it "should not insert into non-existant observer" do
41
+ insert_into_observer(:person, :after => 'Hello', :content => 'Yes').should_not be_true
42
+ end
43
+
44
+ it "should not read from non-existant observer" do
45
+ read_observer :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_observer file that contains an index method and two inserted comments" do
52
+ insert_into_observer :account, :content => '# hello'
53
+ insert_into_observer :account do
54
+ '# goodbye'
55
+ end
56
+ read_observer(:account).should have_comment 'hello'
57
+ puts read_observer(:account)
58
+
59
+ # root_dir.should have_observer :account do |observer_file|
60
+ # observer_file.should have_method :index
61
+ # observer_file.should have_comment 'hello'
62
+ # observer_file.should have_comment 'goodbye'
63
+ # end
64
+ end
65
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'permit' do
4
+ use_helper :permit
5
+
6
+ before :each do
7
+ RailsAssist::Directory.rails_root = fixtures_dir
8
+
9
+ remove_permit :account if has_permit? :account
10
+ create_permit :account do
11
+ %q{ licenses :fishing, :blogging}
12
+ end
13
+
14
+ create_permit :super_admin, :superclass => :admin do
15
+ %q{ licenses :admin_users}
16
+ end
17
+
18
+ # puts read_permit :super_admin
19
+ end
20
+
21
+ after :each do
22
+ remove_permit :account
23
+ remove_permit :super_admin
24
+ end
25
+
26
+ context "Non-existant permit(s)" do
27
+ it "should not fail trying to remove non-existant permits" do
28
+ remove_permits :person, :user
29
+ remove_artifacts :permit, :person, :user
30
+
31
+ remove_permit :person
32
+ remove_artifact :permit, :person
33
+ end
34
+
35
+ it "should not find a non-existant permit" do
36
+ permit_file :person do |person|
37
+ fail "should not find person permit!"
38
+ end
39
+
40
+ has_permit?(:person).should be_false
41
+ has_permits?(:person, :user).should be_false
42
+ end
43
+
44
+ it "should not insert into non-existant permit" do
45
+ insert_into_permit(:person, :after => 'Hello', :content => 'Yes').should_not be_true
46
+ end
47
+
48
+ it "should not read from non-existant permit" do
49
+ read_permit :person do |content|
50
+ fail "should not find person content!"
51
+ end.should_not be_true
52
+ end
53
+ end
54
+
55
+ it "should have an account_permit file that contains a #mail_it method and two inserted comments" do
56
+ has_permit?(:account).should be_true
57
+ has_permit?(:super_admin).should be_true
58
+
59
+ insert_into_permit :account, :content => '# hello'
60
+ insert_into_permit :account do
61
+ '# goodbye'
62
+ end
63
+ read_permit(:account).should have_comment 'hello'
64
+ puts read_permit(:account)
65
+ # root_dir.should have_permit :account do |permit_file|
66
+ # permit_file.should have_method :index
67
+ # permit_file.should have_comment 'hello'
68
+ # permit_file.should have_comment 'goodbye'
69
+ # end
70
+ end
71
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'view API - symbols' do
4
+ use_helpers :view
5
+
6
+ before :each do
7
+ RailsAssist::Directory.rails_root = fixtures_dir
8
+
9
+ remove_view :account, :edit if has_view? :account, :edit
10
+ create_view :account, :edit do
11
+ %q{
12
+ <h1><%= title %></h1>
13
+ }
14
+ end
15
+
16
+ create_view :layouts, :application do
17
+ %q{
18
+ <!DOCTYPE html>
19
+ <html>
20
+ <head>
21
+ <title>App Layout</title>
22
+ <%= stylesheet_link_tag :all %>
23
+ <%= javascript_include_tag :defaults %>
24
+ <%= csrf_meta_tag %>
25
+ </head>
26
+ <body>
27
+
28
+ <%= yield %>
29
+
30
+ </body>
31
+ </html>
32
+ }
33
+ end
34
+ end
35
+
36
+ after :each do
37
+ remove_view :account
38
+ end
39
+
40
+ context "Non-existant view(s)" do
41
+
42
+ it "should read application layouts view" do
43
+ view_file_name(:layouts => :application).should match /html\.erb/
44
+ read_view(:layouts => :application).should match /App Layout/
45
+ read_view(:layouts, :application).should match /App Layout/
46
+ end
47
+
48
+ it "should insert into application layouts view" do
49
+ insert_into_view :layouts => :application, :after => '<body>' do
50
+ %Q{<p class="alert"><%= alert %></p>}
51
+ end
52
+ read_view(:layouts, :application).should match /<%= alert %>/
53
+ end
54
+
55
+ it "should not fail trying to remove non-existant views" do
56
+ remove_views :edit, :show, :folder => :person
57
+ remove_artifacts :view, :edit, :show, :folder => :person
58
+
59
+ remove_view :person => :show
60
+ remove_artifact :view, :show, :folder => :person
61
+ end
62
+
63
+ it "should not find a non-existant view" do
64
+ view_file :show, :folder => :person do |person|
65
+ fail "should not find person view!"
66
+ end
67
+
68
+ has_view?(:show, :folder => :person).should be_false
69
+ has_views?(:show, :edit, :folder => :person).should be_false
70
+ end
71
+
72
+ it "should not insert into non-existant view" do
73
+ insert_into_view(:show, :folder => :person, :after => 'Hello', :content => 'Yes').should_not be_true
74
+ end
75
+
76
+ it "should not read from non-existant view" do
77
+ read_view :person => :show do |content|
78
+ fail "should not find person content!"
79
+ end.should_not be_true
80
+ end
81
+ end
82
+
83
+ it "should have an account_view file that contains an index method and two inserted comments" do
84
+ insert_into_view :account, :edit, :content => '# hello', :before => '<h1>'
85
+ insert_into_view :account, :edit, :before => '<h1>' do
86
+ '# goodbye'
87
+ end
88
+ puts read_view(:account, :edit)
89
+ read_view(:account, :edit).should have_comment 'hello'
90
+ end
91
+ end
92
+
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'view API - symbols' do
4
+ use_helpers :view
5
+
6
+ def simple_path_expr str
7
+ /#{Regexp.escape(str)}/
8
+ end
9
+
10
+ before :each do
11
+ RailsAssist::Directory.rails_root = fixtures_dir
12
+ end
13
+
14
+ it "should find view file using args" do
15
+ simple_path = 'views/person/show.html.erb'
16
+ admin_path = 'views/person/admin/show.html.erb'
17
+
18
+ person_show = simple_path_expr(simple_path)
19
+ person_admin_show = simple_path_expr(admin_path)
20
+
21
+ view_file(:person => :show).should match person_show
22
+ view_file(:person => 'show').should match person_show
23
+ view_file('person/admin/' => 'show').should match person_admin_show
24
+
25
+ view_file(:person, :show).should match person_show
26
+ view_file('person/admin', :show).should match person_admin_show
27
+ view_file(:show, :folder => 'person').should match person_show
28
+ view_file(:folder => 'person', :action => :show).should match person_show
29
+ view_file(:folder => 'person', :action => :show, :type => :erb).should match person_show
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ CLASS = RailsAssist::Artifact::FileName
4
+
5
+ class ArtDir
6
+ include CLASS
7
+ end
8
+
9
+ describe RailsAssist::Artifact::FileName do
10
+ # use_helper :directories
11
+
12
+ before do
13
+ RailsAssist::Directory.rails_root = fixtures_dir
14
+ @test = ArtDir.new
15
+ end
16
+
17
+ (RailsAssist.artifacts - [:migration, :view]).each do |name|
18
+ eval %{
19
+ describe '##{name}_file_name' do
20
+ it "should return the file name for #{name} using class method" do
21
+ clazz = RailsAssist::Artifact::#{name.to_s.camelize}
22
+ clazz.#{name}_file_name('user').should match /user/
23
+ end
24
+
25
+ it "should return the file name for #{name} using instance method" do
26
+ art = ArtDir.new
27
+ art.extend RailsAssist::Artifact::#{name.to_s.camelize}
28
+ art.#{name}_file_name('user').should match /user/
29
+ end
30
+ end
31
+ }
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'migration_assist'
3
+
4
+ CLASS = RailsAssist::Artifact::Migration
5
+
6
+ RailsAssist::Migration.orm = :active_record
7
+
8
+ class ArtDir
9
+ include CLASS
10
+ end
11
+
12
+ describe RailsAssist::Artifact::Migration::FileName do
13
+ # use_orm :active_record
14
+
15
+ before do
16
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
17
+ @test = ArtDir.new
18
+ end
19
+
20
+ describe '#migration_file_name' do
21
+ it "should return the file name for migration" do
22
+ CLASS.migration_file_name(:create_persons).should match /create_persons/
23
+ end
24
+ end
25
+
26
+ describe '#migration_file_name' do
27
+ it "should return the file name for migration" do
28
+ CLASS.migration_file_name(:create_persons, :root_path => 'my_root').should match /my_root/
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ CLASS = RailsAssist::Artifact::View
4
+
5
+ class ArtDir
6
+ include CLASS
7
+ end
8
+
9
+ describe RailsAssist::Artifact::View::FileName do
10
+ # use_orm :active_record
11
+
12
+ before do
13
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
14
+ @test = ArtDir.new
15
+ end
16
+
17
+ describe '#view_file_name' do
18
+ it "should return the file name for the persons/show view with default action" do
19
+ CLASS.view_file_name(:person, :show).should match 'views/person/show'.to_regexp
20
+ end
21
+
22
+ it "should return the file name for the persons/show view with template type" do
23
+ CLASS.view_file_name(:person, :show, :type => :erb).should match 'views/person/show'.to_regexp
24
+ end
25
+
26
+ it "should return the file name for the persons/show view using hash" do
27
+ CLASS.view_file_name(:folder => :person, :action => :show, :type => 'erb.hml').should match 'views/person/show'.to_regexp
28
+ end
29
+
30
+ it "should return the file name for the persons/show view with root path" do
31
+ CLASS.view_file_name(:folder => :person, :action => :show, :type => :erb, :root_path => RailsAssist::Directory.rails_root).should match 'views/person/show'.to_regexp
32
+ end
33
+
34
+ it "should return the file name for the persons/show view with root path" do
35
+ CLASS.view_file_name(:folder => :person, :action => :show, :type => :erb, :views_path => 'my/views').should match 'views/person/show'.to_regexp
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+
3
+ describe RailsAssist::Artifact::Controller do
4
+ before do
5
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
6
+ @clazz = RailsAssist::Artifact::Controller
7
+ end
8
+
9
+ describe '#controller_marker' do
10
+ it "should return the class marker for controller :person" do
11
+ @clazz.controller_marker(:person).should == 'PersonController < ActionController::Base'
12
+ end
13
+ end
14
+ end
15
+
16
+ describe RailsAssist::Artifact::Helper do
17
+ before do
18
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
19
+ @clazz = RailsAssist::Artifact::Helper
20
+ end
21
+
22
+ describe '#helper_marker' do
23
+ it "should return the class marker for helper :person" do
24
+ @clazz.helper_marker(:person).should == 'PersonHelper'
25
+ end
26
+ end
27
+ end
28
+
29
+ describe RailsAssist::Artifact::Permit do
30
+ before do
31
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
32
+ @clazz = RailsAssist::Artifact::Permit
33
+ end
34
+
35
+ describe '#permit_marker' do
36
+ it "should return the class marker for permit :person" do
37
+ @clazz.permit_marker(:person).should == 'PersonPermit < Permit::Base'
38
+ end
39
+ end
40
+ end
41
+
42
+ describe RailsAssist::Artifact::Mailer do
43
+ before do
44
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
45
+ @clazz = RailsAssist::Artifact::Mailer
46
+ end
47
+
48
+ describe '#mailer_marker' do
49
+ it "should return the class marker for mailer :person" do
50
+ @clazz.mailer_marker(:person).should == 'PersonMailer < ActionMailer::Base'
51
+ end
52
+ end
53
+ end
54
+
55
+ describe RailsAssist::Artifact::Observer do
56
+ before do
57
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
58
+ @clazz = RailsAssist::Artifact::Observer
59
+ end
60
+
61
+ describe '#observer_marker' do
62
+ it "should return the class marker for observer :person" do
63
+ @clazz.observer_marker(:person).should == 'PersonObserver < ActiveRecord::Observer'
64
+ end
65
+ end
66
+ end
67
+
68
+ describe RailsAssist::Artifact::Migration do
69
+ before do
70
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
71
+ @clazz = RailsAssist::Artifact::Migration
72
+ end
73
+
74
+ describe '#migration_marker' do
75
+ it "should return the class marker for migration :create_person" do
76
+ @clazz.migration_marker(:create_person).should == 'CreatePerson < ActiveRecord::Migration'
77
+ end
78
+ end
79
+ end
80
+
81
+ describe RailsAssist::Artifact::Model do
82
+ before do
83
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
84
+ @clazz = RailsAssist::Artifact::Model
85
+ end
86
+
87
+ describe '#model_marker' do
88
+ it "should return the class marker for model :person" do
89
+ @clazz.model_marker(:person).should == 'Person'
90
+ end
91
+ end
92
+ end
93
+
File without changes
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'model with active_record' do
4
+ use_orm :active_record
5
+
6
+ before do
7
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
8
+ end
9
+
10
+ before :each do
11
+ remove_model :account
12
+ create_model :account do
13
+ %q{def index
14
+ end}
15
+ end
16
+ end
17
+
18
+ after :each do
19
+ remove_model :account
20
+ end
21
+
22
+ it "should have an account_model file that contains an index method and two inserted comments" do
23
+ insert_into_model :account, :content => '# hello'
24
+ insert_into_model :account do
25
+ '# goodbye'
26
+ end
27
+ puts read_model(:account)
28
+ read_model(:account).should have_comment 'hello'
29
+
30
+ # root_dir.should have_model :account do |model_file|
31
+ # model_file.should have_method :index
32
+ # model_file.should have_comment 'hello'
33
+ # model_file.should have_comment 'goodbye'
34
+ # end
35
+ end
36
+ end
37
+
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'model with DataMapper' do
4
+ use_orm :data_mapper
5
+
6
+ before do
7
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
8
+ end
9
+
10
+ before :each do
11
+ remove_model :account
12
+ create_model :account do
13
+ %q{def index
14
+ end}
15
+ end
16
+ end
17
+
18
+ after :each do
19
+ # remove_model :account
20
+ end
21
+
22
+ it "should have an account_model file that contains an index method and two inserted comments" do
23
+ insert_into_model :account, :content => '# hello'
24
+ insert_into_model :account do
25
+ '# goodbye'
26
+ end
27
+ puts read_model(:account)
28
+ read_model(:account).should have_comment 'hello'
29
+
30
+ # root_dir.should have_model :account do |model_file|
31
+ # model_file.should have_method :index
32
+ # model_file.should have_comment 'hello'
33
+ # model_file.should have_comment 'goodbye'
34
+ # end
35
+ end
36
+ end
37
+
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'model with Mongo Mapper' do
4
+ use_orm :mongo_mapper
5
+
6
+ before do
7
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
8
+ end
9
+
10
+ before :each do
11
+ remove_model :account
12
+ create_model :account do
13
+ %q{ def index
14
+ end}
15
+ end
16
+ end
17
+
18
+ after :each do
19
+ # remove_model :account
20
+ end
21
+
22
+ it "should have an account_model file that contains an index method and two inserted comments" do
23
+ insert_into_model :account, :content => '# hello'
24
+ insert_into_model :account do
25
+ '# goodbye'
26
+ end
27
+ puts read_model(:account)
28
+ read_model(:account).should have_comment 'hello'
29
+
30
+ # root_dir.should have_model :account do |model_file|
31
+ # model_file.should have_method :index
32
+ # model_file.should have_comment 'hello'
33
+ # model_file.should have_comment 'goodbye'
34
+ # end
35
+ end
36
+ end
37
+
38
+ describe 'model with Data Mapper' do
39
+ use_orm :data_mapper
40
+
41
+ before :each do
42
+ remove_model :account
43
+ create_model :account do
44
+ %q{ def index
45
+ end}
46
+ end
47
+ end
48
+
49
+ after :each do
50
+ # remove_model :account
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
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'model with Mongoid' do
4
+ use_orm :mongoid
5
+
6
+ before do
7
+ RailsAssist::Directory.rails_root = File.dirname (__FILE__)
8
+ end
9
+
10
+ before :each do
11
+ remove_model :account
12
+ create_model :account do
13
+ %q{def index
14
+ end}
15
+ end
16
+ end
17
+
18
+ after :each do
19
+ # remove_model :account
20
+ end
21
+
22
+ it "should have an account_model file that contains an index method and two inserted comments" do
23
+ insert_into_model :account, :content => '# hello'
24
+ insert_into_model :account do
25
+ '# goodbye'
26
+ end
27
+ puts read_model(:account)
28
+ read_model(:account).should have_comment 'hello'
29
+
30
+ # root_dir.should have_model :account do |model_file|
31
+ # model_file.should have_method :index
32
+ # model_file.should have_comment 'hello'
33
+ # model_file.should have_comment 'goodbye'
34
+ # end
35
+ end
36
+ end
37
+
38
+ describe 'model with Mongoid - embedded document' do
39
+ use_orm :mongoid
40
+
41
+ before :each do
42
+ remove_model :account
43
+ create_model :account, :model_type => :embedded do
44
+ %q{def index
45
+ end}
46
+ end
47
+ end
48
+
49
+ after :each do
50
+ # remove_model :account
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