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.
- data/README.markdown +10 -3
- data/VERSION +1 -1
- data/lib/rails3_assist/app.rb +7 -41
- data/lib/rails3_assist/artifact/directory.rb +42 -0
- data/lib/rails3_assist/artifact/files.rb +63 -0
- data/lib/rails3_assist/artifact/path.rb +16 -0
- data/lib/rails3_assist/artifact.rb +34 -0
- data/lib/rails3_assist/directory/app.rb +17 -0
- data/lib/rails3_assist/directory/container.rb +24 -0
- data/lib/rails3_assist/directory/root.rb +20 -0
- data/lib/rails3_assist/directory.rb +55 -0
- data/lib/rails3_assist/file/application.rb +14 -0
- data/lib/rails3_assist/file/environment.rb +15 -0
- data/lib/rails3_assist/file/special.rb +48 -0
- data/lib/rails3_assist/file.rb +38 -0
- data/lib/rails3_assist/files.rb +83 -0
- data/lib/rails3_assist/namespaces.rb +11 -0
- data/lib/rails3_assist/rspec/configure.rb +2 -0
- data/lib/rails3_assist/rspec/matchers/have_app_config.rb +49 -0
- data/{spec/rails3_assist/app/app_file_names_spec.rb → lib/rails3_assist/rspec/matchers/have_special_file.rb} +0 -0
- data/lib/rails3_assist.rb +20 -11
- data/rails3_assist.gemspec +140 -49
- data/spec/fixtures/.gitignore +4 -0
- data/spec/fixtures/Gemfile +30 -0
- data/spec/fixtures/Gemfile.lock +73 -0
- data/spec/fixtures/README +256 -0
- data/spec/fixtures/Rakefile +7 -0
- data/spec/fixtures/app/controllers/application_controller.rb +3 -0
- data/spec/fixtures/app/controllers/users_controller.rb +83 -0
- data/spec/fixtures/app/helpers/application_helper.rb +2 -0
- data/spec/fixtures/app/helpers/users_helper.rb +2 -0
- data/spec/{rails3_assist/app/app_files_spec.rb → fixtures/app/mailers/user_mailer.rb} +0 -0
- data/spec/fixtures/app/models/user.rb +2 -0
- data/spec/fixtures/app/models/user_observer.rb +0 -0
- data/spec/fixtures/app/permits/user_permit.rb +0 -0
- data/spec/fixtures/app/views/layouts/application.html.erb +14 -0
- data/spec/fixtures/app/views/users/_form.html.erb +21 -0
- data/spec/fixtures/app/views/users/edit.html.erb +6 -0
- data/spec/fixtures/app/views/users/index.html.erb +23 -0
- data/spec/fixtures/app/views/users/new.html.erb +5 -0
- data/spec/fixtures/app/views/users/show.html.erb +10 -0
- data/spec/fixtures/config/application.rb +42 -0
- data/spec/fixtures/config/boot.rb +13 -0
- data/spec/fixtures/config/database.yml +22 -0
- data/spec/fixtures/config/environment.rb +5 -0
- data/spec/fixtures/config/environments/development.rb +26 -0
- data/spec/fixtures/config/environments/production.rb +49 -0
- data/spec/fixtures/config/environments/test.rb +35 -0
- data/spec/fixtures/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/config/initializers/inflections.rb +10 -0
- data/spec/fixtures/config/initializers/mime_types.rb +5 -0
- data/spec/fixtures/config/initializers/secret_token.rb +7 -0
- data/spec/fixtures/config/initializers/session_store.rb +8 -0
- data/spec/fixtures/config/locales/en.yml +5 -0
- data/spec/fixtures/config/routes.rb +60 -0
- data/spec/fixtures/config.ru +4 -0
- data/spec/fixtures/db/migrate/20100831135208_create_users.rb +13 -0
- data/spec/fixtures/db/seeds.rb +7 -0
- data/spec/fixtures/doc/README_FOR_APP +2 -0
- data/spec/fixtures/lib/tasks/.gitkeep +0 -0
- data/spec/fixtures/public/404.html +26 -0
- data/spec/fixtures/public/422.html +26 -0
- data/spec/fixtures/public/500.html +26 -0
- data/spec/fixtures/public/favicon.ico +0 -0
- data/spec/fixtures/public/images/rails.png +0 -0
- data/spec/fixtures/public/index.html +239 -0
- data/spec/fixtures/public/javascripts/application.js +2 -0
- data/spec/fixtures/public/javascripts/controls.js +965 -0
- data/spec/fixtures/public/javascripts/dragdrop.js +974 -0
- data/spec/fixtures/public/javascripts/effects.js +1123 -0
- data/spec/fixtures/public/javascripts/prototype.js +6001 -0
- data/spec/fixtures/public/javascripts/rails.js +175 -0
- data/spec/fixtures/public/robots.txt +5 -0
- data/spec/fixtures/public/stylesheets/.gitkeep +0 -0
- data/spec/fixtures/public/stylesheets/scaffold.css +56 -0
- data/spec/fixtures/script/rails +6 -0
- data/spec/fixtures/test/fixtures/users.yml +7 -0
- data/spec/fixtures/test/functional/users_controller_test.rb +49 -0
- data/spec/fixtures/test/performance/browsing_test.rb +9 -0
- data/spec/fixtures/test/test_helper.rb +13 -0
- data/spec/fixtures/test/unit/helpers/users_helper_test.rb +4 -0
- data/spec/fixtures/test/unit/user_test.rb +8 -0
- data/spec/fixtures/vendor/plugins/.gitkeep +0 -0
- data/spec/fixtures.rb +3 -0
- data/spec/rails3_assist/app_spec.rb +30 -0
- data/spec/rails3_assist/artifact/directory_spec.rb +66 -0
- data/spec/rails3_assist/artifact/files_spec.rb +64 -0
- data/spec/rails3_assist/artifact/path_spec.rb +23 -0
- data/spec/rails3_assist/artifact_spec.rb +33 -0
- data/spec/rails3_assist/directory/app_spec.rb +41 -0
- data/spec/rails3_assist/directory/container_spec.rb +63 -0
- data/spec/rails3_assist/directory/root_spec.rb +41 -0
- data/spec/rails3_assist/directory_spec.rb +59 -0
- data/spec/rails3_assist/file/application_spec.rb +33 -0
- data/spec/rails3_assist/file/environment_spec.rb +49 -0
- data/spec/rails3_assist/file/special_spec.rb +61 -0
- data/spec/rails3_assist/file_spec.rb +48 -0
- data/spec/rails3_assist/files_spec.rb +128 -0
- data/spec/rails3_assist/rspec/have_app_config_spec.rb +0 -0
- data/spec/spec_helper.rb +4 -2
- metadata +140 -49
- data/lib/rails3_assist/app/file_names.rb +0 -97
- data/lib/rails3_assist/app/methods/crud.rb +0 -31
- data/lib/rails3_assist/app/methods/new_content.rb +0 -11
- data/lib/rails3_assist/app/rails_dirs.rb +0 -106
- data/lib/rails3_assist/app/rails_files.rb +0 -128
- data/lib/rails3_assist/artifact/markers.rb +0 -45
- data/lib/rails3_assist/artifact/migration.rb +0 -10
- data/lib/rails3_assist/artifact/orm.rb +0 -136
- data/lib/rails3_assist/artifact/view.rb +0 -70
- data/lib/rails3_assist/base/class_methods.rb +0 -11
- data/lib/rails3_assist/base/create.rb +0 -48
- data/lib/rails3_assist/base/file_name.rb +0 -40
- data/lib/rails3_assist/base/insert.rb +0 -57
- data/lib/rails3_assist/base/read.rb +0 -19
- data/lib/rails3_assist/base/remove.rb +0 -14
- data/lib/rails3_assist/base.rb +0 -49
- data/lib/rails3_assist/extensions/core_ext.rb +0 -29
- data/lib/rails3_assist/rspec/macro.rb +0 -34
- data/spec/rails3_assist/app/app_dirs_spec.rb +0 -23
- data/spec/rails3_assist/artifact/controller/controller_spec.rb +0 -33
- data/spec/rails3_assist/artifact/helper/helper_spec.rb +0 -33
- data/spec/rails3_assist/artifact/mailer/mailer_spec.rb +0 -33
- data/spec/rails3_assist/artifact/migration/migration_spec.rb +0 -49
- data/spec/rails3_assist/artifact/model/model_spec.rb +0 -34
- data/spec/rails3_assist/artifact/observer/observer_spec.rb +0 -34
- data/spec/rails3_assist/artifact/orm/active_record_spec.rb +0 -33
- data/spec/rails3_assist/artifact/orm/mongo_mapper_spec.rb +0 -63
- data/spec/rails3_assist/artifact/orm/mongoid_spec.rb +0 -63
- data/spec/rails3_assist/artifact/view_spec/view_controller_action_spec.rb +0 -65
- data/spec/rails3_assist/artifact/view_spec/view_controller_default_action_specc.rb +0 -32
@@ -0,0 +1,175 @@
|
|
1
|
+
(function() {
|
2
|
+
// Technique from Juriy Zaytsev
|
3
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
+
function isEventSupported(eventName) {
|
5
|
+
var el = document.createElement('div');
|
6
|
+
eventName = 'on' + eventName;
|
7
|
+
var isSupported = (eventName in el);
|
8
|
+
if (!isSupported) {
|
9
|
+
el.setAttribute(eventName, 'return;');
|
10
|
+
isSupported = typeof el[eventName] == 'function';
|
11
|
+
}
|
12
|
+
el = null;
|
13
|
+
return isSupported;
|
14
|
+
}
|
15
|
+
|
16
|
+
function isForm(element) {
|
17
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
18
|
+
}
|
19
|
+
|
20
|
+
function isInput(element) {
|
21
|
+
if (Object.isElement(element)) {
|
22
|
+
var name = element.nodeName.toUpperCase()
|
23
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
24
|
+
}
|
25
|
+
else return false
|
26
|
+
}
|
27
|
+
|
28
|
+
var submitBubbles = isEventSupported('submit'),
|
29
|
+
changeBubbles = isEventSupported('change')
|
30
|
+
|
31
|
+
if (!submitBubbles || !changeBubbles) {
|
32
|
+
// augment the Event.Handler class to observe custom events when needed
|
33
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
+
function(init, element, eventName, selector, callback) {
|
35
|
+
init(element, eventName, selector, callback)
|
36
|
+
// is the handler being attached to an element that doesn't support this event?
|
37
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
+
// "submit" => "emulated:submit"
|
40
|
+
this.eventName = 'emulated:' + this.eventName
|
41
|
+
}
|
42
|
+
}
|
43
|
+
)
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!submitBubbles) {
|
47
|
+
// discover forms on the page by observing focus events which always bubble
|
48
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
+
// special handler for the real "submit" event (one-time operation)
|
50
|
+
if (!form.retrieve('emulated:submit')) {
|
51
|
+
form.on('submit', function(submitEvent) {
|
52
|
+
var emulated = form.fire('emulated:submit', submitEvent, true)
|
53
|
+
// if custom event received preventDefault, cancel the real one too
|
54
|
+
if (emulated.returnValue === false) submitEvent.preventDefault()
|
55
|
+
})
|
56
|
+
form.store('emulated:submit', true)
|
57
|
+
}
|
58
|
+
})
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!changeBubbles) {
|
62
|
+
// discover form inputs on the page
|
63
|
+
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
64
|
+
// special handler for real "change" events
|
65
|
+
if (!input.retrieve('emulated:change')) {
|
66
|
+
input.on('change', function(changeEvent) {
|
67
|
+
input.fire('emulated:change', changeEvent, true)
|
68
|
+
})
|
69
|
+
input.store('emulated:change', true)
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
function handleRemote(element) {
|
75
|
+
var method, url, params;
|
76
|
+
|
77
|
+
var event = element.fire("ajax:before");
|
78
|
+
if (event.stopped) return false;
|
79
|
+
|
80
|
+
if (element.tagName.toLowerCase() === 'form') {
|
81
|
+
method = element.readAttribute('method') || 'post';
|
82
|
+
url = element.readAttribute('action');
|
83
|
+
params = element.serialize();
|
84
|
+
} else {
|
85
|
+
method = element.readAttribute('data-method') || 'get';
|
86
|
+
url = element.readAttribute('href');
|
87
|
+
params = {};
|
88
|
+
}
|
89
|
+
|
90
|
+
new Ajax.Request(url, {
|
91
|
+
method: method,
|
92
|
+
parameters: params,
|
93
|
+
evalScripts: true,
|
94
|
+
|
95
|
+
onComplete: function(request) { element.fire("ajax:complete", request); },
|
96
|
+
onSuccess: function(request) { element.fire("ajax:success", request); },
|
97
|
+
onFailure: function(request) { element.fire("ajax:failure", request); }
|
98
|
+
});
|
99
|
+
|
100
|
+
element.fire("ajax:after");
|
101
|
+
}
|
102
|
+
|
103
|
+
function handleMethod(element) {
|
104
|
+
var method = element.readAttribute('data-method'),
|
105
|
+
url = element.readAttribute('href'),
|
106
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
107
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
108
|
+
|
109
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
110
|
+
element.parentNode.insert(form);
|
111
|
+
|
112
|
+
if (method !== 'post') {
|
113
|
+
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
114
|
+
form.insert(field);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (csrf_param) {
|
118
|
+
var param = csrf_param.readAttribute('content'),
|
119
|
+
token = csrf_token.readAttribute('content'),
|
120
|
+
field = new Element('input', { type: 'hidden', name: param, value: token });
|
121
|
+
form.insert(field);
|
122
|
+
}
|
123
|
+
|
124
|
+
form.submit();
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
document.on("click", "*[data-confirm]", function(event, element) {
|
129
|
+
var message = element.readAttribute('data-confirm');
|
130
|
+
if (!confirm(message)) event.stop();
|
131
|
+
});
|
132
|
+
|
133
|
+
document.on("click", "a[data-remote]", function(event, element) {
|
134
|
+
if (event.stopped) return;
|
135
|
+
handleRemote(element);
|
136
|
+
event.stop();
|
137
|
+
});
|
138
|
+
|
139
|
+
document.on("click", "a[data-method]", function(event, element) {
|
140
|
+
if (event.stopped) return;
|
141
|
+
handleMethod(element);
|
142
|
+
event.stop();
|
143
|
+
});
|
144
|
+
|
145
|
+
document.on("submit", function(event) {
|
146
|
+
var element = event.findElement(),
|
147
|
+
message = element.readAttribute('data-confirm');
|
148
|
+
if (message && !confirm(message)) {
|
149
|
+
event.stop();
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
|
153
|
+
var inputs = element.select("input[type=submit][data-disable-with]");
|
154
|
+
inputs.each(function(input) {
|
155
|
+
input.disabled = true;
|
156
|
+
input.writeAttribute('data-original-value', input.value);
|
157
|
+
input.value = input.readAttribute('data-disable-with');
|
158
|
+
});
|
159
|
+
|
160
|
+
var element = event.findElement("form[data-remote]");
|
161
|
+
if (element) {
|
162
|
+
handleRemote(element);
|
163
|
+
event.stop();
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
document.on("ajax:after", "form", function(event, element) {
|
168
|
+
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
169
|
+
inputs.each(function(input) {
|
170
|
+
input.value = input.readAttribute('data-original-value');
|
171
|
+
input.removeAttribute('data-original-value');
|
172
|
+
input.disabled = false;
|
173
|
+
});
|
174
|
+
});
|
175
|
+
})();
|
File without changes
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UsersControllerTest < ActionController::TestCase
|
4
|
+
setup do
|
5
|
+
@user = users(:one)
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should get index" do
|
9
|
+
get :index
|
10
|
+
assert_response :success
|
11
|
+
assert_not_nil assigns(:users)
|
12
|
+
end
|
13
|
+
|
14
|
+
test "should get new" do
|
15
|
+
get :new
|
16
|
+
assert_response :success
|
17
|
+
end
|
18
|
+
|
19
|
+
test "should create user" do
|
20
|
+
assert_difference('User.count') do
|
21
|
+
post :create, :user => @user.attributes
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_redirected_to user_path(assigns(:user))
|
25
|
+
end
|
26
|
+
|
27
|
+
test "should show user" do
|
28
|
+
get :show, :id => @user.to_param
|
29
|
+
assert_response :success
|
30
|
+
end
|
31
|
+
|
32
|
+
test "should get edit" do
|
33
|
+
get :edit, :id => @user.to_param
|
34
|
+
assert_response :success
|
35
|
+
end
|
36
|
+
|
37
|
+
test "should update user" do
|
38
|
+
put :update, :id => @user.to_param, :user => @user.attributes
|
39
|
+
assert_redirected_to user_path(assigns(:user))
|
40
|
+
end
|
41
|
+
|
42
|
+
test "should destroy user" do
|
43
|
+
assert_difference('User.count', -1) do
|
44
|
+
delete :destroy, :id => @user.to_param
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_redirected_to users_path
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rails/test_help'
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
7
|
+
#
|
8
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
9
|
+
# -- they do not yet inherit this setting
|
10
|
+
fixtures :all
|
11
|
+
|
12
|
+
# Add more helper methods to be used by all tests here...
|
13
|
+
end
|
File without changes
|
data/spec/fixtures.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
CLASS = Rails3::Assist::App
|
4
|
+
|
5
|
+
class Helper
|
6
|
+
include Rails3::Assist::App
|
7
|
+
include Rails3::Assist::Directory
|
8
|
+
include Rails3::Assist::Artifact
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'controller' do
|
12
|
+
before do
|
13
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
14
|
+
@helper = Helper.new
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
remove_temp_dir 'tmp_rails'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should create basic root directories" do
|
22
|
+
CLASS.create_empty_tmp @helper.root_directories
|
23
|
+
@helper.root_dir.should have_dirs(@helper.root_directories)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have basic app directories" do
|
27
|
+
@helper.create_empty_tmp @helper.app_artifacts
|
28
|
+
@helper.app_dir.should have_dirs(@helper.app_directories)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
CLASS = Rails3::Assist::Artifact::Directory
|
4
|
+
|
5
|
+
class ArtDir
|
6
|
+
include CLASS
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Rails3::Assist::Artifact::Directory do
|
10
|
+
# use_helper :directories
|
11
|
+
|
12
|
+
before do
|
13
|
+
Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
|
14
|
+
@test = ArtDir.new
|
15
|
+
end
|
16
|
+
|
17
|
+
Rails3::Assist::Artifact.app_artifacts.each do |name|
|
18
|
+
eval %{
|
19
|
+
describe '##{name}_dir' do
|
20
|
+
it "should return #{name} directory name" do
|
21
|
+
CLASS.#{name}_dir.should match /app\/\#{name}/
|
22
|
+
@test.#{name}_dir.should match /app\/\#{name}/
|
23
|
+
end
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#observer_dir' do
|
29
|
+
it "should return observer directory name" do
|
30
|
+
CLASS.observer_dir.should match /app\/models/
|
31
|
+
@test.observer_dir.should match /app\/models/
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#migration_dir' do
|
36
|
+
it "should return migration directory name" do
|
37
|
+
CLASS.migration_dir.should match /db\/migration/
|
38
|
+
@test.migration_dir.should match /db\/migration/
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
[:initializer, :locale].each do |name|
|
45
|
+
eval %{
|
46
|
+
describe '##{name}_dir' do
|
47
|
+
it "should return #{name} directory name" do
|
48
|
+
CLASS.#{name}_dir.should match /config\/\#{name}/
|
49
|
+
@test.#{name}_dir.should match /config\/\#{name}/
|
50
|
+
end
|
51
|
+
end
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
[:stylesheet, :javascript].each do |name|
|
56
|
+
eval %{
|
57
|
+
describe '##{name}_dir' do
|
58
|
+
it "should return #{name} directory name" do
|
59
|
+
CLASS.#{name}_dir.should match /public\/\#{name}/
|
60
|
+
@test.#{name}_dir.should match /public\/\#{name}/
|
61
|
+
end
|
62
|
+
end
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
CLASS = Rails3::Assist::Artifact::Files
|
4
|
+
|
5
|
+
class ArtDir
|
6
|
+
include CLASS
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Rails3::Assist::Artifact::Files do
|
10
|
+
# use_helper :directories
|
11
|
+
|
12
|
+
before do
|
13
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
14
|
+
@test = ArtDir.new
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#model_files' do
|
18
|
+
it "should return :model files" do
|
19
|
+
@test.model_files.file_names.should include 'user.rb'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#mailer_files' do
|
24
|
+
it "should return :mailer files" do
|
25
|
+
puts @test.mailer_files.file_names.should include 'user_mailer.rb'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#observer_files' do
|
30
|
+
it "should return :observer files" do
|
31
|
+
puts @test.observer_files.file_names.should include 'user_observer.rb'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#permit_files' do
|
36
|
+
it "should return :permit files" do
|
37
|
+
puts @test.permit_files.file_names.should include 'user_permit.rb'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#helper_files' do
|
42
|
+
it "should return :helper files" do
|
43
|
+
@test.helper_files.file_names.should include 'users_helper.rb'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#controller_files' do
|
48
|
+
it "should return :controller files" do
|
49
|
+
@test.controller_files.file_names.should include 'users_controller.rb'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#view_files' do
|
54
|
+
it "should return :view files" do
|
55
|
+
@test.view_files(:user).file_names.should include 'show.html.erb'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#erb_view_files' do
|
60
|
+
it "should return erb :view files" do
|
61
|
+
@test.erb_view_files(:user).file_names.should include 'show.html.erb'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
CLASS = Rails3::Assist::Artifact::Path
|
4
|
+
|
5
|
+
class ArtDir
|
6
|
+
include CLASS
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Rails3::Assist::Artifact::Path do
|
10
|
+
# use_helper :directories
|
11
|
+
|
12
|
+
before do
|
13
|
+
Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
|
14
|
+
@test = ArtDir.new
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#artifact_path' do
|
18
|
+
it "should return mailer directory name" do
|
19
|
+
@test.artifact_path(:my_mailer, :mailer)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
CLASS = Rails3::Assist::Artifact
|
4
|
+
|
5
|
+
class ArtDir
|
6
|
+
include CLASS
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Rails3::Assist::Artifact do
|
10
|
+
# use_helper :directories
|
11
|
+
|
12
|
+
before do
|
13
|
+
Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
|
14
|
+
@test = ArtDir.new
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#self.rails_artifacts' do
|
18
|
+
it "should return mailer directory name" do
|
19
|
+
CLASS.rails_artifacts.should include :mailer, :model
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#valid_artifact?' do
|
24
|
+
it "should be true that :model is a valid artifact" do
|
25
|
+
CLASS.valid_artifact?(:model).should be_true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be false that :unknown is a valid artifact" do
|
29
|
+
CLASS.valid_artifact?(:unknown).should be_false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
CLASS = Rails3::Assist::Directory::App
|
4
|
+
|
5
|
+
class AppDir
|
6
|
+
include CLASS
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Rails3::Assist::Directory::App do
|
10
|
+
# use_helper :directories
|
11
|
+
|
12
|
+
before do
|
13
|
+
Rails3::Assist::Directory.rails_root = File.dirname (__FILE__)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#self.app_directories' do
|
17
|
+
it "should return symbols list of Rails 3 app directories" do
|
18
|
+
CLASS.app_directories.should include :controllers, :mailers, :helpers, :views, :models, :permits
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#app_directories' do
|
23
|
+
it "should return symbols list of Rails 3 app directories" do
|
24
|
+
AppDir.new.app_directories.should include :controllers, :mailers, :helpers, :views, :models, :permits
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
describe '#self.app_dir' do
|
30
|
+
it "should the current Rails 3 ap dir when Rails root is set" do
|
31
|
+
CLASS.app_dir.should == File.join(File.dirname(__FILE__), 'app')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#app_dir' do
|
36
|
+
it "should the current Rails 3 ap dir when Rails root is set" do
|
37
|
+
AppDir.new.app_dir.should == File.join(File.dirname(__FILE__), 'app')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
CLASS = Rails3::Assist::Directory::Container
|
4
|
+
|
5
|
+
class Con
|
6
|
+
include Rails3::Assist::Directory
|
7
|
+
end
|
8
|
+
|
9
|
+
class ConExt
|
10
|
+
extend Rails3::Assist::Directory::Container
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
describe Rails3::Assist::Directory::Container do
|
15
|
+
# use_helper :directories
|
16
|
+
|
17
|
+
context "using module methods directly" do
|
18
|
+
describe '#rails_containers' do
|
19
|
+
it "should return symbols list of rails 3 artifact containers" do
|
20
|
+
CLASS.rails_containers.should include :controller, :mailer, :helper, :view, :model, :permit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#valid_container?' do
|
25
|
+
it "should return true that since controller is a valid container" do
|
26
|
+
CLASS.valid_container?(:controller).should be_true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return since :unknown is NOT a valid container" do
|
30
|
+
CLASS.valid_container?(:unknown).should be_false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "module included into class" do
|
36
|
+
describe '#rails_containers' do
|
37
|
+
it "should return symbols list of rails 3 artifact containers" do
|
38
|
+
Con.new.rails_containers.should include :controller, :mailer, :helper, :view, :model, :permit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#valid_container?' do
|
43
|
+
it "should return true that since controller is a valid container" do
|
44
|
+
Con.new.valid_container?(:controller).should be_true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "module extended into class" do
|
50
|
+
describe '#rails_containers' do
|
51
|
+
it "should return symbols list of rails 3 artifact containers" do
|
52
|
+
ConExt.rails_containers.should include :controller, :mailer, :helper, :view, :model, :permit
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#valid_container?' do
|
57
|
+
it "should return true that since controller is a valid container" do
|
58
|
+
ConExt.valid_container?(:controller).should be_true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|