rails3_artifactor 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/.rspec +1 -0
- data/LICENSE +20 -0
- data/README.markdown +67 -0
- data/Rakefile +18 -0
- data/VERSION +1 -0
- data/lib/rails3_artifactor/artifact/crud/view.rb +71 -0
- data/lib/rails3_artifactor/artifact/crud.rb +55 -0
- data/lib/rails3_artifactor/artifact/file_name/artifacts.rb +21 -0
- data/lib/rails3_artifactor/artifact/file_name/migration.rb +54 -0
- data/lib/rails3_artifactor/artifact/file_name/view.rb +36 -0
- data/lib/rails3_artifactor/artifact/markers.rb +76 -0
- data/lib/rails3_artifactor/artifact/migration.rb +11 -0
- data/lib/rails3_artifactor/artifact/orm/active_record.rb +14 -0
- data/lib/rails3_artifactor/artifact/orm/data_mapper.rb +22 -0
- data/lib/rails3_artifactor/artifact/orm/mongo_mapper.rb +18 -0
- data/lib/rails3_artifactor/artifact/orm/mongoid.rb +23 -0
- data/lib/rails3_artifactor/artifact/orm/none.rb +17 -0
- data/lib/rails3_artifactor/artifact/orm.rb +51 -0
- data/lib/rails3_artifactor/base/class_methods.rb +9 -0
- data/lib/rails3_artifactor/base/crud/create.rb +48 -0
- data/lib/rails3_artifactor/base/crud/delete.rb +14 -0
- data/lib/rails3_artifactor/base/crud/read.rb +20 -0
- data/lib/rails3_artifactor/base/crud/update.rb +44 -0
- data/lib/rails3_artifactor/base/crud.rb +6 -0
- data/lib/rails3_artifactor/base/file_name.rb +41 -0
- data/lib/rails3_artifactor/namespaces.rb +13 -0
- data/lib/rails3_artifactor/rspec/configure.rb +6 -0
- data/lib/rails3_artifactor/rspec/macro.rb +30 -0
- data/lib/rails3_artifactor.rb +6 -0
- data/spec/fixtures/app/controllers/account_controller.rb +4 -0
- data/spec/fixtures/app/helpers/account_helper.rb +4 -0
- data/spec/fixtures/app/models/account.rb +5 -0
- data/spec/fixtures/app/models/account_observer.rb +4 -0
- data/spec/fixtures/app/views/account/edit.html.erb +4 -0
- data/spec/fixtures/app/views/account/show.html.erb +3 -0
- data/spec/fixtures/db/migrations/20100904095012_create_account.rb +4 -0
- data/spec/fixtures.rb +3 -0
- data/spec/rails3_artifactor/artifact/crud/controller_spec.rb +35 -0
- data/spec/rails3_artifactor/artifact/crud/helper_spec.rb +35 -0
- data/spec/rails3_artifactor/artifact/crud/migration_spec.rb +51 -0
- data/spec/rails3_artifactor/artifact/crud/model_spec.rb +37 -0
- data/spec/rails3_artifactor/artifact/crud/observer_spec.rb +36 -0
- data/spec/rails3_artifactor/artifact/crud/view_controller_action_spec.rb +67 -0
- data/spec/rails3_artifactor/artifact/crud/view_controller_default_action_spec.rb +35 -0
- data/spec/rails3_artifactor/artifact/file_name/artifacts_spec.rb +29 -0
- data/spec/rails3_artifactor/artifact/file_name/migration_spec.rb +30 -0
- data/spec/rails3_artifactor/artifact/file_name/view_spec.rb +27 -0
- data/spec/rails3_artifactor/artifact/markers_spec.rb +97 -0
- data/spec/rails3_artifactor/artifact/migration_spec.rb +0 -0
- data/spec/rails3_artifactor/artifact/orm/active_record_spec.rb +33 -0
- data/spec/rails3_artifactor/artifact/orm/data_mapper_spec.rb +33 -0
- data/spec/rails3_artifactor/artifact/orm/mongo_mapper_spec.rb +63 -0
- data/spec/rails3_artifactor/artifact/orm/mongoid_spec.rb +63 -0
- data/spec/rails3_artifactor/artifact/orm/none_spec.rb +32 -0
- data/spec/rails3_artifactor/base/crud/create_spec.rb +13 -0
- data/spec/rails3_artifactor/base/crud/delete_spec.rb +14 -0
- data/spec/rails3_artifactor/base/crud/read_spec.rb +24 -0
- data/spec/rails3_artifactor/base/crud/update_spec.rb +24 -0
- data/spec/rails3_artifactor/base/file_name_spec.rb +23 -0
- data/spec/spec_helper.rb +9 -0
- metadata +183 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
module Rails3::Assist::Artifact::CRUD
|
2
|
+
module Delete
|
3
|
+
def remove_artifact name, type
|
4
|
+
file = existing_file_name name, type
|
5
|
+
debug "removed artifact: #{name}" if File.exist?(file) && FileUtils.rm_f(file)
|
6
|
+
end
|
7
|
+
alias_method :delete_artifact, :remove_artifact
|
8
|
+
|
9
|
+
def remove_artifacts type,*names
|
10
|
+
names.flatten.each{|name| send :"remove_#{type}", name }
|
11
|
+
end
|
12
|
+
alias_method :delete_artifacts, :remove_artifacts
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Rails3::Assist::Artifact::CRUD
|
2
|
+
module Read
|
3
|
+
|
4
|
+
# TODO: Support :before and :after hash options!
|
5
|
+
def read_artifact(name, options, &block)
|
6
|
+
type = get_type(options)
|
7
|
+
file_name = existing_file_name(name, type)
|
8
|
+
debug "reading from: #{file_name}"
|
9
|
+
begin
|
10
|
+
file = File.new(file_name)
|
11
|
+
content = file.read
|
12
|
+
debug "read content: #{content}"
|
13
|
+
yield content if block
|
14
|
+
content
|
15
|
+
rescue
|
16
|
+
raise "Rails #{type} at: #{file_name} can't be read"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'sugar-high/arguments'
|
2
|
+
|
3
|
+
module Rails3::Assist::Artifact::CRUD
|
4
|
+
module Update
|
5
|
+
def insert_into_artifact name, options={}, &block
|
6
|
+
type = get_type(options)
|
7
|
+
file = existing_file_name(name, type)
|
8
|
+
|
9
|
+
raise "No file could be determined: #{file} from name: #{name} of type: #{type}" if !file
|
10
|
+
raise "File to insert in not found: #{file} for #{type}" if !File.file?(file)
|
11
|
+
|
12
|
+
options1 = options.merge marker_option(name, type, options)
|
13
|
+
|
14
|
+
res = File.insert_into file, options1, &block
|
15
|
+
if !res
|
16
|
+
# try with :embedded option if default doesn't work
|
17
|
+
mrk_opt = marker_option name, type, options.merge(:model_type => :embedded)
|
18
|
+
options.merge! mrk_opt
|
19
|
+
|
20
|
+
File.insert_into file, options, &block
|
21
|
+
end
|
22
|
+
end
|
23
|
+
alias_method :update_artifact, :insert_into_artifact
|
24
|
+
|
25
|
+
def remove_from_artifact name, options={}, &block
|
26
|
+
# TODO
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove_content_from type, *names, &block
|
30
|
+
replacement_expr = last_option names
|
31
|
+
names.flatten.each do |name|
|
32
|
+
file = existing_file_name(name, type)
|
33
|
+
File.remove_content_from file, replacement_expr=nil, &block
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# TODO
|
38
|
+
aliases_for :remove_content_from, :delete_content_from, :delete_from, :remove_from
|
39
|
+
|
40
|
+
def replace_in_artifact name, options={}, &block
|
41
|
+
# TODO
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rails3_assist/artifact'
|
2
|
+
|
3
|
+
module Rails3::Assist::Artifact
|
4
|
+
module FileName
|
5
|
+
include Rails3::Assist::Artifact::Directory
|
6
|
+
include Rails3::Assist::Artifact::Path
|
7
|
+
|
8
|
+
def make_file_name name, type, options={}
|
9
|
+
send :"#{type}_file_name", name, options
|
10
|
+
end
|
11
|
+
|
12
|
+
def existing_file_name name, type=nil
|
13
|
+
# first try finder method
|
14
|
+
finder_method = :"find_#{type}"
|
15
|
+
if respond_to?(finder_method)
|
16
|
+
result = send finder_method, name
|
17
|
+
if !result.kind_of? String
|
18
|
+
raise IOError, "The call to #find_#{type}(#{name}) didn't find an existing #{type} file. Error in find expression: #{result.find_expr}"
|
19
|
+
end
|
20
|
+
return result
|
21
|
+
elsif type == :migration
|
22
|
+
raise "The method #find_#{type} to find the migration is not available!"
|
23
|
+
end
|
24
|
+
|
25
|
+
# default for non-migration
|
26
|
+
file_name = make_file_name(name, type)
|
27
|
+
raise IOError, "No file for :#{type} found at location: #{file_name}" if !File.file?(file_name)
|
28
|
+
file_name
|
29
|
+
end
|
30
|
+
|
31
|
+
Rails3::Assist.artifacts.each do |name|
|
32
|
+
class_eval %{
|
33
|
+
def existing_#{name}_file name, type=nil
|
34
|
+
existing_file_name name, type
|
35
|
+
end
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end # file_name
|
39
|
+
|
40
|
+
include FileName
|
41
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Rails3::Assist
|
2
|
+
module UseMacro
|
3
|
+
def assist_with *types
|
4
|
+
types.each{|type| use_helper type}
|
5
|
+
end
|
6
|
+
alias_method :load_helpers, :assist_with
|
7
|
+
alias_method :use_helpers, :assist_with
|
8
|
+
|
9
|
+
def use_helper type
|
10
|
+
class_eval do
|
11
|
+
begin
|
12
|
+
include "Rails3::Assist::Artifact::#{type.to_s.camelize}".constantize
|
13
|
+
rescue
|
14
|
+
raise ArgumentError, "Unregistered Rails3 helper library: #{type}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
alias_method :load_helper, :use_helper
|
19
|
+
|
20
|
+
def use_orm orm
|
21
|
+
class_eval do
|
22
|
+
begin
|
23
|
+
include "Rails3::Assist::Orm::#{orm.to_s.camelize}".constantize
|
24
|
+
rescue
|
25
|
+
raise ArgumentError, "Unregistered ORM library: #{orm}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/fixtures.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'controller' do
|
4
|
+
use_helpers :controller
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
8
|
+
|
9
|
+
remove_controller :account if has_controller? :account
|
10
|
+
create_controller :account do
|
11
|
+
%q{
|
12
|
+
def index
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
after :each do
|
19
|
+
# remove_controller :account
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have an account_controller file that contains an index method and two inserted comments" do
|
23
|
+
insert_into_controller :account, :content => '# hello'
|
24
|
+
insert_into_controller :account do
|
25
|
+
'# goodbye'
|
26
|
+
end
|
27
|
+
read_controller(:account).should have_comment 'hello'
|
28
|
+
puts read_controller(:account)
|
29
|
+
# root_dir.should have_controller :account do |controller_file|
|
30
|
+
# controller_file.should have_method :index
|
31
|
+
# controller_file.should have_comment 'hello'
|
32
|
+
# controller_file.should have_comment 'goodbye'
|
33
|
+
# end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'helper' do
|
4
|
+
use_helpers :helper
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
8
|
+
|
9
|
+
remove_helper :account if has_helper? :account
|
10
|
+
create_helper :account do
|
11
|
+
%q{
|
12
|
+
def index
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
after :each do
|
19
|
+
# remove_helper :account
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have an account_helper file that contains an index method and two inserted comments" do
|
23
|
+
insert_into_helper :account, :content => '# hello'
|
24
|
+
insert_into_helper :account do
|
25
|
+
'# goodbye'
|
26
|
+
end
|
27
|
+
read_helper(:account).should have_comment 'hello'
|
28
|
+
puts read_helper(:account)
|
29
|
+
# root_dir.should have_helper :account do |helper_file|
|
30
|
+
# helper_file.should have_method :index
|
31
|
+
# helper_file.should have_comment 'hello'
|
32
|
+
# helper_file.should have_comment 'goodbye'
|
33
|
+
# end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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
|
+
@root_dir = Rails3::Assist::Directory.rails_root = fixtures_dir
|
11
|
+
|
12
|
+
remove_migration :create_account if has_migration? :create_account
|
13
|
+
|
14
|
+
create_migration :create_account do
|
15
|
+
%q{
|
16
|
+
def self.up
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.down
|
20
|
+
end
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
after :each do
|
26
|
+
# remove_migration :create_account
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have an create_account_migration file that contains an index method and two inserted comments" do
|
30
|
+
insert_into_migration :create_account, :content => '# hello'
|
31
|
+
insert_into_migration :create_account do
|
32
|
+
'# goodbye'
|
33
|
+
end
|
34
|
+
read_migration(:create_account).should have_comment 'hello'
|
35
|
+
puts read_migration(:create_account)
|
36
|
+
|
37
|
+
# puts migration_file_name :create_account
|
38
|
+
|
39
|
+
# puts existing_file_name :create_account, :migration
|
40
|
+
|
41
|
+
# @root_dir.should have_migration :create_account
|
42
|
+
#
|
43
|
+
# lambda {existing_migration_file :blip}.should raise_error
|
44
|
+
#
|
45
|
+
# @root_dir.should have_migration :create_account do |migration_file|
|
46
|
+
# migration_file.should have_class_method :up
|
47
|
+
# migration_file.should have_comment 'hello'
|
48
|
+
# migration_file.should have_comment 'goodbye'
|
49
|
+
# end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'model without orm' do
|
4
|
+
use_orm :none
|
5
|
+
use_helper :model
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
9
|
+
|
10
|
+
remove_model :account if has_model? :account
|
11
|
+
create_model :account do
|
12
|
+
%q{def index
|
13
|
+
end}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after :each do
|
18
|
+
# remove_model :account
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have an account_model file that contains an index method and two inserted comments" do
|
22
|
+
insert_into_model :account, :content => '# hello'
|
23
|
+
insert_into_model :account do
|
24
|
+
'# goodbye'
|
25
|
+
end
|
26
|
+
puts read_model(:account)
|
27
|
+
read_model(:account).should have_comment 'hello'
|
28
|
+
|
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,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'observer' do
|
4
|
+
use_helpers :observer
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
Rails3::Assist::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
|
+
it "should have an account_observer file that contains an index method and two inserted comments" do
|
23
|
+
insert_into_observer :account, :content => '# hello'
|
24
|
+
insert_into_observer :account do
|
25
|
+
'# goodbye'
|
26
|
+
end
|
27
|
+
read_observer(:account).should have_comment 'hello'
|
28
|
+
puts read_observer(:account)
|
29
|
+
|
30
|
+
# root_dir.should have_observer :account do |observer_file|
|
31
|
+
# observer_file.should have_method :index
|
32
|
+
# observer_file.should have_comment 'hello'
|
33
|
+
# observer_file.should have_comment 'goodbye'
|
34
|
+
# end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'view API - symbols' do
|
4
|
+
use_helpers :view
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
Rails3::Assist::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
|
+
end
|
16
|
+
|
17
|
+
after :each do
|
18
|
+
# remove_view :account
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have an account_view file that contains an index method and two inserted comments" do
|
22
|
+
insert_into_view :account, :edit, :content => '# hello', :before => '<h1>'
|
23
|
+
insert_into_view :account, :edit, :before => '<h1>' do
|
24
|
+
'# goodbye'
|
25
|
+
end
|
26
|
+
puts read_view(:account, :edit)
|
27
|
+
read_view(:account, :edit).should have_comment 'hello'
|
28
|
+
|
29
|
+
# root_dir.should have_view :account do |view_file|
|
30
|
+
# view_file.should have_method :index
|
31
|
+
# view_file.should have_comment 'hello'
|
32
|
+
# view_file.should have_comment 'goodbye'
|
33
|
+
# end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# describe 'view API - hash' do
|
38
|
+
# use_helpers :app, :view
|
39
|
+
#
|
40
|
+
# before :each do
|
41
|
+
# remove_view :account, :action => :edit
|
42
|
+
# create_view :account, :action => :edit do
|
43
|
+
# %q{
|
44
|
+
# <h1><%= title %></h1>
|
45
|
+
# }
|
46
|
+
# end
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# after :each do
|
50
|
+
# # remove_view :account
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# it "should have an account_view file that contains an index method and two inserted comments" do
|
54
|
+
# insert_into_view :account, :action => :edit, :content => '# hello', :before => '<h1>'
|
55
|
+
# insert_into_view :account, :action => :edit, :before => '<h1>' do
|
56
|
+
# '# goodbye'
|
57
|
+
# end
|
58
|
+
# puts read_view(:account, :action => :edit)
|
59
|
+
# read_view(:account, :action => :edit).should have_comment 'hello'
|
60
|
+
# puts view_file_name(:account, :edit)
|
61
|
+
# # root_dir.should have_view :account do |view_file|
|
62
|
+
# # view_file.should have_method :index
|
63
|
+
# # view_file.should have_comment 'hello'
|
64
|
+
# # view_file.should have_comment 'goodbye'
|
65
|
+
# # end
|
66
|
+
# end
|
67
|
+
# end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'view' do
|
4
|
+
use_helpers :view
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
8
|
+
|
9
|
+
remove_view :account if has_view? :account
|
10
|
+
|
11
|
+
create_view :account do
|
12
|
+
%q{ def index
|
13
|
+
end}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after :each do
|
18
|
+
# remove_view :account
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have an account_view file that contains an index method and two inserted comments" do
|
22
|
+
insert_into_view :account, :content => '# hello', :before => 'def'
|
23
|
+
insert_into_view :account, :before => 'def' do
|
24
|
+
'# goodbye'
|
25
|
+
end
|
26
|
+
puts read_view(:account)
|
27
|
+
read_view(:account).should have_comment 'hello'
|
28
|
+
|
29
|
+
# root_dir.should have_view :account do |view_file|
|
30
|
+
# view_file.should have_method :index
|
31
|
+
# view_file.should have_comment 'hello'
|
32
|
+
# view_file.should have_comment 'goodbye'
|
33
|
+
# end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'require_all'
|
2
|
+
require 'rails3_artifactor/namespaces'
|
3
|
+
require 'rails3_artifactor/artifact/file_name/artifacts'
|
4
|
+
|
5
|
+
CLASS = Rails3::Assist::Artifact::FileName
|
6
|
+
|
7
|
+
class ArtDir
|
8
|
+
include CLASS
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Rails3::Assist::Artifact::FileName do
|
12
|
+
# use_helper :directories
|
13
|
+
|
14
|
+
before do
|
15
|
+
Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
|
16
|
+
@test = ArtDir.new
|
17
|
+
end
|
18
|
+
|
19
|
+
(Rails3::Assist.artifacts - [:migration, :view]).each do |name|
|
20
|
+
eval %{
|
21
|
+
describe '##{name}_file_name' do
|
22
|
+
it "should return the file name for #{name}" do
|
23
|
+
clazz = Rails3::Assist::Artifact::#{name.to_s.camelize}
|
24
|
+
clazz.#{name}_file_name('user').should match /user/
|
25
|
+
end
|
26
|
+
end
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# require 'spec_helper'
|
2
|
+
require 'require_all'
|
3
|
+
require 'rails3_artifactor/namespaces'
|
4
|
+
require 'rails3_artifactor/artifact/file_name/migration'
|
5
|
+
require 'rails3_artifactor/artifact/orm'
|
6
|
+
require 'rails3_artifactor/rspec/configure'
|
7
|
+
|
8
|
+
CLASS = Rails3::Assist::Artifact::Migration
|
9
|
+
|
10
|
+
Rails::Migration::Assist.orm = :active_record
|
11
|
+
|
12
|
+
class ArtDir
|
13
|
+
include CLASS
|
14
|
+
end
|
15
|
+
|
16
|
+
describe Rails3::Assist::Artifact::Migration::FileName do
|
17
|
+
# use_orm :active_record
|
18
|
+
|
19
|
+
before do
|
20
|
+
Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
|
21
|
+
@test = ArtDir.new
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#migration_file_name' do
|
25
|
+
it "should return the file name for migration" do
|
26
|
+
CLASS.migration_file_name(:create_persons).should match /create_persons/
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# require 'spec_helper'
|
2
|
+
require 'require_all'
|
3
|
+
require 'sugar-high/regexp'
|
4
|
+
require 'rails3_artifactor/namespaces'
|
5
|
+
require 'rails3_artifactor/artifact/file_name/view'
|
6
|
+
# require 'rails3_artifactor/rspec/configure'
|
7
|
+
|
8
|
+
CLASS = Rails3::Assist::Artifact::View
|
9
|
+
|
10
|
+
class ArtDir
|
11
|
+
include CLASS
|
12
|
+
end
|
13
|
+
|
14
|
+
describe Rails3::Assist::Artifact::View::FileName do
|
15
|
+
# use_orm :active_record
|
16
|
+
|
17
|
+
before do
|
18
|
+
Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
|
19
|
+
@test = ArtDir.new
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#view_file_name' do
|
23
|
+
it "should return the file name for the persons/show view" do
|
24
|
+
CLASS.view_file_name(:person, :show).should match 'views/person/show'.to_regexp
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|