rails3_assist 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/README.markdown +10 -3
  2. data/VERSION +1 -1
  3. data/lib/rails3_assist/app.rb +7 -41
  4. data/lib/rails3_assist/artifact/directory.rb +42 -0
  5. data/lib/rails3_assist/artifact/files.rb +63 -0
  6. data/lib/rails3_assist/artifact/path.rb +16 -0
  7. data/lib/rails3_assist/artifact.rb +34 -0
  8. data/lib/rails3_assist/directory/app.rb +17 -0
  9. data/lib/rails3_assist/directory/container.rb +24 -0
  10. data/lib/rails3_assist/directory/root.rb +20 -0
  11. data/lib/rails3_assist/directory.rb +55 -0
  12. data/lib/rails3_assist/file/application.rb +14 -0
  13. data/lib/rails3_assist/file/environment.rb +15 -0
  14. data/lib/rails3_assist/file/special.rb +48 -0
  15. data/lib/rails3_assist/file.rb +38 -0
  16. data/lib/rails3_assist/files.rb +83 -0
  17. data/lib/rails3_assist/namespaces.rb +11 -0
  18. data/lib/rails3_assist/rspec/configure.rb +2 -0
  19. data/lib/rails3_assist/rspec/matchers/have_app_config.rb +49 -0
  20. data/{spec/rails3_assist/app/app_file_names_spec.rb → lib/rails3_assist/rspec/matchers/have_special_file.rb} +0 -0
  21. data/lib/rails3_assist.rb +20 -11
  22. data/rails3_assist.gemspec +140 -49
  23. data/spec/fixtures/.gitignore +4 -0
  24. data/spec/fixtures/Gemfile +30 -0
  25. data/spec/fixtures/Gemfile.lock +73 -0
  26. data/spec/fixtures/README +256 -0
  27. data/spec/fixtures/Rakefile +7 -0
  28. data/spec/fixtures/app/controllers/application_controller.rb +3 -0
  29. data/spec/fixtures/app/controllers/users_controller.rb +83 -0
  30. data/spec/fixtures/app/helpers/application_helper.rb +2 -0
  31. data/spec/fixtures/app/helpers/users_helper.rb +2 -0
  32. data/spec/{rails3_assist/app/app_files_spec.rb → fixtures/app/mailers/user_mailer.rb} +0 -0
  33. data/spec/fixtures/app/models/user.rb +2 -0
  34. data/spec/fixtures/app/models/user_observer.rb +0 -0
  35. data/spec/fixtures/app/permits/user_permit.rb +0 -0
  36. data/spec/fixtures/app/views/layouts/application.html.erb +14 -0
  37. data/spec/fixtures/app/views/users/_form.html.erb +21 -0
  38. data/spec/fixtures/app/views/users/edit.html.erb +6 -0
  39. data/spec/fixtures/app/views/users/index.html.erb +23 -0
  40. data/spec/fixtures/app/views/users/new.html.erb +5 -0
  41. data/spec/fixtures/app/views/users/show.html.erb +10 -0
  42. data/spec/fixtures/config/application.rb +42 -0
  43. data/spec/fixtures/config/boot.rb +13 -0
  44. data/spec/fixtures/config/database.yml +22 -0
  45. data/spec/fixtures/config/environment.rb +5 -0
  46. data/spec/fixtures/config/environments/development.rb +26 -0
  47. data/spec/fixtures/config/environments/production.rb +49 -0
  48. data/spec/fixtures/config/environments/test.rb +35 -0
  49. data/spec/fixtures/config/initializers/backtrace_silencers.rb +7 -0
  50. data/spec/fixtures/config/initializers/inflections.rb +10 -0
  51. data/spec/fixtures/config/initializers/mime_types.rb +5 -0
  52. data/spec/fixtures/config/initializers/secret_token.rb +7 -0
  53. data/spec/fixtures/config/initializers/session_store.rb +8 -0
  54. data/spec/fixtures/config/locales/en.yml +5 -0
  55. data/spec/fixtures/config/routes.rb +60 -0
  56. data/spec/fixtures/config.ru +4 -0
  57. data/spec/fixtures/db/migrate/20100831135208_create_users.rb +13 -0
  58. data/spec/fixtures/db/seeds.rb +7 -0
  59. data/spec/fixtures/doc/README_FOR_APP +2 -0
  60. data/spec/fixtures/lib/tasks/.gitkeep +0 -0
  61. data/spec/fixtures/public/404.html +26 -0
  62. data/spec/fixtures/public/422.html +26 -0
  63. data/spec/fixtures/public/500.html +26 -0
  64. data/spec/fixtures/public/favicon.ico +0 -0
  65. data/spec/fixtures/public/images/rails.png +0 -0
  66. data/spec/fixtures/public/index.html +239 -0
  67. data/spec/fixtures/public/javascripts/application.js +2 -0
  68. data/spec/fixtures/public/javascripts/controls.js +965 -0
  69. data/spec/fixtures/public/javascripts/dragdrop.js +974 -0
  70. data/spec/fixtures/public/javascripts/effects.js +1123 -0
  71. data/spec/fixtures/public/javascripts/prototype.js +6001 -0
  72. data/spec/fixtures/public/javascripts/rails.js +175 -0
  73. data/spec/fixtures/public/robots.txt +5 -0
  74. data/spec/fixtures/public/stylesheets/.gitkeep +0 -0
  75. data/spec/fixtures/public/stylesheets/scaffold.css +56 -0
  76. data/spec/fixtures/script/rails +6 -0
  77. data/spec/fixtures/test/fixtures/users.yml +7 -0
  78. data/spec/fixtures/test/functional/users_controller_test.rb +49 -0
  79. data/spec/fixtures/test/performance/browsing_test.rb +9 -0
  80. data/spec/fixtures/test/test_helper.rb +13 -0
  81. data/spec/fixtures/test/unit/helpers/users_helper_test.rb +4 -0
  82. data/spec/fixtures/test/unit/user_test.rb +8 -0
  83. data/spec/fixtures/vendor/plugins/.gitkeep +0 -0
  84. data/spec/fixtures.rb +3 -0
  85. data/spec/rails3_assist/app_spec.rb +30 -0
  86. data/spec/rails3_assist/artifact/directory_spec.rb +66 -0
  87. data/spec/rails3_assist/artifact/files_spec.rb +64 -0
  88. data/spec/rails3_assist/artifact/path_spec.rb +23 -0
  89. data/spec/rails3_assist/artifact_spec.rb +33 -0
  90. data/spec/rails3_assist/directory/app_spec.rb +41 -0
  91. data/spec/rails3_assist/directory/container_spec.rb +63 -0
  92. data/spec/rails3_assist/directory/root_spec.rb +41 -0
  93. data/spec/rails3_assist/directory_spec.rb +59 -0
  94. data/spec/rails3_assist/file/application_spec.rb +33 -0
  95. data/spec/rails3_assist/file/environment_spec.rb +49 -0
  96. data/spec/rails3_assist/file/special_spec.rb +61 -0
  97. data/spec/rails3_assist/file_spec.rb +48 -0
  98. data/spec/rails3_assist/files_spec.rb +128 -0
  99. data/spec/rails3_assist/rspec/have_app_config_spec.rb +0 -0
  100. data/spec/spec_helper.rb +4 -2
  101. metadata +140 -49
  102. data/lib/rails3_assist/app/file_names.rb +0 -97
  103. data/lib/rails3_assist/app/methods/crud.rb +0 -31
  104. data/lib/rails3_assist/app/methods/new_content.rb +0 -11
  105. data/lib/rails3_assist/app/rails_dirs.rb +0 -106
  106. data/lib/rails3_assist/app/rails_files.rb +0 -128
  107. data/lib/rails3_assist/artifact/markers.rb +0 -45
  108. data/lib/rails3_assist/artifact/migration.rb +0 -10
  109. data/lib/rails3_assist/artifact/orm.rb +0 -136
  110. data/lib/rails3_assist/artifact/view.rb +0 -70
  111. data/lib/rails3_assist/base/class_methods.rb +0 -11
  112. data/lib/rails3_assist/base/create.rb +0 -48
  113. data/lib/rails3_assist/base/file_name.rb +0 -40
  114. data/lib/rails3_assist/base/insert.rb +0 -57
  115. data/lib/rails3_assist/base/read.rb +0 -19
  116. data/lib/rails3_assist/base/remove.rb +0 -14
  117. data/lib/rails3_assist/base.rb +0 -49
  118. data/lib/rails3_assist/extensions/core_ext.rb +0 -29
  119. data/lib/rails3_assist/rspec/macro.rb +0 -34
  120. data/spec/rails3_assist/app/app_dirs_spec.rb +0 -23
  121. data/spec/rails3_assist/artifact/controller/controller_spec.rb +0 -33
  122. data/spec/rails3_assist/artifact/helper/helper_spec.rb +0 -33
  123. data/spec/rails3_assist/artifact/mailer/mailer_spec.rb +0 -33
  124. data/spec/rails3_assist/artifact/migration/migration_spec.rb +0 -49
  125. data/spec/rails3_assist/artifact/model/model_spec.rb +0 -34
  126. data/spec/rails3_assist/artifact/observer/observer_spec.rb +0 -34
  127. data/spec/rails3_assist/artifact/orm/active_record_spec.rb +0 -33
  128. data/spec/rails3_assist/artifact/orm/mongo_mapper_spec.rb +0 -63
  129. data/spec/rails3_assist/artifact/orm/mongoid_spec.rb +0 -63
  130. data/spec/rails3_assist/artifact/view_spec/view_controller_action_spec.rb +0 -65
  131. data/spec/rails3_assist/artifact/view_spec/view_controller_default_action_specc.rb +0 -32
@@ -1,40 +0,0 @@
1
- module Rails::Assist
2
- module BaseHelper
3
- module FileName
4
- include Rails::Assist::ArtifactPath
5
-
6
- def make_file_name name, type, options={}
7
- send :"#{type}_file_name", name, options
8
- end
9
-
10
- def existing_file_name name, type=nil
11
- # first try finder method
12
- finder_method = :"find_#{type}"
13
- if respond_to?(finder_method)
14
- result = send finder_method, name
15
- if !result.kind_of? String
16
- raise "The call to #find_#{type}(#{name}) didn't find an existing #{type} file. Error in find expression: #{result.find_expr}"
17
- end
18
- return result
19
- else
20
- raise "The method #find_#{type} to find the migration is not available!" if type == :migration
21
- end
22
-
23
- # puts "Using method #make_file_name(#{name}) for #{type || 'unknown'}"
24
-
25
- # default for non-migration
26
- make_file_name(name, type)
27
- end
28
-
29
- Rails::Assist.artifacts.each do |name|
30
- class_eval %{
31
- def existing_#{name}_file name, type=nil
32
- existing_file_name name, type
33
- end
34
- }
35
- end
36
- end # file_name
37
-
38
- include FileName
39
- end
40
- end
@@ -1,57 +0,0 @@
1
- module Rails::Assist
2
- module BaseHelper
3
- # UPDATE
4
- def insert_content(name, options={}, &block)
5
- type = get_type(options)
6
- file = existing_file_name(name, type)
7
- raise "No file could be determined: #{file} from name: #{name} of type: #{type}" if !file
8
- raise "File to insert in not found: #{file} for #{type}" if !File.file?(file)
9
-
10
- x_marker = marker(name, type, options)
11
-
12
- res = file_insertion file, x_marker, options, &block
13
- if !res
14
- # try with :embedded option if default doesn't work
15
- x2_marker = marker(name, type, options.merge(:model_type => :embedded))
16
- file_insertion file, x2_marker, options, &block
17
- end
18
- end
19
-
20
- protected
21
-
22
- def file_insertion(file_name, marker, options={}, &block)
23
- return nil if !marker
24
-
25
- file = File.new(file_name)
26
- return nil if !File.exist?(file)
27
-
28
- insert_content = options[:content] || (yield if block)
29
-
30
- # already inserted?
31
- return nil if insert_content.blank? || (file.read =~ /#{insert_content}/)
32
-
33
- place = options[:before] ? :before : :after
34
-
35
- debug "insert #{place}: '#{marker}'"
36
- debug "content: #{insert_content}"
37
-
38
- return nil if !(File.new(file.path).read =~ /#{Regexp.escape(marker)}/)
39
-
40
- mutate_file file.path, marker, place do
41
- insert_content
42
- end
43
- end
44
-
45
- def mutate_file file, marker, place, &block
46
- raise ArgumentError, "You must define a replacement marker for a :before or :after key" if !marker
47
- replace_in_file file, /(#{Regexp.escape(marker)})/mi do |match|
48
- place == :after ? "#{match}\n #{yield}" : "#{yield}\n #{match}"
49
- end
50
- end
51
-
52
- def replace_in_file(path, regexp, *args, &block)
53
- content = File.read(path).gsub(regexp, *args, &block)
54
- File.open(path, 'wb') { |file| file.write(content) }
55
- end
56
- end
57
- end
@@ -1,19 +0,0 @@
1
- module Rails::Assist
2
- module BaseHelper
3
- # READ
4
- def read_artifact(name, options, &block)
5
- type = get_type(options)
6
- file_name = existing_file_name(name, type)
7
- debug "reading from: #{file_name}"
8
- begin
9
- file = File.new(file_name)
10
- content = file.read
11
- debug "read content: #{content}"
12
- yield content if block
13
- content
14
- rescue
15
- raise "Rails #{type} at: #{file_name} can't be read"
16
- end
17
- end
18
- end
19
- end
@@ -1,14 +0,0 @@
1
- module Rails::Assist
2
- module BaseHelper
3
-
4
- # DELETE
5
- def remove_artifact name, type
6
- file = make_file_name name, type
7
- debug "removed artifact: #{name}" if File.exist?(file) && FileUtils.rm_f(file)
8
- end
9
-
10
- def remove_artifacts type,*names
11
- names.flatten.each{|name| send :"remove_#{type}", name }
12
- end
13
- end
14
- end
@@ -1,49 +0,0 @@
1
- module Rails::Assist
2
- module BaseHelper
3
- def self.included(base)
4
- base.extend ClassMethods
5
- base.class_eval do
6
- include Rails::Assist::App
7
- include ::Thor::Actions
8
- end
9
- end
10
-
11
- protected
12
-
13
- def get_type options = {}
14
- case options
15
- when Hash
16
- raise ArgumentError, "No artifact type specified #{options}" if !options[:type]
17
- options[:type].to_sym
18
- when String, Symbol
19
- options.to_sym
20
- else
21
- raise ArgumentError, "Bad artifact type specified #{options}"
22
- end
23
- end
24
-
25
- def debug?
26
- Rails::Assist.debug_on
27
- end
28
-
29
- def debug msg
30
- puts msg if debug?
31
- end
32
-
33
- def set options, type
34
- options.merge!(:type => type)
35
- options
36
- end
37
-
38
- def orm_notify
39
- ''
40
- end
41
-
42
- def marker name, type, options={}
43
- return send :"#{type}_marker", name, options if type
44
- name.to_s.camelize
45
- end
46
- end
47
- end
48
-
49
- require_all File.dirname(__FILE__) + '/base'
@@ -1,29 +0,0 @@
1
- class Module
2
- def multi_alias name, options={}
3
- config_options = options[:options]
4
- options.each_pair do |original, aliases|
5
- next if original == :options
6
- alias_methods name, original, [aliases].flatten, config_options
7
- end
8
- end
9
-
10
- protected
11
-
12
- def alias_methods name, original, aliases, config_options
13
- aliases.each do |alias_name|
14
- new_alias = make_name(name, alias_name.to_s, config_options)
15
- original_name = make_name(name, original.to_s, config_options)
16
- alias_method new_alias, original_name if respond_to? original_name
17
- end
18
- end
19
-
20
- def make_name name, alias_name, config_options
21
- return alias_name.gsub(/X/, name.to_s) if alias_name =~ /X/
22
- case config_options
23
- when :after
24
- "#{alias_name}_#{name}"
25
- when :before
26
- "#{name}_#{alias_name}"
27
- end
28
- end
29
- end
@@ -1,34 +0,0 @@
1
- module Rails::Assist
2
- module UseMacro
3
- def use_orm orm
4
- class_eval do
5
- begin
6
- include "Rails::Assist::Orm::#{orm.to_s.camelize}".constantize
7
- rescue
8
- raise ArgumentError, "Unregistered ORM library: #{orm}"
9
- end
10
- end
11
- end
12
-
13
- def assist_with *types
14
- types.each{|type| use_helper type}
15
- end
16
- alias_method :load_helpers, :assist_with
17
- alias_method :use_helpers, :assist_with
18
-
19
- def use_helper type
20
- class_eval do
21
- begin
22
- include "Rails::Assist::#{type.to_s.camelize}".constantize
23
- rescue
24
- raise ArgumentError, "Unregistered Rails3 helper library: #{type}"
25
- end
26
- end
27
- end
28
- alias_method :load_helper, :use_helper
29
- end
30
- end
31
-
32
- RSpec.configure do |config|
33
- config.extend(Rails::Assist::UseMacro)
34
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'controller' do
4
- use_helper :app
5
-
6
- before do
7
- Rails::Assist::App.rails_root_dir = temp_dir('tmp_rails')
8
- end
9
-
10
- after do
11
- remove_temp_dir 'tmp_rails'
12
- end
13
-
14
- it "should create basic root directories" do
15
- create_empty_tmp root_directories
16
- root_dir.should have_dirs root_directories
17
- end
18
-
19
- it "should have basic app directories" do
20
- create_empty_tmp app_artifacts
21
- app_dir.should have_dirs app_directories
22
- end
23
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'controller' do
4
- use_helpers :app, :controller
5
-
6
- before :each do
7
- remove_controller :account
8
- create_controller :account do
9
- %q{
10
- def index
11
- end
12
- }
13
- end
14
- end
15
-
16
- after :each do
17
- # remove_controller :account
18
- end
19
-
20
- it "should have an account_controller file that contains an index method and two inserted comments" do
21
- insert_into_controller :account, :content => '# hello'
22
- insert_into_controller :account do
23
- '# goodbye'
24
- end
25
- read_controller(:account).should have_comment 'hello'
26
- puts read_controller(:account)
27
- # root_dir.should have_controller :account do |controller_file|
28
- # controller_file.should have_method :index
29
- # controller_file.should have_comment 'hello'
30
- # controller_file.should have_comment 'goodbye'
31
- # end
32
- end
33
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'helper' do
4
- use_helpers :app, :helper
5
-
6
- before :each do
7
- remove_helper :account
8
- create_helper :account do
9
- %q{
10
- def index
11
- end
12
- }
13
- end
14
- end
15
-
16
- after :each do
17
- # remove_helper :account
18
- end
19
-
20
- it "should have an account_helper file that contains an index method and two inserted comments" do
21
- insert_into_helper :account, :content => '# hello'
22
- insert_into_helper :account do
23
- '# goodbye'
24
- end
25
- read_helper(:account).should have_comment 'hello'
26
- puts read_helper(:account)
27
- # root_dir.should have_helper :account do |helper_file|
28
- # helper_file.should have_method :index
29
- # helper_file.should have_comment 'hello'
30
- # helper_file.should have_comment 'goodbye'
31
- # end
32
- end
33
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'mailer' do
4
- use_helpers :app, :mailer
5
-
6
- before :each do
7
- remove_mailer :account
8
- create_mailer :account do
9
- %q{
10
- def index
11
- end
12
- }
13
- end
14
- end
15
-
16
- after :each do
17
- # remove_mailer :account
18
- end
19
-
20
- it "should have an account_mailer file that contains an index method and two inserted comments" do
21
- insert_into_mailer :account, :content => '# hello'
22
- insert_into_mailer :account do
23
- '# goodbye'
24
- end
25
- read_mailer(:account).should have_comment 'hello'
26
- puts read_mailer(:account)
27
- # root_dir.should have_mailer :account do |mailer_file|
28
- # mailer_file.should have_method :index
29
- # mailer_file.should have_comment 'hello'
30
- # mailer_file.should have_comment 'goodbye'
31
- # end
32
- end
33
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- Rails::Migration::Assist.orm = :active_record
4
-
5
- describe 'migration' do
6
- use_orm :active_record
7
- use_helpers :migration
8
-
9
- before :each do
10
- remove_migration :create_account
11
-
12
- create_migration :create_account do
13
- %q{
14
- def self.up
15
- end
16
-
17
- def self.down
18
- end
19
- }
20
- end
21
- end
22
-
23
- after :each do
24
- # remove_migration :create_account
25
- end
26
-
27
- it "should have an create_account_migration file that contains an index method and two inserted comments" do
28
- insert_into_migration :create_account, :content => '# hello'
29
- insert_into_migration :create_account do
30
- '# goodbye'
31
- end
32
- read_migration(:create_account).should have_comment 'hello'
33
- puts read_migration(:create_account)
34
-
35
- # puts migration_file_name :create_account
36
-
37
- # puts existing_file_name :create_account, :migration
38
-
39
- root_dir.should have_migration :create_account
40
-
41
- lambda {existing_migration_file :blip}.should raise_error
42
-
43
- root_dir.should have_migration :create_account do |migration_file|
44
- migration_file.should have_class_method :up
45
- migration_file.should have_comment 'hello'
46
- migration_file.should have_comment 'goodbye'
47
- end
48
- end
49
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'model without orm' do
4
- use_orm :none
5
-
6
- before :each do
7
- remove_model :account
8
- create_model :account do
9
- %q{def index
10
- end}
11
- end
12
- end
13
-
14
- after :each do
15
- # remove_model :account
16
- end
17
-
18
- it "should have an account_model file that contains an index method and two inserted comments" do
19
- insert_into_model :account, :content => '# hello'
20
- insert_into_model :account do
21
- '# goodbye'
22
- end
23
- puts read_model(:account)
24
- read_model(:account).should have_comment 'hello'
25
-
26
-
27
- # root_dir.should have_model :account do |model_file|
28
- # model_file.should have_method :index
29
- # model_file.should have_comment 'hello'
30
- # model_file.should have_comment 'goodbye'
31
- # end
32
- end
33
- end
34
-
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'observer' do
4
- use_helpers :app, :observer
5
-
6
- before :each do
7
- remove_observer :account
8
- create_observer :account do
9
- %q{
10
- def index
11
- end
12
- }
13
- end
14
- end
15
-
16
- after :each do
17
- # remove_observer :account
18
- end
19
-
20
- it "should have an account_observer file that contains an index method and two inserted comments" do
21
- insert_into_observer :account, :content => '# hello'
22
- insert_into_observer :account do
23
- '# goodbye'
24
- end
25
- read_observer(:account).should have_comment 'hello'
26
- puts read_observer(:account)
27
-
28
- # root_dir.should have_observer :account do |observer_file|
29
- # observer_file.should have_method :index
30
- # observer_file.should have_comment 'hello'
31
- # observer_file.should have_comment 'goodbye'
32
- # end
33
- end
34
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'model with active_record' do
4
- use_orm :active_record
5
-
6
- before :each do
7
- remove_model :account
8
- create_model :account do
9
- %q{def index
10
- end}
11
- end
12
- end
13
-
14
- after :each do
15
- # remove_model :account
16
- end
17
-
18
- it "should have an account_model file that contains an index method and two inserted comments" do
19
- insert_into_model :account, :content => '# hello'
20
- insert_into_model :account do
21
- '# goodbye'
22
- end
23
- puts read_model(:account)
24
- read_model(:account).should have_comment 'hello'
25
-
26
- # root_dir.should have_model :account do |model_file|
27
- # model_file.should have_method :index
28
- # model_file.should have_comment 'hello'
29
- # model_file.should have_comment 'goodbye'
30
- # end
31
- end
32
- end
33
-
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'model with Mongo Mapper' do
4
- use_orm :mongo_mapper
5
-
6
- before :each do
7
- remove_model :account
8
- create_model :account do
9
- %q{ def index
10
- end}
11
- end
12
- end
13
-
14
- after :each do
15
- # remove_model :account
16
- end
17
-
18
- it "should have an account_model file that contains an index method and two inserted comments" do
19
- insert_into_model :account, :content => '# hello'
20
- insert_into_model :account do
21
- '# goodbye'
22
- end
23
- puts read_model(:account)
24
- read_model(:account).should have_comment 'hello'
25
-
26
- # root_dir.should have_model :account do |model_file|
27
- # model_file.should have_method :index
28
- # model_file.should have_comment 'hello'
29
- # model_file.should have_comment 'goodbye'
30
- # end
31
- end
32
- end
33
-
34
- describe 'model with Data Mapper' do
35
- use_orm :data_mapper
36
-
37
- before :each do
38
- remove_model :account
39
- create_model :account do
40
- %q{ def index
41
- end}
42
- end
43
- end
44
-
45
- after :each do
46
- # remove_model :account
47
- end
48
-
49
- it "should have an account_model file that contains an index method and two inserted comments" do
50
- insert_into_model :account, :content => '# hello'
51
- insert_into_model :account do
52
- '# goodbye'
53
- end
54
- puts read_model(:account)
55
- read_model(:account).should have_comment 'hello'
56
-
57
- # root_dir.should have_model :account do |model_file|
58
- # model_file.should have_method :index
59
- # model_file.should have_comment 'hello'
60
- # model_file.should have_comment 'goodbye'
61
- # end
62
- end
63
- end
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'model with Mongoid' do
4
- use_orm :mongoid
5
-
6
- before :each do
7
- remove_model :account
8
- create_model :account do
9
- %q{def index
10
- end}
11
- end
12
- end
13
-
14
- after :each do
15
- # remove_model :account
16
- end
17
-
18
- it "should have an account_model file that contains an index method and two inserted comments" do
19
- insert_into_model :account, :content => '# hello'
20
- insert_into_model :account do
21
- '# goodbye'
22
- end
23
- puts read_model(:account)
24
- read_model(:account).should have_comment 'hello'
25
-
26
- # root_dir.should have_model :account do |model_file|
27
- # model_file.should have_method :index
28
- # model_file.should have_comment 'hello'
29
- # model_file.should have_comment 'goodbye'
30
- # end
31
- end
32
- end
33
-
34
- describe 'model with Mongoid - embedded document' do
35
- use_orm :mongoid
36
-
37
- before :each do
38
- remove_model :account
39
- create_model :account, :model_type => :embedded do
40
- %q{def index
41
- end}
42
- end
43
- end
44
-
45
- after :each do
46
- # remove_model :account
47
- end
48
-
49
- it "should have an account_model file that contains an index method and two inserted comments" do
50
- insert_into_model :account, :content => '# hello'
51
- insert_into_model :account do
52
- '# goodbye'
53
- end
54
- puts read_model(:account)
55
- read_model(:account).should have_comment 'hello'
56
-
57
- # root_dir.should have_model :account do |model_file|
58
- # model_file.should have_method :index
59
- # model_file.should have_comment 'hello'
60
- # model_file.should have_comment 'goodbye'
61
- # end
62
- end
63
- end