rich_support 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/.gitignore +9 -0
- data/.suit +4 -0
- data/CHANGELOG.rdoc +5 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +141 -0
- data/Rakefile +29 -0
- data/VERSION +1 -0
- data/lib/rich/support/actionpack/action_controller/test_case.rb +28 -0
- data/lib/rich/support/actionpack.rb +3 -0
- data/lib/rich/support/activesupport/active_support/dependencies.rb +12 -0
- data/lib/rich/support/activesupport.rb +3 -0
- data/lib/rich/support/core/string/colorize.rb +41 -0
- data/lib/rich/support/core/string/html_safe.rb +17 -0
- data/lib/rich/support/core/string/inflections.rb +39 -0
- data/lib/rich/support/core/string.rb +7 -0
- data/lib/rich/support/core.rb +2 -0
- data/lib/rich/support/rails/engine.rb +4 -0
- data/lib/rich/support/rails.rb +3 -0
- data/lib/rich/support/test/unit/test_case.rb +92 -0
- data/lib/rich/support/test.rb +3 -0
- data/lib/rich/support/version.rb +11 -0
- data/lib/rich/support.rb +51 -0
- data/lib/rich_support.rb +7 -0
- data/rich_support.gemspec +21 -0
- data/suit/rails-2/dummy/Gemfile +14 -0
- data/suit/rails-2/dummy/README +243 -0
- data/suit/rails-2/dummy/Rakefile +10 -0
- data/suit/rails-2/dummy/app/controllers/application_controller.rb +10 -0
- data/suit/rails-2/dummy/app/helpers/application_helper.rb +3 -0
- data/suit/rails-2/dummy/config/boot.rb +128 -0
- data/suit/rails-2/dummy/config/database.yml +22 -0
- data/suit/rails-2/dummy/config/environment.rb +41 -0
- data/suit/rails-2/dummy/config/environments/development.rb +17 -0
- data/suit/rails-2/dummy/config/environments/production.rb +28 -0
- data/suit/rails-2/dummy/config/environments/test.rb +28 -0
- data/suit/rails-2/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/suit/rails-2/dummy/config/initializers/cookie_verification_secret.rb +7 -0
- data/suit/rails-2/dummy/config/initializers/inflections.rb +10 -0
- data/suit/rails-2/dummy/config/initializers/mime_types.rb +5 -0
- data/suit/rails-2/dummy/config/initializers/new_rails_defaults.rb +21 -0
- data/suit/rails-2/dummy/config/initializers/session_store.rb +15 -0
- data/suit/rails-2/dummy/config/locales/en.yml +5 -0
- data/suit/rails-2/dummy/config/preinitializer.rb +20 -0
- data/suit/rails-2/dummy/config/routes.rb +43 -0
- data/suit/rails-2/dummy/db/schema.rb +2 -0
- data/suit/rails-2/dummy/db/seeds.rb +7 -0
- data/suit/rails-2/dummy/doc/README_FOR_APP +2 -0
- data/suit/rails-2/dummy/script/about +4 -0
- data/suit/rails-2/dummy/script/console +3 -0
- data/suit/rails-2/dummy/script/dbconsole +3 -0
- data/suit/rails-2/dummy/script/destroy +3 -0
- data/suit/rails-2/dummy/script/generate +3 -0
- data/suit/rails-2/dummy/script/performance/benchmarker +3 -0
- data/suit/rails-2/dummy/script/performance/profiler +3 -0
- data/suit/rails-2/dummy/script/plugin +3 -0
- data/suit/rails-2/dummy/script/runner +3 -0
- data/suit/rails-2/dummy/script/server +3 -0
- data/suit/rails-3/dummy/.gitignore +4 -0
- data/suit/rails-3/dummy/Gemfile +14 -0
- data/suit/rails-3/dummy/README +256 -0
- data/suit/rails-3/dummy/Rakefile +7 -0
- data/suit/rails-3/dummy/app/controllers/application_controller.rb +3 -0
- data/suit/rails-3/dummy/app/helpers/application_helper.rb +2 -0
- data/suit/rails-3/dummy/config/application.rb +42 -0
- data/suit/rails-3/dummy/config/boot.rb +6 -0
- data/suit/rails-3/dummy/config/database.yml +22 -0
- data/suit/rails-3/dummy/config/environment.rb +5 -0
- data/suit/rails-3/dummy/config/environments/development.rb +26 -0
- data/suit/rails-3/dummy/config/environments/production.rb +49 -0
- data/suit/rails-3/dummy/config/environments/test.rb +35 -0
- data/suit/rails-3/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/suit/rails-3/dummy/config/initializers/inflections.rb +10 -0
- data/suit/rails-3/dummy/config/initializers/mime_types.rb +5 -0
- data/suit/rails-3/dummy/config/initializers/secret_token.rb +7 -0
- data/suit/rails-3/dummy/config/initializers/session_store.rb +8 -0
- data/suit/rails-3/dummy/config/locales/en.yml +5 -0
- data/suit/rails-3/dummy/config/routes.rb +58 -0
- data/suit/rails-3/dummy/config.ru +4 -0
- data/suit/rails-3/dummy/db/schema.rb +2 -0
- data/suit/rails-3/dummy/db/seeds.rb +7 -0
- data/suit/rails-3/dummy/doc/README_FOR_APP +2 -0
- data/suit/rails-3/dummy/lib/tasks/.gitkeep +0 -0
- data/suit/rails-3/dummy/script/rails +6 -0
- data/suit/rails-3/dummy/vendor/plugins/.gitkeep +0 -0
- data/suit/shared/app/models/.gitkeep +0 -0
- data/suit/shared/app/views/application/index.html.erb +16 -0
- data/suit/shared/app/views/layouts/application.html.erb +11 -0
- data/suit/shared/db/schema.rb +2 -0
- data/suit/shared/db/seeds.rb +7 -0
- data/suit/shared/public/404.html +26 -0
- data/suit/shared/public/422.html +26 -0
- data/suit/shared/public/500.html +26 -0
- data/suit/shared/public/favicon.ico +0 -0
- data/suit/shared/public/images/rails.png +0 -0
- data/suit/shared/public/javascripts/application.js +2 -0
- data/suit/shared/public/javascripts/controls.js +965 -0
- data/suit/shared/public/javascripts/dragdrop.js +974 -0
- data/suit/shared/public/javascripts/effects.js +1123 -0
- data/suit/shared/public/javascripts/prototype.js +6001 -0
- data/suit/shared/public/javascripts/rails.js +191 -0
- data/suit/shared/public/robots.txt +5 -0
- data/suit/shared/public/stylesheets/.gitkeep +0 -0
- data/suit/shared/public/stylesheets/app.css +99 -0
- data/suit/shared/test/fixtures/.gitkeep +0 -0
- data/suit/shared/test/integration/suit/example.rb +40 -0
- data/suit/shared/test/suit_application/capybara_extensions.rb +32 -0
- data/suit/shared/test/suit_application.rb +27 -0
- data/suit/shared/test/test_helper.rb +37 -0
- data/suit/shared/test/unit/.gitkeep +0 -0
- data/suit/shared/test/unit/actionpack/action_controller/routing_test.rb +14 -0
- data/suit/shared/test/unit/actionpack/action_controller/test_case_test.rb +17 -0
- data/suit/shared/test/unit/activesupport/active_support/dependencies_test.rb +15 -0
- data/suit/shared/test/unit/core/string/colorize_test.rb +43 -0
- data/suit/shared/test/unit/core/string/html_safe_test.rb +15 -0
- data/suit/shared/test/unit/core/string/inflections_test.rb +51 -0
- data/suit/shared/test/unit/rails/engine_test.rb +13 -0
- data/suit/shared/test/unit/test/unit/test_case_test.rb +19 -0
- data/suit/templates/shared/Gemfile +14 -0
- data/suit/templates/shared/config/database.yml +10 -0
- data/suit/templates/shared/config/initializers/.gitkeep +0 -0
- data/suit/templates/shared/db/schema.rb +2 -0
- metadata +189 -0
|
@@ -0,0 +1,191 @@
|
|
|
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
|
+
|
|
176
|
+
Ajax.Responders.register({
|
|
177
|
+
onCreate: function(request) {
|
|
178
|
+
var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
|
|
179
|
+
|
|
180
|
+
if (csrf_meta_tag) {
|
|
181
|
+
var header = 'X-CSRF-Token',
|
|
182
|
+
token = csrf_meta_tag.readAttribute('content');
|
|
183
|
+
|
|
184
|
+
if (!request.options.requestHeaders) {
|
|
185
|
+
request.options.requestHeaders = {};
|
|
186
|
+
}
|
|
187
|
+
request.options.requestHeaders[header] = token;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
})();
|
|
File without changes
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
* {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding: 0;
|
|
4
|
+
outline: 0; }
|
|
5
|
+
|
|
6
|
+
html, body {
|
|
7
|
+
height: 100%; }
|
|
8
|
+
|
|
9
|
+
body {
|
|
10
|
+
color: #111;
|
|
11
|
+
font-family: Myriad Pro, Arial;
|
|
12
|
+
font-size: 18px;
|
|
13
|
+
line-height: 120%;
|
|
14
|
+
text-shadow: white 0 2px 0;
|
|
15
|
+
background: #E0E0E0; }
|
|
16
|
+
|
|
17
|
+
ol, ul {
|
|
18
|
+
list-style: none; }
|
|
19
|
+
|
|
20
|
+
a {
|
|
21
|
+
padding-bottom: 1px;
|
|
22
|
+
color: #111;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
text-decoration: none; }
|
|
25
|
+
|
|
26
|
+
a:hover {
|
|
27
|
+
text-decoration: underline; }
|
|
28
|
+
|
|
29
|
+
abbr, fieldset, img {
|
|
30
|
+
border: 0; }
|
|
31
|
+
|
|
32
|
+
textarea {
|
|
33
|
+
font-family: Myriad Pro, Arial; }
|
|
34
|
+
|
|
35
|
+
#page {
|
|
36
|
+
width: 750px;
|
|
37
|
+
min-height: 100%;
|
|
38
|
+
margin: 0 auto; }
|
|
39
|
+
|
|
40
|
+
#page div.locales {
|
|
41
|
+
padding-top: 80px;
|
|
42
|
+
text-align: center; }
|
|
43
|
+
|
|
44
|
+
#page div.locales a img {
|
|
45
|
+
margin: 0 2px;
|
|
46
|
+
padding: 2px; }
|
|
47
|
+
|
|
48
|
+
#page div.locales a.selected img {
|
|
49
|
+
padding: 1px;
|
|
50
|
+
border: 1px solid #06F; }
|
|
51
|
+
|
|
52
|
+
#page div.content {
|
|
53
|
+
padding-top: 80px;
|
|
54
|
+
clear: both; }
|
|
55
|
+
|
|
56
|
+
#page div.content h1 {
|
|
57
|
+
margin-bottom: 35px; }
|
|
58
|
+
|
|
59
|
+
#page div.content div.left {
|
|
60
|
+
width: 515px;
|
|
61
|
+
float: left; }
|
|
62
|
+
|
|
63
|
+
#page div.content div.left h3 {
|
|
64
|
+
font-size: 22px;
|
|
65
|
+
margin-bottom: 22px; }
|
|
66
|
+
|
|
67
|
+
#page div.content div.left p {
|
|
68
|
+
margin-bottom: 30px;
|
|
69
|
+
font-size: 18px;
|
|
70
|
+
line-height: 140%; }
|
|
71
|
+
|
|
72
|
+
#page div.content div.left form label {
|
|
73
|
+
display: block;
|
|
74
|
+
font-weight: bold; }
|
|
75
|
+
|
|
76
|
+
#page div.content div.left form .inputs input {
|
|
77
|
+
margin-bottom: 15px;
|
|
78
|
+
width: 350px;
|
|
79
|
+
font-size: 16px; }
|
|
80
|
+
|
|
81
|
+
#page div.content div.left form .inputs textarea {
|
|
82
|
+
width: 400px;
|
|
83
|
+
height: 150px;
|
|
84
|
+
font-size: 18px; }
|
|
85
|
+
|
|
86
|
+
#page div.content div.left form .buttons {
|
|
87
|
+
padding: 15px 0 60px 0; }
|
|
88
|
+
|
|
89
|
+
#page div.content div.left form .buttons input {
|
|
90
|
+
margin-right: 6px;
|
|
91
|
+
font-size: 16px; }
|
|
92
|
+
|
|
93
|
+
#page div.content div.left form .buttons a {
|
|
94
|
+
font-size: 14px; }
|
|
95
|
+
|
|
96
|
+
#page div.content ul {
|
|
97
|
+
width: 175px;
|
|
98
|
+
font-weight: bold;
|
|
99
|
+
float: right; }
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require File.expand_path("../../../suit_application.rb", __FILE__)
|
|
2
|
+
|
|
3
|
+
SuitApplication.test
|
|
4
|
+
|
|
5
|
+
class ExampleTest < GemSuit::IntegrationTest
|
|
6
|
+
|
|
7
|
+
context "My example test" do
|
|
8
|
+
setup do
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
teardown do
|
|
12
|
+
SuitApplication.restore_all
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
should "assert css as expected" do
|
|
16
|
+
visit "/"
|
|
17
|
+
assert page.has_css? "div#page"
|
|
18
|
+
assert page.has_no_css? "div#paul_engel"
|
|
19
|
+
|
|
20
|
+
# Hello World ;)
|
|
21
|
+
page.execute_script <<-SCRIPT
|
|
22
|
+
var div = document.createElement("div");
|
|
23
|
+
div.innerHTML = "<h2>Hi. This is an GemSuit example test!</h2><p><br>Closing in <span id='seconds'>10</span> seconds.</p>";
|
|
24
|
+
var divs = document.getElementsByTagName("div");
|
|
25
|
+
for (var i = 0; i < divs.length; i++) {
|
|
26
|
+
if (divs[i].className == "left") {
|
|
27
|
+
divs[i].appendChild(div);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
SCRIPT
|
|
31
|
+
|
|
32
|
+
# Counting down
|
|
33
|
+
10.times do |i|
|
|
34
|
+
sleep 1
|
|
35
|
+
page.execute_script "document.getElementById('seconds').innerHTML = '#{9 - i}';"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module GemSuit
|
|
2
|
+
class IntegrationTest
|
|
3
|
+
|
|
4
|
+
# def login
|
|
5
|
+
# visit "/login"
|
|
6
|
+
# fill_in_and_submit "form#login", {:Email => "paul.engel@holder.nl", :Password => "test"}, "Login"
|
|
7
|
+
# end
|
|
8
|
+
|
|
9
|
+
# def logout
|
|
10
|
+
# find("a#logout").click_link "Logout"
|
|
11
|
+
# end
|
|
12
|
+
|
|
13
|
+
# def fill_in_and_submit(selector, with, submit)
|
|
14
|
+
# within "#{selector} fieldset.inputs" do
|
|
15
|
+
# with.each do |key, value|
|
|
16
|
+
# begin
|
|
17
|
+
# fill_in key.to_s, :with => value
|
|
18
|
+
# rescue Selenium::WebDriver::Error::ElementNotDisplayedError
|
|
19
|
+
# page.execute_script "var input = $('#{selector} [name=\"#{key}\"]');" +
|
|
20
|
+
# "if (input.data('cleditor')) {" +
|
|
21
|
+
# " input.val('#{value}');" +
|
|
22
|
+
# " input.data('cleditor').updateFrame();" +
|
|
23
|
+
# "}"
|
|
24
|
+
# end
|
|
25
|
+
# end
|
|
26
|
+
# end
|
|
27
|
+
# find(selector).find_button(submit).click
|
|
28
|
+
# sleep 2
|
|
29
|
+
# end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "gem_suit"
|
|
3
|
+
|
|
4
|
+
class SuitApplication < GemSuit::Application
|
|
5
|
+
|
|
6
|
+
# def description
|
|
7
|
+
# "My first GemSuit integration test"
|
|
8
|
+
# end
|
|
9
|
+
|
|
10
|
+
# def prepare
|
|
11
|
+
# generate_something
|
|
12
|
+
# end
|
|
13
|
+
|
|
14
|
+
# def config_for_template(path)
|
|
15
|
+
# case path
|
|
16
|
+
# when "Gemfile"
|
|
17
|
+
# {"rails_gem_version" => "3.0.5"}
|
|
18
|
+
# end
|
|
19
|
+
# end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
# def generate_something
|
|
24
|
+
# generate "your_generator", "some_parameter"
|
|
25
|
+
# end
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "gem_suit/test_help"
|
|
3
|
+
|
|
4
|
+
class ActiveSupport::TestCase
|
|
5
|
+
# Transactional fixtures accelerate your tests by wrapping each test method
|
|
6
|
+
# in a transaction that's rolled back on completion. This ensures that the
|
|
7
|
+
# test database remains unchanged so your fixtures don't have to be reloaded
|
|
8
|
+
# between every test method. Fewer database queries means faster tests.
|
|
9
|
+
#
|
|
10
|
+
# Read Mike Clark's excellent walkthrough at
|
|
11
|
+
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
|
12
|
+
#
|
|
13
|
+
# Every Active Record database supports transactions except MyISAM tables
|
|
14
|
+
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
|
15
|
+
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
|
16
|
+
# is recommended.
|
|
17
|
+
#
|
|
18
|
+
# The only drawback to using transactional fixtures is when you actually
|
|
19
|
+
# need to test transactions. Since your test is bracketed by a transaction,
|
|
20
|
+
# any transactions started in your code will be automatically rolled back.
|
|
21
|
+
self.use_transactional_fixtures = true
|
|
22
|
+
|
|
23
|
+
# Instantiated fixtures are slow, but give you @david where otherwise you
|
|
24
|
+
# would need people(:david). If you don't want to migrate your existing
|
|
25
|
+
# test cases which use the @david style and don't mind the speed hit (each
|
|
26
|
+
# instantiated fixtures translates to a database query per test method),
|
|
27
|
+
# then set this back to true.
|
|
28
|
+
self.use_instantiated_fixtures = false
|
|
29
|
+
|
|
30
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
31
|
+
#
|
|
32
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
33
|
+
# -- they do not yet inherit this setting
|
|
34
|
+
fixtures :all
|
|
35
|
+
|
|
36
|
+
# Add more helper methods to be used by all tests here...
|
|
37
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.expand_path("../../../../test_helper.rb", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Actionpack
|
|
4
|
+
module ActionController
|
|
5
|
+
class RoutingTest < ::ActionController::TestCase
|
|
6
|
+
|
|
7
|
+
test "root_path" do
|
|
8
|
+
assert_routing "/", :controller => "application", :action => "index"
|
|
9
|
+
assert_named_route "/", :root
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require File.expand_path("../../../../test_helper.rb", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Actionpack
|
|
4
|
+
module ActionController
|
|
5
|
+
class TestCaseTest < ActiveSupport::TestCase
|
|
6
|
+
|
|
7
|
+
context "An ActionController::TestCase instance" do
|
|
8
|
+
should "be provided with named route assertion methods" do
|
|
9
|
+
methods = ::ActionController::TestCase.instance_methods
|
|
10
|
+
assert methods.include?("assert_named_route")
|
|
11
|
+
assert methods.include?("named_routes")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require File.expand_path("../../../../test_helper.rb", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Activesupport
|
|
4
|
+
module ActiveSupport
|
|
5
|
+
class DependenciesTest < ::ActiveSupport::TestCase
|
|
6
|
+
|
|
7
|
+
context "ActiveSupport::Dependencies" do
|
|
8
|
+
should "respond to :autoload_paths" do
|
|
9
|
+
assert ::ActiveSupport::Dependencies.respond_to? :autoload_paths
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.expand_path("../../../../test_helper.rb", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Core
|
|
4
|
+
module String
|
|
5
|
+
class ColorizeTest < ActiveSupport::TestCase
|
|
6
|
+
|
|
7
|
+
context "A String" do
|
|
8
|
+
should "respond to colorize methods" do
|
|
9
|
+
assert "".respond_to?(:red)
|
|
10
|
+
assert "".respond_to?(:green)
|
|
11
|
+
assert "".respond_to?(:yellow)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
should "return the expected when calling a colorize method" do
|
|
15
|
+
assert_equal "\e[1m\e[31mtesting\e[0m", "testing".red
|
|
16
|
+
assert_equal "\e[1m\e[32mtesting\e[0m", "testing".green
|
|
17
|
+
assert_equal "\e[1m\e[33mtesting\e[0m", "testing".yellow
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "with a lot of colorization" do
|
|
21
|
+
should "be able to be colorized" do
|
|
22
|
+
string = <<-STRING
|
|
23
|
+
{{green:Create your Firefox 'capybara' profile if you haven't done it yet}}
|
|
24
|
+
Run the following in your console to start the profile manager and create a profile called 'capybara':
|
|
25
|
+
{{yellow:[Mac] $ /Applications/Firefox.app/Contents/MacOS/firefox-bin -profilemanager}}
|
|
26
|
+
{{yellow:[Linux] $ cd <appdir> && ./firefox -profilemanager}}
|
|
27
|
+
{{green:Done establishing current GemSuit in your environment! ^^}}
|
|
28
|
+
STRING
|
|
29
|
+
result = <<-RESULT
|
|
30
|
+
\e[1m\e[32mCreate your Firefox 'capybara' profile if you haven't done it yet\e[0m
|
|
31
|
+
Run the following in your console to start the profile manager and create a profile called 'capybara':
|
|
32
|
+
\e[1m\e[33m[Mac] $ /Applications/Firefox.app/Contents/MacOS/firefox-bin -profilemanager\e[0m
|
|
33
|
+
\e[1m\e[33m[Linux] $ cd <appdir> && ./firefox -profilemanager\e[0m
|
|
34
|
+
\e[1m\e[32mDone establishing current GemSuit in your environment! ^^\e[0m
|
|
35
|
+
RESULT
|
|
36
|
+
assert_equal result, string.colorize
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require File.expand_path("../../../../test_helper.rb", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Core
|
|
4
|
+
module String
|
|
5
|
+
class HtmlSafeTest < ActiveSupport::TestCase
|
|
6
|
+
|
|
7
|
+
context "A String" do
|
|
8
|
+
should "respond to :html_safe" do
|
|
9
|
+
assert "".respond_to?(:html_safe)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.expand_path("../../../../test_helper.rb", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Core
|
|
4
|
+
module String
|
|
5
|
+
class InflectionsTest < ActiveSupport::TestCase
|
|
6
|
+
|
|
7
|
+
test "upcase_first" do
|
|
8
|
+
assert_equal "", "".upcase_first
|
|
9
|
+
assert_equal "Value", "value".upcase_first
|
|
10
|
+
assert_equal "VALUE", "vALUE".upcase_first
|
|
11
|
+
assert_equal "Value", "Value".upcase_first
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
test "cp_case" do
|
|
15
|
+
assert_equal "VALUE", "value".cp_case("KEY")
|
|
16
|
+
assert_equal "value", "VALUE".cp_case("key")
|
|
17
|
+
assert_equal "VAlUe", "vAlUe".cp_case("Key")
|
|
18
|
+
assert_equal "Welkom bij CodeHero.es", "welkom bij CodeHero.es".cp_case("Welcome at CodeHero.es")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test "upcase_first!" do
|
|
22
|
+
assert_equal nil, "".upcase_first!
|
|
23
|
+
assert_equal nil, "Paul".upcase_first!
|
|
24
|
+
assert_equal "Paul", "paul".upcase_first!
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test "cp_case!" do
|
|
28
|
+
assert_equal nil, "".cp_case!("")
|
|
29
|
+
assert_equal nil, "Paul".cp_case!("Engel")
|
|
30
|
+
assert_equal nil, "PAUL".cp_case!("ENGEL")
|
|
31
|
+
assert_equal "Paul", "paul".cp_case!("Engel")
|
|
32
|
+
assert_equal "PAUL", "paul".cp_case!("ENGEL")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
test "singularize!" do
|
|
36
|
+
assert_equal nil, "test" .singularize!
|
|
37
|
+
assert_equal nil, "TeSt" .singularize!
|
|
38
|
+
assert_equal "test", "tests".singularize!
|
|
39
|
+
assert_equal "TeSt", "TeSts".singularize!
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
test "pluralize!" do
|
|
43
|
+
assert_equal nil, "tests".pluralize!
|
|
44
|
+
assert_equal nil, "TeSts".pluralize!
|
|
45
|
+
assert_equal "tests", "test" .pluralize!
|
|
46
|
+
assert_equal "TeSts", "TeSt" .pluralize!
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require File.expand_path("../../../../test_helper.rb", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Test
|
|
4
|
+
module Unit
|
|
5
|
+
class TestCaseTest < ActiveSupport::TestCase
|
|
6
|
+
|
|
7
|
+
context "An Test::Unit::TestCase instance" do
|
|
8
|
+
should "be provided with pending methods" do
|
|
9
|
+
if defined? Test
|
|
10
|
+
klass = ::Test::Unit::TestCase
|
|
11
|
+
# assert klass .methods.include?("pending")
|
|
12
|
+
# assert klass.instance_methods.include?("pending")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gem "rails", "<%= rails_gem_version %>"
|
|
4
|
+
gem "sqlite3-ruby", :require => "sqlite3"
|
|
5
|
+
|
|
6
|
+
gem "rich_support", :path => File.expand_path("../../../..", __FILE__)
|
|
7
|
+
|
|
8
|
+
group :test do
|
|
9
|
+
gem "mysql"
|
|
10
|
+
gem "shoulda"
|
|
11
|
+
gem "mocha"
|
|
12
|
+
gem "capybara"
|
|
13
|
+
gem "launchy"
|
|
14
|
+
end
|
|
File without changes
|