rails3_artifactor 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,7 +7,8 @@ begin
7
7
  gem.email = "kmandrup@gmail.com"
8
8
  gem.homepage = "http://github.com/kristianmandrup/rails3_artifact_helper"
9
9
  gem.authors = ["Kristian Mandrup"]
10
- gem.add_development_dependency "rspec", ">= 2.0"
10
+ gem.add_development_dependency "rspec", ">= 2.0.0"
11
+ gem.add_development_dependency "generator-spec", '>= 0.7.0'
11
12
 
12
13
  gem.add_dependency "rspec", ">= 2.0.0"
13
14
  gem.add_dependency "require_all", "~> 1.2.0"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -34,7 +34,12 @@ module Rails3::Assist::Artifact
34
34
 
35
35
  def view_file_name *args
36
36
  folder, action, type = get_view_args(args)
37
- File.expand_path File.join(DIR.view_dir, folder.to_s, "#{action}.#{type}")
37
+ options = last_option args
38
+ root_path = options[:root_path]
39
+ views_path = options[:views_path]
40
+ views_path ||= File.join(root_path, 'app/views') if root_path
41
+ puts "views: #{views_path}"
42
+ File.expand_path File.join(views_path || DIR.view_dir, folder.to_s, "#{action}.#{type}")
38
43
  end
39
44
 
40
45
  def get_view_args *args
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails3_artifactor}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2010-10-21}
12
+ s.date = %q{2010-11-20}
13
13
  s.description = %q{Helpers for handling Rails 3 artifacts in general, such as CRUD operations etc.}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -131,14 +131,16 @@ Gem::Specification.new do |s|
131
131
  s.specification_version = 3
132
132
 
133
133
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
134
- s.add_development_dependency(%q<rspec>, [">= 2.0"])
134
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
135
+ s.add_development_dependency(%q<generator-spec>, [">= 0.7.0"])
135
136
  s.add_runtime_dependency(%q<rspec>, [">= 2.0.0"])
136
137
  s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
137
138
  s.add_runtime_dependency(%q<sugar-high>, ["~> 0.3.0"])
138
139
  s.add_runtime_dependency(%q<rails3_assist>, ["~> 0.3.0"])
139
140
  s.add_runtime_dependency(%q<migration_assist>, ["~> 0.1.4"])
140
141
  else
141
- s.add_dependency(%q<rspec>, [">= 2.0"])
142
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
143
+ s.add_dependency(%q<generator-spec>, [">= 0.7.0"])
142
144
  s.add_dependency(%q<rspec>, [">= 2.0.0"])
143
145
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
144
146
  s.add_dependency(%q<sugar-high>, ["~> 0.3.0"])
@@ -146,7 +148,8 @@ Gem::Specification.new do |s|
146
148
  s.add_dependency(%q<migration_assist>, ["~> 0.1.4"])
147
149
  end
148
150
  else
149
- s.add_dependency(%q<rspec>, [">= 2.0"])
151
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
152
+ s.add_dependency(%q<generator-spec>, [">= 0.7.0"])
150
153
  s.add_dependency(%q<rspec>, [">= 2.0.0"])
151
154
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
152
155
  s.add_dependency(%q<sugar-high>, ["~> 0.3.0"])
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'generator-spec'
2
3
 
3
4
  Rails3::Migration::Assist.orm = :active_record
4
5
 
@@ -26,7 +27,7 @@ describe 'migration' do
26
27
  remove_migration :create_account
27
28
  end
28
29
 
29
- context "Non-existant migration(s)" do
30
+ context "Migration not there" do
30
31
  it "should not fail trying to remove non-existant migrations" do
31
32
  remove_migrations :person, :user
32
33
  remove_artifacts :migration, :person, :user
@@ -54,27 +55,32 @@ describe 'migration' do
54
55
  end.should_not be_true
55
56
  end
56
57
  end
57
-
58
- it "should have an create_account_migration file that contains an index method and two inserted comments" do
59
- insert_into_migration :create_account, :content => '# hello'
60
- insert_into_migration :create_account do
61
- '# goodbye'
62
- end
63
- read_migration(:create_account).should have_comment 'hello'
64
- puts read_migration(:create_account)
65
-
66
- # puts migration_file_name :create_account
67
58
 
68
- # puts existing_file_name :create_account, :migration
59
+ context "When migration does exist" do
60
+ before do
61
+ insert_into_migration :create_account, :content => '# hello'
62
+ insert_into_migration :create_account do
63
+ '# goodbye'
64
+ end
65
+ end
66
+
67
+ it "should have an :create_account migration file that contains an index method and two inserted comments" do
68
+ nil.should have_migration :create_account
69
69
 
70
- # @root_dir.should have_migration :create_account
71
- #
72
- # lambda {existing_migration_file :blip}.should raise_error
73
- #
74
- # @root_dir.should have_migration :create_account do |migration_file|
75
- # migration_file.should have_class_method :up
76
- # migration_file.should have_comment 'hello'
77
- # migration_file.should have_comment 'goodbye'
78
- # end
70
+ read_migration(:create_account).should have_comment 'hello'
71
+ read_migration(:create_account).should match /ActiveRecord::Migration/
72
+ end
73
+
74
+ it "should not have migration blip" do
75
+ lambda {existing_migration_file :blip}.should raise_error
76
+ end
77
+
78
+ it "shoud have migraion a :create_account migration with basic setup" do
79
+ nil.should have_migration :create_account do |migration_file|
80
+ migration_file.should have_class_method :up
81
+ migration_file.should have_comment 'hello'
82
+ migration_file.should have_comment 'goodbye'
83
+ end
84
+ end
79
85
  end
80
86
  end
@@ -16,23 +16,23 @@ describe Rails3::Assist::Artifact::View::FileName do
16
16
 
17
17
  describe '#view_file_name' do
18
18
  it "should return the file name for the persons/show view with default action" do
19
- CLASS.view_file_name(:person).should match 'views/person/show'.to_regexp
20
- end
21
-
22
- it "should return the file name for the persons/show view with default type" do
23
19
  CLASS.view_file_name(:person, :show).should match 'views/person/show'.to_regexp
24
20
  end
25
21
 
26
22
  it "should return the file name for the persons/show view with template type" do
27
- CLASS.view_file_name(:person, :show, 'erb.hml').should match 'views/person/show'.to_regexp
23
+ CLASS.view_file_name(:person, :show, :type => :erb).should match 'views/person/show'.to_regexp
28
24
  end
29
-
25
+
30
26
  it "should return the file name for the persons/show view using hash" do
31
- CLASS.view_file_name(:person, :action => :show, :type => 'erb.hml').should match 'views/person/show'.to_regexp
27
+ CLASS.view_file_name(:folder => :person, :action => :show, :type => 'erb.hml').should match 'views/person/show'.to_regexp
32
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 => Rails3::Assist::Directory.rails_root).should match 'views/person/show'.to_regexp
32
+ end
33
33
 
34
34
  it "should return the file name for the persons/show view with root path" do
35
- CLASS.view_file_name(:person, :action => :show, :type => 'erb.hml', :root_path => Rails3::Assist::Directory.rails_root).should match 'views/person/show'.to_regexp
35
+ CLASS.view_file_name(:folder => :person, :action => :show, :type => :erb, :views_path => 'my/views').should match 'views/person/show'.to_regexp
36
36
  end
37
37
  end
38
38
  end
@@ -34,7 +34,7 @@ describe Rails3::Assist::Artifact::Permit do
34
34
 
35
35
  describe '#permit_marker' do
36
36
  it "should return the class marker for permit :person" do
37
- @clazz.permit_marker(:person).should == 'Person'
37
+ @clazz.permit_marker(:person).should == 'PersonPermit < Permit::Base'
38
38
  end
39
39
  end
40
40
  end
@@ -3,6 +3,10 @@ require 'spec_helper'
3
3
  describe 'model with active_record' do
4
4
  use_orm :active_record
5
5
 
6
+ before do
7
+ Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
8
+ end
9
+
6
10
  before :each do
7
11
  remove_model :account
8
12
  create_model :account do
@@ -12,7 +16,7 @@ describe 'model with active_record' do
12
16
  end
13
17
 
14
18
  after :each do
15
- # remove_model :account
19
+ remove_model :account
16
20
  end
17
21
 
18
22
  it "should have an account_model file that contains an index method and two inserted comments" do
@@ -3,6 +3,10 @@ require 'spec_helper'
3
3
  describe 'model with DataMapper' do
4
4
  use_orm :data_mapper
5
5
 
6
+ before do
7
+ Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
8
+ end
9
+
6
10
  before :each do
7
11
  remove_model :account
8
12
  create_model :account do
@@ -3,6 +3,10 @@ require 'spec_helper'
3
3
  describe 'model with Mongo Mapper' do
4
4
  use_orm :mongo_mapper
5
5
 
6
+ before do
7
+ Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
8
+ end
9
+
6
10
  before :each do
7
11
  remove_model :account
8
12
  create_model :account do
@@ -3,6 +3,10 @@ require 'spec_helper'
3
3
  describe 'model with Mongoid' do
4
4
  use_orm :mongoid
5
5
 
6
+ before do
7
+ Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
8
+ end
9
+
6
10
  before :each do
7
11
  remove_model :account
8
12
  create_model :account do
@@ -3,6 +3,10 @@ require 'spec_helper'
3
3
  describe 'model without any orm' do
4
4
  use_orm :none
5
5
 
6
+ before do
7
+ Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
8
+ end
9
+
6
10
  before :each do
7
11
  remove_model :account
8
12
  create_model :account do
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'rspec/core'
2
- # require 'autotest/rspec2'
3
2
  require 'rails3_artifactor'
4
3
  require 'rails3_artifactor/rspec'
5
4
  require 'code-spec'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-21 00:00:00 +02:00
17
+ date: 2010-11-20 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -28,13 +28,29 @@ dependencies:
28
28
  segments:
29
29
  - 2
30
30
  - 0
31
- version: "2.0"
31
+ - 0
32
+ version: 2.0.0
32
33
  type: :development
33
34
  version_requirements: *id001
34
35
  - !ruby/object:Gem::Dependency
35
- name: rspec
36
+ name: generator-spec
36
37
  prerelease: false
37
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ - 7
46
+ - 0
47
+ version: 0.7.0
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
38
54
  none: false
39
55
  requirements:
40
56
  - - ">="
@@ -45,11 +61,11 @@ dependencies:
45
61
  - 0
46
62
  version: 2.0.0
47
63
  type: :runtime
48
- version_requirements: *id002
64
+ version_requirements: *id003
49
65
  - !ruby/object:Gem::Dependency
50
66
  name: require_all
51
67
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
53
69
  none: false
54
70
  requirements:
55
71
  - - ~>
@@ -60,11 +76,11 @@ dependencies:
60
76
  - 0
61
77
  version: 1.2.0
62
78
  type: :runtime
63
- version_requirements: *id003
79
+ version_requirements: *id004
64
80
  - !ruby/object:Gem::Dependency
65
81
  name: sugar-high
66
82
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
83
+ requirement: &id005 !ruby/object:Gem::Requirement
68
84
  none: false
69
85
  requirements:
70
86
  - - ~>
@@ -75,11 +91,11 @@ dependencies:
75
91
  - 0
76
92
  version: 0.3.0
77
93
  type: :runtime
78
- version_requirements: *id004
94
+ version_requirements: *id005
79
95
  - !ruby/object:Gem::Dependency
80
96
  name: rails3_assist
81
97
  prerelease: false
82
- requirement: &id005 !ruby/object:Gem::Requirement
98
+ requirement: &id006 !ruby/object:Gem::Requirement
83
99
  none: false
84
100
  requirements:
85
101
  - - ~>
@@ -90,11 +106,11 @@ dependencies:
90
106
  - 0
91
107
  version: 0.3.0
92
108
  type: :runtime
93
- version_requirements: *id005
109
+ version_requirements: *id006
94
110
  - !ruby/object:Gem::Dependency
95
111
  name: migration_assist
96
112
  prerelease: false
97
- requirement: &id006 !ruby/object:Gem::Requirement
113
+ requirement: &id007 !ruby/object:Gem::Requirement
98
114
  none: false
99
115
  requirements:
100
116
  - - ~>
@@ -105,7 +121,7 @@ dependencies:
105
121
  - 4
106
122
  version: 0.1.4
107
123
  type: :runtime
108
- version_requirements: *id006
124
+ version_requirements: *id007
109
125
  description: Helpers for handling Rails 3 artifacts in general, such as CRUD operations etc.
110
126
  email: kmandrup@gmail.com
111
127
  executables: []