generator-spec 0.5.0 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +0 -0
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/LICENSE +0 -0
- data/README.markdown +19 -13
- data/Rakefile +14 -35
- data/VERSION +1 -1
- data/generator-spec.gemspec +63 -148
- data/lib/generator-spec.rb +12 -0
- data/lib/generator-spec/namespaces.rb +7 -0
- data/lib/{generator_spec/helpers/configure_rails.rb → generator-spec/rails/configure.rb} +3 -3
- data/lib/generator-spec/rspec.rb +1 -0
- data/lib/generator-spec/rspec/configure.rb +6 -0
- data/lib/{generator_spec/rspec_generator/generator_util.rb → generator-spec/rspec/generator.rb} +6 -6
- data/lib/{generator_spec/rspec_generator → generator-spec/rspec/generator}/configure.rb +0 -0
- data/lib/{generator_spec/require_generator.rb → generator-spec/rspec/generator/require.rb} +0 -0
- data/lib/{generator_spec/rspec_generator → generator-spec/rspec/generator}/routes.rb +0 -0
- data/lib/{generator_spec/rspec_generator → generator-spec/rspec/generator}/test_case.rb +0 -0
- data/lib/generator-spec/rspec/macro.rb +18 -0
- data/lib/generator-spec/rspec/matchers/generate_artifact.rb +34 -0
- data/lib/generator-spec/rspec/matchers/generate_artifacts.rb +33 -0
- data/lib/generators/controller/controller_generator.rb +15 -21
- data/lib/generators/helper/helper_generator.rb +13 -29
- data/lib/generators/migration/migration_generator.rb +6 -7
- data/lib/generators/migration/templates/create_users.erb +0 -0
- data/lib/generators/model/model_generator.rb +36 -55
- data/lib/generators/observer/observer_generator.rb +2 -0
- data/lib/generators/view/view_generator.rb +2 -0
- data/spec/generator_spec/generators/controller_gen_spec.rb +40 -0
- data/spec/generator_spec/generators/{helper_generator_spec.rb → helper_gen_spec.rb} +4 -8
- data/spec/generator_spec/generators/{migration_generator_spec.rb → migration_gen_spec.rb} +3 -8
- data/spec/generator_spec/generators/model_gen_spec.rb +36 -0
- data/spec/generator_spec/generators/{observer_generator_spec.rb → observer_gen_spec.rb} +12 -21
- data/spec/generator_spec/generators/{view_generator_spec.rb → view_gen_spec.rb} +9 -20
- data/spec/generator_spec/matchers/generate_artifact_spec.rb +36 -0
- data/spec/generator_spec/matchers/generate_artifacts_spec.rb +35 -0
- data/spec/spec_helper.rb +5 -6
- data/wiki/Custom Rails 3 Generators.textile b/data/wiki/Custom Rails 3 → Generators.textile +0 -0
- data/wiki/content_matchers.textile +0 -0
- data/wiki/file_matchers.textile +0 -0
- data/wiki/migration_matchers.textile +0 -0
- data/wiki/rails_helpers.textile +0 -0
- metadata +117 -154
- data/lib/generator_spec.rb +0 -12
- data/lib/generator_spec/extensions/core_ext.rb +0 -47
- data/lib/generator_spec/helpers/generator_helper.rb +0 -11
- data/lib/generator_spec/helpers/migration_helper.rb +0 -69
- data/lib/generator_spec/main.rb +0 -77
- data/lib/generator_spec/matchers/content/content_matcher.rb +0 -110
- data/lib/generator_spec/matchers/content/have_block.rb +0 -57
- data/lib/generator_spec/matchers/content/have_call.rb +0 -59
- data/lib/generator_spec/matchers/content/have_calls.rb +0 -60
- data/lib/generator_spec/matchers/content/have_class_self.rb +0 -40
- data/lib/generator_spec/matchers/content/have_comment.rb +0 -42
- data/lib/generator_spec/matchers/content/have_method.rb +0 -66
- data/lib/generator_spec/matchers/content/have_module.rb +0 -66
- data/lib/generator_spec/matchers/content/have_region.rb +0 -48
- data/lib/generator_spec/matchers/content/have_subclass.rb +0 -50
- data/lib/generator_spec/matchers/content/include_module.rb +0 -51
- data/lib/generator_spec/matchers/content/inherit_from.rb +0 -40
- data/lib/generator_spec/matchers/file/generate_directory.rb +0 -73
- data/lib/generator_spec/matchers/file/generate_file.rb +0 -103
- data/lib/generator_spec/matchers/file/generate_migration.rb +0 -54
- data/lib/generator_spec/matchers/file/have_file.rb +0 -115
- data/lib/generator_spec/matchers/helpers/content.rb +0 -18
- data/lib/generator_spec/matchers/helpers/file.rb +0 -26
- data/lib/generator_spec/matchers/helpers/migration.rb +0 -89
- data/lib/generator_spec/matchers/migration/have_column.rb +0 -29
- data/lib/generator_spec/matchers/migration/have_index.rb +0 -9
- data/lib/generator_spec/matchers/migration/have_table.rb +0 -18
- data/lib/generator_spec/matchers/migration/have_tbl_column.rb +0 -25
- data/lib/generator_spec/matchers/migration/have_up_down.rb +0 -15
- data/lib/generator_spec/rails_helpers/base_helper.rb +0 -171
- data/lib/generator_spec/rails_helpers/rails_app.rb +0 -166
- data/lib/generator_spec/rails_helpers/rails_controller.rb +0 -44
- data/lib/generator_spec/rails_helpers/rails_helper.rb +0 -40
- data/lib/generator_spec/rails_helpers/rails_mailer.rb +0 -39
- data/lib/generator_spec/rails_helpers/rails_migration.rb +0 -51
- data/lib/generator_spec/rails_helpers/rails_model.rb +0 -40
- data/lib/generator_spec/rails_helpers/rails_observer.rb +0 -39
- data/lib/generator_spec/rails_helpers/rails_orm.rb +0 -114
- data/lib/generator_spec/rails_helpers/rails_view.rb +0 -65
- data/rspec_for_generators.gemspec +0 -96
- data/spec/generator_spec/generators/controller_generator_spec.rb +0 -47
- data/spec/generator_spec/generators/model_generator_spec.rb +0 -41
- data/spec/generator_spec/matchers/content/class_self_spec.rb +0 -30
- data/spec/generator_spec/matchers/content/have_block_spec.rb +0 -57
- data/spec/generator_spec/matchers/content/have_call_spec.rb +0 -55
- data/spec/generator_spec/matchers/content/have_calls_spec.rb +0 -47
- data/spec/generator_spec/matchers/content/have_class_spec.rb +0 -34
- data/spec/generator_spec/matchers/content/have_method_spec.rb +0 -52
- data/spec/generator_spec/matchers/content/have_module_spec.rb +0 -34
- data/spec/generator_spec/matchers/content/have_region_spec.rb +0 -56
- data/spec/generator_spec/matchers/content/have_subclass_spec.rb +0 -34
- data/spec/generator_spec/matchers/content/include_module_spec.rb +0 -36
- data/spec/generator_spec/matchers/content/inherit_from_spec.rb +0 -34
- data/spec/generator_spec/matchers/file/directory_spec.rb +0 -0
- data/spec/generator_spec/matchers/file/file_spec.rb +0 -0
- data/spec/generator_spec/matchers/file/migration_spec.rb +0 -0
- data/spec/generator_spec/matchers/migration/have_column_spec.rb +0 -0
- data/spec/generator_spec/matchers/migration/have_index_spec.rb +0 -0
- data/spec/generator_spec/matchers/migration/have_table_spec.rb +0 -0
- data/spec/generator_spec/matchers/migration/have_tbl_column_spec.rb +0 -0
- data/spec/generator_spec/matchers/migration/have_up_down_spec.rb +0 -0
- data/spec/generator_spec/matchers/rails/controller_matcher_spec.rb +0 -27
- data/spec/generator_spec/matchers/rails/helper_matcher_spec.rb +0 -26
- data/spec/generator_spec/matchers/rails/mailer_matcher_spec.rb +0 -24
- data/spec/generator_spec/matchers/rails/model_matcher_spec.rb +0 -31
- data/spec/generator_spec/matchers/rails/observer_matcher_spec.rb +0 -19
- data/spec/generator_spec/matchers/rails/view_matcher_spec.rb +0 -23
- data/spec/generator_spec/rails_helpers/rails_app_spec.rb +0 -0
- data/spec/generator_spec/rails_helpers/rails_controller_spec.rb +0 -33
- data/spec/generator_spec/rails_helpers/rails_helper_spec.rb +0 -33
- data/spec/generator_spec/rails_helpers/rails_mailer_spec.rb +0 -33
- data/spec/generator_spec/rails_helpers/rails_migration_spec.rb +0 -0
- data/spec/generator_spec/rails_helpers/rails_model_spec.rb +0 -31
- data/spec/generator_spec/rails_helpers/rails_observer_spec.rb +0 -33
- data/spec/generator_spec/rails_helpers/rails_orm_spec.rb +0 -0
- data/spec/generator_spec/rails_helpers/rails_view_spec.rb +0 -31
@@ -1,73 +0,0 @@
|
|
1
|
-
# Asserts a given file exists. You need to supply an absolute path or a path relative
|
2
|
-
# to the configured destination:
|
3
|
-
#
|
4
|
-
# generator.should have_generated_file "app/controller/products_controller.rb"
|
5
|
-
#
|
6
|
-
|
7
|
-
module RSpec::FileMatchers
|
8
|
-
class GenerateDir
|
9
|
-
attr_accessor :relative_path
|
10
|
-
|
11
|
-
def initialize(relative_path, type = nil)
|
12
|
-
@relative_path = relative_rails_dir(relative_path, type)
|
13
|
-
end
|
14
|
-
|
15
|
-
def matches?(generator, &block)
|
16
|
-
file = File.expand_path(relative_path, generator.class.destination_root)
|
17
|
-
file_exists = File.exists?(expected)
|
18
|
-
if block && file_exists
|
19
|
-
read = File.read(file)
|
20
|
-
ruby_content = read.extend(RSpec::RubyContent::Helpers)
|
21
|
-
yield ruby_content
|
22
|
-
else
|
23
|
-
file_exists
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def failure_message
|
28
|
-
"Expected file #{relative_path} to have been generated, but it was not"
|
29
|
-
end
|
30
|
-
|
31
|
-
def negative_failure_message
|
32
|
-
"Did not expected file #{relative_path} to have been generated, but it was"
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
def relative_rails_dir path, type = nil
|
38
|
-
path = path.to_s
|
39
|
-
return File.join(::Rails.root, base_dir(type), folder(type), "#{path}") if type
|
40
|
-
File.join(::Rails.root, path)
|
41
|
-
end
|
42
|
-
|
43
|
-
def folder type
|
44
|
-
case type
|
45
|
-
when :observer
|
46
|
-
'models'
|
47
|
-
else
|
48
|
-
type.to_s.pluralize
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def base_dir type
|
53
|
-
case type
|
54
|
-
when :model, :controller, :view, :helper, :observer
|
55
|
-
'app'
|
56
|
-
when :migration
|
57
|
-
'db'
|
58
|
-
when :javascript, :stylesheet
|
59
|
-
'public'
|
60
|
-
when :initializer, :locale
|
61
|
-
'config'
|
62
|
-
else
|
63
|
-
''
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def generate_dir(relative, type = nil)
|
69
|
-
GenerateDir.new(relative, type)
|
70
|
-
end
|
71
|
-
alias_method :have_dir, :generate_dir
|
72
|
-
end
|
73
|
-
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# Asserts a given file exists. You need to supply an absolute path or a path relative
|
2
|
-
# to the configured destination:
|
3
|
-
#
|
4
|
-
# generator.should have_generated_file "app/controller/products_controller.rb"
|
5
|
-
#
|
6
|
-
|
7
|
-
module RSpec::FileMatchers
|
8
|
-
class GenerateFile
|
9
|
-
attr_accessor :relative_path
|
10
|
-
|
11
|
-
def initialize(relative_path, type = nil)
|
12
|
-
@relative_path = relative_rails_file(relative_path, type)
|
13
|
-
end
|
14
|
-
|
15
|
-
def matches?(generator, &block)
|
16
|
-
file = File.expand_path(relative_path, generator.class.destination_root)
|
17
|
-
file_exists = File.exists?(file)
|
18
|
-
if block && file_exists
|
19
|
-
read = File.read(file)
|
20
|
-
ruby_content = read.extend(RSpec::RubyContent::Helpers)
|
21
|
-
yield ruby_content
|
22
|
-
else
|
23
|
-
file_exists
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def failure_message
|
28
|
-
"Expected file #{relative_path} to have been generated, but it was not"
|
29
|
-
end
|
30
|
-
|
31
|
-
def negative_failure_message
|
32
|
-
"Did not expected file #{relative_path} to have been generated, but it was"
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
def relative_rails_file path, type = nil
|
38
|
-
path = path.to_s
|
39
|
-
f_name = file_name(path, type)
|
40
|
-
return File.join(::Rails.root, base_dir(type), folder(type), f_name) if type
|
41
|
-
File.join(::Rails.root, path)
|
42
|
-
end
|
43
|
-
|
44
|
-
def file_name path, type
|
45
|
-
return "#{path}#{postfix(type)}.rb" if !path.include? '.'
|
46
|
-
path
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
def postfix type
|
51
|
-
"_#{type}" if [:helper, :controller, :observer].include?(type)
|
52
|
-
end
|
53
|
-
|
54
|
-
def folder type
|
55
|
-
case type
|
56
|
-
when :observer
|
57
|
-
'models'
|
58
|
-
else
|
59
|
-
type.to_s.pluralize
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def base_dir type
|
64
|
-
case type
|
65
|
-
when :model, :controller, :view, :helper, :observer
|
66
|
-
'app'
|
67
|
-
when :migration
|
68
|
-
'db'
|
69
|
-
when :javascript, :stylesheet
|
70
|
-
'public'
|
71
|
-
when :initializer, :locale
|
72
|
-
'config'
|
73
|
-
else
|
74
|
-
''
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def generate_file(relative, type = nil)
|
80
|
-
GenerateFile.new(relative, type)
|
81
|
-
end
|
82
|
-
|
83
|
-
def generate_model(relative)
|
84
|
-
GenerateFile.new(relative, :model)
|
85
|
-
end
|
86
|
-
|
87
|
-
def generate_controller(relative)
|
88
|
-
GenerateFile.new(relative, :controller)
|
89
|
-
end
|
90
|
-
|
91
|
-
def generate_helper(relative)
|
92
|
-
GenerateFile.new(relative, :helper)
|
93
|
-
end
|
94
|
-
|
95
|
-
def generate_view(relative, action, ext)
|
96
|
-
GenerateFile.new("#{relative}/#{action}.#{ext}", :view)
|
97
|
-
end
|
98
|
-
|
99
|
-
def generate_observer(relative)
|
100
|
-
GenerateFile.new(relative, :observer)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# This method manipulates the given path and tries to find any migration which
|
2
|
-
# matches the migration name. For example, the call above is converted to:
|
3
|
-
#
|
4
|
-
# generator.should generate_migration "db/migrate/003_create_products.rb"
|
5
|
-
#
|
6
|
-
# Consequently it accepts the same arguments as the matcher have_file.
|
7
|
-
|
8
|
-
module RSpec
|
9
|
-
module FileMatchers
|
10
|
-
class GenerateMigration
|
11
|
-
include RSpec::Rails::Migration
|
12
|
-
|
13
|
-
attr_reader :name
|
14
|
-
|
15
|
-
def initialize(name)
|
16
|
-
@name = name.to_s
|
17
|
-
end
|
18
|
-
|
19
|
-
def matches?(generator)
|
20
|
-
expected = migration_file_name(name, generator)
|
21
|
-
if block_given? && expected
|
22
|
-
read = File.read(expected)
|
23
|
-
ruby_content = read.extend(RSpec::RubyContent::Helpers)
|
24
|
-
yield ruby_content
|
25
|
-
else
|
26
|
-
expected
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def failure_message
|
31
|
-
"Expected migration #{name} to have been generated, but it was not"
|
32
|
-
end
|
33
|
-
|
34
|
-
def negative_failure_message
|
35
|
-
"Did not expect migration #{name} to have been generated, but it was"
|
36
|
-
end
|
37
|
-
|
38
|
-
protected
|
39
|
-
|
40
|
-
def migration_file_name(relative, generator) #:nodoc:
|
41
|
-
dirname = migration_dir
|
42
|
-
file_name = relative.sub(/\.rb$/, '')
|
43
|
-
migrations = Dir.glob("#{dirname}/[0-9]*_*.rb")
|
44
|
-
!migrations.empty? ? migrations.grep(/\d+_#{file_name}\.rb$/).first : false
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def generate_migration(name)
|
50
|
-
GenerateMigration.new(name)
|
51
|
-
end
|
52
|
-
alias_method :have_migration, :generate_migration
|
53
|
-
end
|
54
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
# Asserts a given file exists. You need to supply an absolute path or a path relative
|
2
|
-
# to the configured destination:
|
3
|
-
#
|
4
|
-
# generator.should have_generated_file "app/controller/products_controller.rb"
|
5
|
-
#
|
6
|
-
|
7
|
-
module RSpec::FileMatchers
|
8
|
-
class HaveFile
|
9
|
-
attr_accessor :relative_path
|
10
|
-
|
11
|
-
def initialize(relative_path, type = nil)
|
12
|
-
@relative_path = relative_rails_file(relative_path, type)
|
13
|
-
end
|
14
|
-
|
15
|
-
def matches?(generator, &block)
|
16
|
-
file = File.expand_path(relative_path, Rails.root)
|
17
|
-
file_exists = File.exists?(file)
|
18
|
-
if block && file_exists
|
19
|
-
read = File.read(file)
|
20
|
-
ruby_content = read.extend(RSpec::RubyContent::Helpers)
|
21
|
-
yield ruby_content
|
22
|
-
else
|
23
|
-
file_exists
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def failure_message
|
28
|
-
"Expected file #{relative_path} to have been generated, but it was not"
|
29
|
-
end
|
30
|
-
|
31
|
-
def negative_failure_message
|
32
|
-
"Did not expected file #{relative_path} to have been generated, but it was"
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
def relative_rails_file path, type = nil
|
38
|
-
path = path.to_s
|
39
|
-
f_name = file_name(path, type)
|
40
|
-
return File.join(::Rails.root, base_dir(type), folder(type), f_name) if type
|
41
|
-
File.join(::Rails.root, path)
|
42
|
-
end
|
43
|
-
|
44
|
-
def file_name path, type
|
45
|
-
return "#{path}#{postfix(type)}.rb" if !path.include? '.'
|
46
|
-
path
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
def postfix type
|
51
|
-
"_#{type}" if ![:model].include?(type)
|
52
|
-
end
|
53
|
-
|
54
|
-
def folder type
|
55
|
-
case type
|
56
|
-
when :observer
|
57
|
-
'models'
|
58
|
-
else
|
59
|
-
type.to_s.pluralize
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def base_dir type
|
64
|
-
case type
|
65
|
-
when :model, :controller, :view, :helper, :observer, :mailer
|
66
|
-
'app'
|
67
|
-
when :migration
|
68
|
-
'db'
|
69
|
-
when :javascript, :stylesheet
|
70
|
-
'public'
|
71
|
-
when :initializer, :locale
|
72
|
-
'config'
|
73
|
-
else
|
74
|
-
''
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def have_file(relative, type = nil)
|
80
|
-
HaveFile.new(relative, type)
|
81
|
-
end
|
82
|
-
alias_method :contain_file, :have_file
|
83
|
-
|
84
|
-
def have_model(relative)
|
85
|
-
HaveFile.new(relative, :model)
|
86
|
-
end
|
87
|
-
alias_method :contain_model, :have_model
|
88
|
-
|
89
|
-
def have_controller(relative)
|
90
|
-
HaveFile.new(relative, :controller)
|
91
|
-
end
|
92
|
-
alias_method :contain_controller, :have_controller
|
93
|
-
|
94
|
-
def have_helper(relative)
|
95
|
-
HaveFile.new(relative, :helper)
|
96
|
-
end
|
97
|
-
alias_method :contain_helper, :have_helper
|
98
|
-
|
99
|
-
def have_view(relative, action='show', ext='html.erb')
|
100
|
-
HaveFile.new("#{relative}/#{action}.#{ext}", :view)
|
101
|
-
end
|
102
|
-
alias_method :contain_view, :have_view
|
103
|
-
|
104
|
-
def have_observer(relative)
|
105
|
-
HaveFile.new(relative, :observer)
|
106
|
-
end
|
107
|
-
alias_method :contain_observer, :have_observer
|
108
|
-
|
109
|
-
def have_mailer(relative)
|
110
|
-
HaveFile.new(relative, :mailer)
|
111
|
-
end
|
112
|
-
alias_method :contain_mailer, :have_mailer
|
113
|
-
|
114
|
-
end
|
115
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module RSpec::RubyContent
|
2
|
-
module Helpers
|
3
|
-
def check_matchings matchings
|
4
|
-
matchings.each do |matching|
|
5
|
-
self.should match /#{Regexp.escape(matching)}/
|
6
|
-
end
|
7
|
-
end
|
8
|
-
alias_method :matchings, :check_matchings
|
9
|
-
|
10
|
-
|
11
|
-
def check_methods methods, type=nil
|
12
|
-
methods.each do |method_name|
|
13
|
-
self.should have_method(method_name, type)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
alias_method :methods, :check_methods
|
17
|
-
end
|
18
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module RSpec::Generator
|
2
|
-
module Helpers
|
3
|
-
def check_file file_name, type=nil, &block
|
4
|
-
self.should generate_file(file_name, type, &block)
|
5
|
-
end
|
6
|
-
alias_method :file, :check_file
|
7
|
-
|
8
|
-
def check_view(file_name, matchings)
|
9
|
-
self.should generate_file(file_name, :view) do |content|
|
10
|
-
check_matchings matchings
|
11
|
-
end
|
12
|
-
end
|
13
|
-
alias_method :view, :check_view
|
14
|
-
|
15
|
-
def check_model(file_name, clazz, options = {})
|
16
|
-
self.should generate_file("#{file_name.underscore}.rb", :model) do |file_content|
|
17
|
-
file_content.should have_class clazz do |content|
|
18
|
-
check_matchings options[:matchings]
|
19
|
-
check_methods(options[:methods])
|
20
|
-
check_class_methods(options[:class_methods])
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
alias_method :model, :check_model
|
25
|
-
end
|
26
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
module RSpec::Generator
|
2
|
-
module Helpers
|
3
|
-
def check_migration(file_name, &block)
|
4
|
-
self.should generate_migration file_name do |content|
|
5
|
-
yield content if block
|
6
|
-
end
|
7
|
-
end
|
8
|
-
alias_method :migration, :check_migration
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
module RSpec::RubyContent
|
13
|
-
module Helpers
|
14
|
-
def check_up &block
|
15
|
-
self.should have_up, &block
|
16
|
-
end
|
17
|
-
alias_method :up, :check_up
|
18
|
-
|
19
|
-
def check_down &block
|
20
|
-
self.should have_down, &block
|
21
|
-
end
|
22
|
-
alias_method :down, :check_down
|
23
|
-
|
24
|
-
def check_create_table name, &block
|
25
|
-
self.should create_table name, &block
|
26
|
-
end
|
27
|
-
alias_method :creates_table, :check_create_table
|
28
|
-
|
29
|
-
def check_change_table name, &block
|
30
|
-
self.should change_table name, &block
|
31
|
-
end
|
32
|
-
alias_method :changes_table, :check_change_table
|
33
|
-
|
34
|
-
def check_drop_table name
|
35
|
-
self.should drop_table name, &block
|
36
|
-
end
|
37
|
-
alias_method :drops_table, :check_drop_table
|
38
|
-
|
39
|
-
def check_rename_table name
|
40
|
-
self.should rename_table name, &block
|
41
|
-
end
|
42
|
-
alias_method :renames_table, :check_rename_table
|
43
|
-
|
44
|
-
def check_remove_column name
|
45
|
-
self.should remove_colum name, &block
|
46
|
-
end
|
47
|
-
alias_method :removes_column, :check_remove_column
|
48
|
-
|
49
|
-
def check_add_column name, type='string'
|
50
|
-
self.should add_column name, type, &block
|
51
|
-
end
|
52
|
-
alias_method :adds_column, :check_add_column
|
53
|
-
|
54
|
-
def check_change_column name, type='string'
|
55
|
-
self.should change_column name, type, &block
|
56
|
-
end
|
57
|
-
alias_method :changes_column, :check_change_column
|
58
|
-
|
59
|
-
def check_add_tbl_column tbl_name, name, type='string'
|
60
|
-
self.should add_tbl_column tbl_name, name, type
|
61
|
-
end
|
62
|
-
alias_method :adds_tbl_column, :check_add_tbl_column
|
63
|
-
|
64
|
-
def check_change_tbl_column tbl_name, name, type='string'
|
65
|
-
self.should change_tbl_column tbl_name, name, type
|
66
|
-
end
|
67
|
-
alias_method :changes_tbl_column, :check_change_tbl_column
|
68
|
-
|
69
|
-
def check_rename_tbl_column tbl_name, new_name
|
70
|
-
self.should rename_tbl_column tbl_name, new_name
|
71
|
-
end
|
72
|
-
alias_method :renames_tbl_column, :check_rename_tbl_column
|
73
|
-
|
74
|
-
def check_remove_tbl_column tbl_name, name
|
75
|
-
self.should remove_tbl_column tbl_name, name
|
76
|
-
end
|
77
|
-
alias_method :removes_tbl_column, :check_remove_tbl_column
|
78
|
-
|
79
|
-
def check_add_tbl_index tbl_name, name
|
80
|
-
self.should add_tbl_index tbl_name, name
|
81
|
-
end
|
82
|
-
alias_method :adds_tbl_index, :check_add_tbl_index
|
83
|
-
|
84
|
-
def check_remove_tbl_index tbl_name, name
|
85
|
-
self.should remove_tbl_index tbl_name, name
|
86
|
-
end
|
87
|
-
alias_method :removes_tbl_index, :check_remove_tbl_index
|
88
|
-
end
|
89
|
-
end
|