rails3_assist 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/.rspec +1 -0
  4. data/LICENSE +20 -0
  5. data/README.markdown +63 -0
  6. data/Rakefile +21 -0
  7. data/VERSION +1 -0
  8. data/lib/rails3_assist/app/file_names.rb +34 -0
  9. data/lib/rails3_assist/app/methods/crud.rb +31 -0
  10. data/lib/rails3_assist/app/methods/new_content.rb +11 -0
  11. data/lib/rails3_assist/app/rails_dirs.rb +105 -0
  12. data/lib/rails3_assist/app/rails_files.rb +128 -0
  13. data/lib/rails3_assist/app.rb +47 -0
  14. data/lib/rails3_assist/artifact/markers.rb +39 -0
  15. data/lib/rails3_assist/artifact/migration.rb +24 -0
  16. data/lib/rails3_assist/artifact/orm.rb +136 -0
  17. data/lib/rails3_assist/artifact/view.rb +67 -0
  18. data/lib/rails3_assist/base/class_methods.rb +11 -0
  19. data/lib/rails3_assist/base/create.rb +48 -0
  20. data/lib/rails3_assist/base/file_name.rb +17 -0
  21. data/lib/rails3_assist/base/insert.rb +53 -0
  22. data/lib/rails3_assist/base/read.rb +19 -0
  23. data/lib/rails3_assist/base/remove.rb +14 -0
  24. data/lib/rails3_assist/base.rb +49 -0
  25. data/lib/rails3_assist/extensions/core_ext.rb +29 -0
  26. data/lib/rails3_assist/rspec/macro.rb +34 -0
  27. data/lib/rails3_assist.rb +21 -0
  28. data/rails3_assist.gemspec +107 -0
  29. data/rails_generator.log +14 -0
  30. data/spec/load_spec.rb +1 -0
  31. data/spec/rails3_assist/app/app_dirs_spec.rb +23 -0
  32. data/spec/rails3_assist/app/app_file_names_spec.rb +0 -0
  33. data/spec/rails3_assist/app/app_files_spec.rb +0 -0
  34. data/spec/rails3_assist/artifact/controller/controller_spec.rb +33 -0
  35. data/spec/rails3_assist/artifact/helper/helper_spec.rb +33 -0
  36. data/spec/rails3_assist/artifact/mailer/mailer_spec.rb +33 -0
  37. data/spec/rails3_assist/artifact/migration/migration_spec.rb +34 -0
  38. data/spec/rails3_assist/artifact/model/model_spec.rb +34 -0
  39. data/spec/rails3_assist/artifact/observer/observer_spec.rb +34 -0
  40. data/spec/rails3_assist/artifact/orm/active_record_spec.rb +33 -0
  41. data/spec/rails3_assist/artifact/orm/mongo_mapper_spec.rb +63 -0
  42. data/spec/rails3_assist/artifact/orm/mongoid_spec.rb +63 -0
  43. data/spec/rails3_assist/artifact/view_spec/view_spec.rb +32 -0
  44. data/spec/spec_helper.rb +43 -0
  45. metadata +168 -0
@@ -0,0 +1,67 @@
1
+ module Rails::Assist
2
+ module View
3
+ include Rails::Assist::BaseHelper
4
+
5
+ # CREATE
6
+ def create_view name, options = {}, &block
7
+ file = view_file_name(name, options[:action], options[:type])
8
+ dir = File.dirname(file)
9
+ FileUtils.mkdir_p dir if !File.directory?(dir)
10
+ content = options[:content]
11
+ # set content to block
12
+ content ||= yield if block
13
+
14
+ # abort if no content given
15
+ return if !content
16
+
17
+ # write file content of view
18
+ File.open(file, 'w') do |f|
19
+ f.puts content
20
+ end
21
+ end
22
+
23
+ # READ
24
+ def read_view(name, options = {}, &block)
25
+ file_name = view_file_name(name, options[:action], options[:type])
26
+ debug "reading from: #{file_name}"
27
+ file = File.new(file_name)
28
+ raise "The view file: #{file} could not be found" if !file
29
+ begin
30
+ content = file.read
31
+ debug "read content: #{content}"
32
+ yield content if block
33
+ content
34
+ rescue
35
+ nil
36
+ end
37
+ end
38
+
39
+
40
+ # UPDATE
41
+ def insert_into_view(name, options = {}, &block)
42
+ debug "insert_into_view: #{options}"
43
+ file = view_file_name(name, options[:action], options[:type])
44
+ debug "file insertion (view): #{file}"
45
+ marker = options[:before] || options[:after]
46
+ file_insertion(file, marker, options, &block) if marker
47
+ end
48
+
49
+ # DELETE
50
+ def remove_view name, action=nil, type=nil
51
+ file = view_file_name(name, action, type)
52
+ FileUtils.rm_f(file) if File.exist?(file)
53
+ end
54
+
55
+ def get_action action
56
+ action || 'show'
57
+ end
58
+
59
+ def get_type type
60
+ type || 'html.erb'
61
+ end
62
+
63
+ include FileName
64
+
65
+ aliases_for :view
66
+ end
67
+ end
@@ -0,0 +1,11 @@
1
+ module Rails::Assist
2
+ module BaseHelper
3
+ module ClassMethods
4
+ def aliases_for name
5
+ multi_alias name,
6
+ :create => :new, :insert_into => [:inject_into, :update], :read => :X_content, :remove => :delete,
7
+ :options => :after
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,48 @@
1
+ module Rails::Assist
2
+ module BaseHelper
3
+ def new_artifact_content name, type, content=nil, &block
4
+ content ||= yield if block
5
+ %Q{class #{marker(name, type)}
6
+ #{content}
7
+ end}
8
+ end
9
+
10
+ # CREATE
11
+ def create_artifact name, options={}, &block
12
+ type = get_type(options)
13
+
14
+ file = make_file_name name, type
15
+ return if File.exist?(file)
16
+
17
+ debug "create #{type}: #{name}, opt: #{options}"
18
+ debug "file: #{file}"
19
+
20
+ # make dir
21
+ dir = File.dirname(file)
22
+ FileUtils.mkdir_p dir if !File.directory?(dir)
23
+
24
+ content = options[:content]
25
+ content ||= yield if block
26
+
27
+ content_method = :"new_#{type}_content"
28
+ debug "inner content: #{content}, to inject using ##{content_method}"
29
+
30
+ raise "Content method #{content_method} not found #{orm_notify}" if !respond_to?(content_method)
31
+
32
+ insert_content = if type == :model
33
+ send content_method, name, options.merge(:content => content), &block
34
+ else
35
+ send content_method, name, content, &block
36
+ end
37
+
38
+ debug "content to insert: #{insert_content}"
39
+
40
+ return if insert_content.blank?
41
+
42
+ File.open(file, 'w') do |f|
43
+ f.puts insert_content
44
+ end
45
+ debug "file created and content inserted"
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,17 @@
1
+ module Rails::Assist
2
+ module BaseHelper
3
+ include Rails::Assist::ArtifactPath
4
+
5
+ def make_file_name name, type, options={}
6
+ send :"#{type}_file_name", name, options
7
+ end
8
+
9
+ def existing_file_name name, type
10
+ # first try finder method
11
+ finder_method = :"find_#{type}"
12
+ found = send finder_method, name if respond_to? finder_method
13
+ # default
14
+ make_file_name(name, type) if !found
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,53 @@
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
+ x_marker = marker(name, type, options)
8
+ res = file_insertion file, x_marker, options, &block
9
+ if !res
10
+ # try with :embedded option if default doesn't work
11
+ x2_marker = marker(name, type, options.merge(:model_type => :embedded))
12
+ file_insertion file, x2_marker, options, &block
13
+ end
14
+ end
15
+
16
+ protected
17
+
18
+ def file_insertion(file_name, marker, options={}, &block)
19
+ return nil if !marker
20
+
21
+ file = File.new(file_name)
22
+ return nil if !File.exist?(file)
23
+
24
+ insert_content = options[:content] || (yield if block)
25
+
26
+ # already inserted?
27
+ return nil if insert_content.blank? || (file.read =~ /#{insert_content}/)
28
+
29
+ place = options[:before] ? :before : :after
30
+
31
+ debug "insert #{place}: '#{marker}'"
32
+ debug "content: #{insert_content}"
33
+
34
+ return nil if !(File.new(file.path).read =~ /#{Regexp.escape(marker)}/)
35
+
36
+ mutate_file file.path, marker, place do
37
+ insert_content
38
+ end
39
+ end
40
+
41
+ def mutate_file file, marker, place, &block
42
+ raise ArgumentError, "You must define a replacement marker for a :before or :after key" if !marker
43
+ replace_in_file file, /(#{Regexp.escape(marker)})/mi do |match|
44
+ place == :after ? "#{match}\n #{yield}" : "#{yield}\n #{match}"
45
+ end
46
+ end
47
+
48
+ def replace_in_file(path, regexp, *args, &block)
49
+ content = File.read(path).gsub(regexp, *args, &block)
50
+ File.open(path, 'wb') { |file| file.write(content) }
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,49 @@
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]
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'
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,34 @@
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
@@ -0,0 +1,21 @@
1
+ require 'thor'
2
+ require 'require_all'
3
+ require 'active_support/inflector'
4
+
5
+ module Rails
6
+ module Assist
7
+ def self.artifacts
8
+ [:observer, :controller, :helper, :mailer, :model, :migration]
9
+ end
10
+
11
+ class << self
12
+ attr_accessor :debug_on
13
+ end
14
+ end
15
+ end
16
+
17
+ require 'rails3_assist/extensions/core_ext'
18
+ require 'rails3_assist/rspec/macro'
19
+ require 'rails3_assist/app'
20
+ require_all File.dirname(__FILE__) + '/rails3_assist/artifact'
21
+
@@ -0,0 +1,107 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rails3_assist}
8
+ s.version = "0.2.2"
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{2010-08-19}
13
+ s.description = %q{Assist in operating on Rails 3 artifacts including migrations}
14
+ s.email = %q{kmandrup@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.markdown"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ ".rspec",
23
+ "LICENSE",
24
+ "README.markdown",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/rails3_assist.rb",
28
+ "lib/rails3_assist/app.rb",
29
+ "lib/rails3_assist/app/file_names.rb",
30
+ "lib/rails3_assist/app/methods/crud.rb",
31
+ "lib/rails3_assist/app/methods/new_content.rb",
32
+ "lib/rails3_assist/app/rails_dirs.rb",
33
+ "lib/rails3_assist/app/rails_files.rb",
34
+ "lib/rails3_assist/artifact/markers.rb",
35
+ "lib/rails3_assist/artifact/migration.rb",
36
+ "lib/rails3_assist/artifact/orm.rb",
37
+ "lib/rails3_assist/artifact/view.rb",
38
+ "lib/rails3_assist/base.rb",
39
+ "lib/rails3_assist/base/class_methods.rb",
40
+ "lib/rails3_assist/base/create.rb",
41
+ "lib/rails3_assist/base/file_name.rb",
42
+ "lib/rails3_assist/base/insert.rb",
43
+ "lib/rails3_assist/base/read.rb",
44
+ "lib/rails3_assist/base/remove.rb",
45
+ "lib/rails3_assist/extensions/core_ext.rb",
46
+ "lib/rails3_assist/rspec/macro.rb",
47
+ "rails3_assist.gemspec",
48
+ "rails_generator.log",
49
+ "spec/load_spec.rb",
50
+ "spec/rails3_assist/app/app_dirs_spec.rb",
51
+ "spec/rails3_assist/app/app_file_names_spec.rb",
52
+ "spec/rails3_assist/app/app_files_spec.rb",
53
+ "spec/rails3_assist/artifact/controller/controller_spec.rb",
54
+ "spec/rails3_assist/artifact/helper/helper_spec.rb",
55
+ "spec/rails3_assist/artifact/mailer/mailer_spec.rb",
56
+ "spec/rails3_assist/artifact/migration/migration_spec.rb",
57
+ "spec/rails3_assist/artifact/model/model_spec.rb",
58
+ "spec/rails3_assist/artifact/observer/observer_spec.rb",
59
+ "spec/rails3_assist/artifact/orm/active_record_spec.rb",
60
+ "spec/rails3_assist/artifact/orm/mongo_mapper_spec.rb",
61
+ "spec/rails3_assist/artifact/orm/mongoid_spec.rb",
62
+ "spec/rails3_assist/artifact/view_spec/view_spec.rb",
63
+ "spec/spec_helper.rb"
64
+ ]
65
+ s.homepage = %q{http://github.com/kristianmandrup/rails3-assist}
66
+ s.rdoc_options = ["--charset=UTF-8"]
67
+ s.require_paths = ["lib"]
68
+ s.rubygems_version = %q{1.3.7}
69
+ s.summary = %q{Assist in operating on Rails 3 artifacts including migrations}
70
+ s.test_files = [
71
+ "spec/load_spec.rb",
72
+ "spec/rails3_assist/app/app_dirs_spec.rb",
73
+ "spec/rails3_assist/app/app_file_names_spec.rb",
74
+ "spec/rails3_assist/app/app_files_spec.rb",
75
+ "spec/rails3_assist/artifact/controller/controller_spec.rb",
76
+ "spec/rails3_assist/artifact/helper/helper_spec.rb",
77
+ "spec/rails3_assist/artifact/mailer/mailer_spec.rb",
78
+ "spec/rails3_assist/artifact/migration/migration_spec.rb",
79
+ "spec/rails3_assist/artifact/model/model_spec.rb",
80
+ "spec/rails3_assist/artifact/observer/observer_spec.rb",
81
+ "spec/rails3_assist/artifact/orm/active_record_spec.rb",
82
+ "spec/rails3_assist/artifact/orm/mongo_mapper_spec.rb",
83
+ "spec/rails3_assist/artifact/orm/mongoid_spec.rb",
84
+ "spec/rails3_assist/artifact/view_spec/view_spec.rb",
85
+ "spec/spec_helper.rb"
86
+ ]
87
+
88
+ if s.respond_to? :specification_version then
89
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
90
+ s.specification_version = 3
91
+
92
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
93
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
94
+ s.add_runtime_dependency(%q<require_all>, [">= 1.1.0"])
95
+ s.add_runtime_dependency(%q<migration_assist>, [">= 0.1.2"])
96
+ else
97
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
98
+ s.add_dependency(%q<require_all>, [">= 1.1.0"])
99
+ s.add_dependency(%q<migration_assist>, [">= 0.1.2"])
100
+ end
101
+ else
102
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
103
+ s.add_dependency(%q<require_all>, [">= 1.1.0"])
104
+ s.add_dependency(%q<migration_assist>, [">= 0.1.2"])
105
+ end
106
+ end
107
+
@@ -0,0 +1,14 @@
1
+ -----------------------------------------------------
2
+ 2010-08-18 13:38:04 +0200 -- setup generator: [basic_generator]
3
+ [BasicGenerator]
4
+ -- By default we are in info mode...
5
+ This is debugging mode!
6
+ -- Back to info mode
7
+ -----------------------------------------------------
8
+ 2010-08-18 13:40:00 +0200 -- setup generator: [basic_generator]
9
+ [BasicGenerator]
10
+ -- By default we are in info mode...
11
+ -- debug lv set to: debug
12
+ This is debugging mode!
13
+ -- More info... but still in debugging mode
14
+ -- Back to info mode
data/spec/load_spec.rb ADDED
@@ -0,0 +1 @@
1
+ require 'spec_helper'
@@ -0,0 +1,23 @@
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
File without changes
File without changes
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'migration' do
4
+ use_helpers :app, :migration
5
+
6
+ before :each do
7
+ remove_migration :create_account
8
+
9
+ create_migration :create_account do
10
+ %q{
11
+ def index
12
+ end
13
+ }
14
+ end
15
+ end
16
+
17
+ after :each do
18
+ # remove_migration :create_account
19
+ end
20
+
21
+ it "should have an create_account_migration file that contains an index method and two inserted comments" do
22
+ insert_into_migration :create_account, :content => '# hello'
23
+ insert_into_migration :create_account do
24
+ '# goodbye'
25
+ end
26
+ read_migration(:create_account).should have_comment 'hello'
27
+ puts read_migration(:create_account)
28
+ # root_dir.should have_migration :create_account do |migration_file|
29
+ # migration_file.should have_method :index
30
+ # migration_file.should have_comment 'hello'
31
+ # migration_file.should have_comment 'goodbye'
32
+ # end
33
+ end
34
+ end