fixture_background 0.9.1 → 0.9.2

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.
Files changed (64) hide show
  1. data/.gitignore +1 -0
  2. data/README.rdoc +4 -2
  3. data/lib/fixture_background/background.rb +14 -10
  4. data/lib/fixture_background/generator.rb +4 -2
  5. data/lib/fixture_background/version.rb +1 -1
  6. data/test/rails3/.gitignore +4 -0
  7. data/test/rails3/Gemfile +6 -0
  8. data/test/rails3/Gemfile.lock +83 -0
  9. data/test/rails3/README +256 -0
  10. data/test/rails3/Rakefile +7 -0
  11. data/test/rails3/app/controllers/application_controller.rb +3 -0
  12. data/test/rails3/app/controllers/people_controller.rb +83 -0
  13. data/test/rails3/app/helpers/application_helper.rb +2 -0
  14. data/test/rails3/app/helpers/people_helper.rb +5 -0
  15. data/test/rails3/app/models/person.rb +2 -0
  16. data/test/rails3/app/views/layouts/application.html.erb +14 -0
  17. data/test/rails3/app/views/people/_form.html.erb +21 -0
  18. data/test/rails3/app/views/people/edit.html.erb +6 -0
  19. data/test/rails3/app/views/people/index.html.erb +23 -0
  20. data/test/rails3/app/views/people/new.html.erb +5 -0
  21. data/test/rails3/app/views/people/show.html.erb +10 -0
  22. data/test/rails3/config.ru +4 -0
  23. data/test/rails3/config/application.rb +42 -0
  24. data/test/rails3/config/boot.rb +13 -0
  25. data/test/rails3/config/database.yml +22 -0
  26. data/test/rails3/config/environment.rb +5 -0
  27. data/test/rails3/config/environments/development.rb +26 -0
  28. data/test/rails3/config/environments/production.rb +49 -0
  29. data/test/rails3/config/environments/test.rb +35 -0
  30. data/test/rails3/config/initializers/backtrace_silencers.rb +7 -0
  31. data/test/rails3/config/initializers/inflections.rb +10 -0
  32. data/test/rails3/config/initializers/mime_types.rb +5 -0
  33. data/test/rails3/config/initializers/secret_token.rb +7 -0
  34. data/test/rails3/config/initializers/session_store.rb +8 -0
  35. data/test/rails3/config/locales/en.yml +5 -0
  36. data/test/rails3/config/routes.rb +60 -0
  37. data/test/rails3/db/migrate/20110127093735_create_people.rb +13 -0
  38. data/test/rails3/db/schema.rb +21 -0
  39. data/test/rails3/db/seeds.rb +7 -0
  40. data/test/rails3/doc/README_FOR_APP +2 -0
  41. data/test/rails3/lib/tasks/.gitkeep +0 -0
  42. data/test/rails3/public/404.html +26 -0
  43. data/test/rails3/public/422.html +26 -0
  44. data/test/rails3/public/500.html +26 -0
  45. data/test/rails3/public/favicon.ico +0 -0
  46. data/test/rails3/public/images/rails.png +0 -0
  47. data/test/rails3/public/index.html +239 -0
  48. data/test/rails3/public/javascripts/application.js +2 -0
  49. data/test/rails3/public/javascripts/controls.js +965 -0
  50. data/test/rails3/public/javascripts/dragdrop.js +974 -0
  51. data/test/rails3/public/javascripts/effects.js +1123 -0
  52. data/test/rails3/public/javascripts/prototype.js +6001 -0
  53. data/test/rails3/public/javascripts/rails.js +175 -0
  54. data/test/rails3/public/robots.txt +5 -0
  55. data/test/rails3/public/stylesheets/.gitkeep +0 -0
  56. data/test/rails3/public/stylesheets/scaffold.css +56 -0
  57. data/test/rails3/script/rails +6 -0
  58. data/test/rails3/test/functional/people_controller_test.rb +50 -0
  59. data/test/rails3/test/performance/browsing_test.rb +9 -0
  60. data/test/rails3/test/test_helper.rb +14 -0
  61. data/test/rails3/test/unit/helpers/people_helper_test.rb +12 -0
  62. data/test/rails3/test/unit/person_test.rb +59 -0
  63. data/test/rails3/vendor/plugins/.gitkeep +0 -0
  64. metadata +120 -5
@@ -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
+ })();
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
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,50 @@
1
+ require 'test_helper'
2
+
3
+ class PeopleControllerTest < ActionController::TestCase
4
+ background do
5
+ some_test_helper_returning_one
6
+ @person = Person.create(:name => "one")
7
+ end
8
+
9
+ should "get index" do
10
+ get :index
11
+ assert_response :success
12
+ assert_not_nil assigns(:people)
13
+ end
14
+
15
+ should "get new" do
16
+ get :new
17
+ assert_response :success
18
+ end
19
+
20
+ should "create person" do
21
+ assert_difference('Person.count') do
22
+ post :create, :person => @person.attributes
23
+ end
24
+
25
+ assert_redirected_to person_path(assigns(:person))
26
+ end
27
+
28
+ should "show person" do
29
+ get :show, :id => @person.to_param
30
+ assert_response :success
31
+ end
32
+
33
+ should "get edit" do
34
+ get :edit, :id => @person.to_param
35
+ assert_response :success
36
+ end
37
+
38
+ should "update person" do
39
+ put :update, :id => @person.to_param, :person => @person.attributes
40
+ assert_redirected_to person_path(assigns(:person))
41
+ end
42
+
43
+ should "destroy person" do
44
+ assert_difference('Person.count', -1) do
45
+ delete :destroy, :id => @person.to_param
46
+ end
47
+
48
+ assert_redirected_to people_path
49
+ end
50
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'rails/performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionDispatch::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'fixture_background'
4
+ require 'rails/test_help'
5
+
6
+ class ActiveSupport::TestCase
7
+ include ::FixtureBackground::ActiveSupport::TestCase
8
+
9
+ fixtures :all
10
+
11
+ def some_test_helper_returning_one
12
+ 1
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ class PeopleHelperTest < ActionView::TestCase
4
+ background do
5
+ some_test_helper_returning_one
6
+ @person = Person.create(:name => "one")
7
+ end
8
+
9
+ should "return reversed name" do
10
+ assert_equal "eno", reverse_name(@person)
11
+ end
12
+ end
@@ -0,0 +1,59 @@
1
+ require 'test_helper'
2
+
3
+ class PersonTest < ActiveSupport::TestCase
4
+ background do
5
+ some_test_helper_returning_one
6
+ @hase = Person.create(:name => "bunny")
7
+ end
8
+
9
+ context "with thies" do
10
+ background do
11
+ some_test_helper_returning_one
12
+ @thies = Person.create(:name => "thies")
13
+ end
14
+
15
+ should "be cool" do
16
+ assert @hase
17
+ assert @thies
18
+ assert_nil @manuel
19
+ assert_nil @norman
20
+ assert_equal 2, Person.count
21
+ end
22
+
23
+ context "with manuel" do
24
+ background do
25
+ @manuel = Person.create(:name => "manuel")
26
+ end
27
+
28
+ should "be cool" do
29
+ assert @hase
30
+ assert @thies
31
+ assert @manuel
32
+ assert_nil @norman
33
+ assert_equal 3, Person.count
34
+ end
35
+
36
+ context "with norman" do
37
+ background do
38
+ @norman = Person.create(:name => "norman")
39
+ end
40
+
41
+ should "be cool" do
42
+ assert @hase
43
+ assert @thies
44
+ assert @manuel
45
+ assert @norman
46
+ assert_equal 4, Person.count
47
+ end
48
+ end
49
+ end
50
+
51
+ should "nother truth" do
52
+ assert @hase
53
+ assert @thies
54
+ assert_nil @manuel
55
+ assert_nil @norman
56
+ assert_equal 2, Person.count
57
+ end
58
+ end
59
+ end
File without changes
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 1
9
- version: 0.9.1
8
+ - 2
9
+ version: 0.9.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Thies C. Arntzen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-12 00:00:00 +01:00
18
+ date: 2011-01-27 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -43,6 +43,64 @@ files:
43
43
  - lib/fixture_background/ivars.rb
44
44
  - lib/fixture_background/shoulda.rb
45
45
  - lib/fixture_background/version.rb
46
+ - test/rails3/.gitignore
47
+ - test/rails3/Gemfile
48
+ - test/rails3/Gemfile.lock
49
+ - test/rails3/README
50
+ - test/rails3/Rakefile
51
+ - test/rails3/app/controllers/application_controller.rb
52
+ - test/rails3/app/controllers/people_controller.rb
53
+ - test/rails3/app/helpers/application_helper.rb
54
+ - test/rails3/app/helpers/people_helper.rb
55
+ - test/rails3/app/models/person.rb
56
+ - test/rails3/app/views/layouts/application.html.erb
57
+ - test/rails3/app/views/people/_form.html.erb
58
+ - test/rails3/app/views/people/edit.html.erb
59
+ - test/rails3/app/views/people/index.html.erb
60
+ - test/rails3/app/views/people/new.html.erb
61
+ - test/rails3/app/views/people/show.html.erb
62
+ - test/rails3/config.ru
63
+ - test/rails3/config/application.rb
64
+ - test/rails3/config/boot.rb
65
+ - test/rails3/config/database.yml
66
+ - test/rails3/config/environment.rb
67
+ - test/rails3/config/environments/development.rb
68
+ - test/rails3/config/environments/production.rb
69
+ - test/rails3/config/environments/test.rb
70
+ - test/rails3/config/initializers/backtrace_silencers.rb
71
+ - test/rails3/config/initializers/inflections.rb
72
+ - test/rails3/config/initializers/mime_types.rb
73
+ - test/rails3/config/initializers/secret_token.rb
74
+ - test/rails3/config/initializers/session_store.rb
75
+ - test/rails3/config/locales/en.yml
76
+ - test/rails3/config/routes.rb
77
+ - test/rails3/db/migrate/20110127093735_create_people.rb
78
+ - test/rails3/db/schema.rb
79
+ - test/rails3/db/seeds.rb
80
+ - test/rails3/doc/README_FOR_APP
81
+ - test/rails3/lib/tasks/.gitkeep
82
+ - test/rails3/public/404.html
83
+ - test/rails3/public/422.html
84
+ - test/rails3/public/500.html
85
+ - test/rails3/public/favicon.ico
86
+ - test/rails3/public/images/rails.png
87
+ - test/rails3/public/index.html
88
+ - test/rails3/public/javascripts/application.js
89
+ - test/rails3/public/javascripts/controls.js
90
+ - test/rails3/public/javascripts/dragdrop.js
91
+ - test/rails3/public/javascripts/effects.js
92
+ - test/rails3/public/javascripts/prototype.js
93
+ - test/rails3/public/javascripts/rails.js
94
+ - test/rails3/public/robots.txt
95
+ - test/rails3/public/stylesheets/.gitkeep
96
+ - test/rails3/public/stylesheets/scaffold.css
97
+ - test/rails3/script/rails
98
+ - test/rails3/test/functional/people_controller_test.rb
99
+ - test/rails3/test/performance/browsing_test.rb
100
+ - test/rails3/test/test_helper.rb
101
+ - test/rails3/test/unit/helpers/people_helper_test.rb
102
+ - test/rails3/test/unit/person_test.rb
103
+ - test/rails3/vendor/plugins/.gitkeep
46
104
  has_rdoc: true
47
105
  homepage: https://github.com/tmp8/fixture_background
48
106
  licenses: []
@@ -75,5 +133,62 @@ rubygems_version: 1.3.7
75
133
  signing_key:
76
134
  specification_version: 3
77
135
  summary: Generate fixtures from factories _in_ you testcode to speedup test-runs
78
- test_files: []
79
-
136
+ test_files:
137
+ - test/rails3/.gitignore
138
+ - test/rails3/Gemfile
139
+ - test/rails3/Gemfile.lock
140
+ - test/rails3/README
141
+ - test/rails3/Rakefile
142
+ - test/rails3/app/controllers/application_controller.rb
143
+ - test/rails3/app/controllers/people_controller.rb
144
+ - test/rails3/app/helpers/application_helper.rb
145
+ - test/rails3/app/helpers/people_helper.rb
146
+ - test/rails3/app/models/person.rb
147
+ - test/rails3/app/views/layouts/application.html.erb
148
+ - test/rails3/app/views/people/_form.html.erb
149
+ - test/rails3/app/views/people/edit.html.erb
150
+ - test/rails3/app/views/people/index.html.erb
151
+ - test/rails3/app/views/people/new.html.erb
152
+ - test/rails3/app/views/people/show.html.erb
153
+ - test/rails3/config.ru
154
+ - test/rails3/config/application.rb
155
+ - test/rails3/config/boot.rb
156
+ - test/rails3/config/database.yml
157
+ - test/rails3/config/environment.rb
158
+ - test/rails3/config/environments/development.rb
159
+ - test/rails3/config/environments/production.rb
160
+ - test/rails3/config/environments/test.rb
161
+ - test/rails3/config/initializers/backtrace_silencers.rb
162
+ - test/rails3/config/initializers/inflections.rb
163
+ - test/rails3/config/initializers/mime_types.rb
164
+ - test/rails3/config/initializers/secret_token.rb
165
+ - test/rails3/config/initializers/session_store.rb
166
+ - test/rails3/config/locales/en.yml
167
+ - test/rails3/config/routes.rb
168
+ - test/rails3/db/migrate/20110127093735_create_people.rb
169
+ - test/rails3/db/schema.rb
170
+ - test/rails3/db/seeds.rb
171
+ - test/rails3/doc/README_FOR_APP
172
+ - test/rails3/lib/tasks/.gitkeep
173
+ - test/rails3/public/404.html
174
+ - test/rails3/public/422.html
175
+ - test/rails3/public/500.html
176
+ - test/rails3/public/favicon.ico
177
+ - test/rails3/public/images/rails.png
178
+ - test/rails3/public/index.html
179
+ - test/rails3/public/javascripts/application.js
180
+ - test/rails3/public/javascripts/controls.js
181
+ - test/rails3/public/javascripts/dragdrop.js
182
+ - test/rails3/public/javascripts/effects.js
183
+ - test/rails3/public/javascripts/prototype.js
184
+ - test/rails3/public/javascripts/rails.js
185
+ - test/rails3/public/robots.txt
186
+ - test/rails3/public/stylesheets/.gitkeep
187
+ - test/rails3/public/stylesheets/scaffold.css
188
+ - test/rails3/script/rails
189
+ - test/rails3/test/functional/people_controller_test.rb
190
+ - test/rails3/test/performance/browsing_test.rb
191
+ - test/rails3/test/test_helper.rb
192
+ - test/rails3/test/unit/helpers/people_helper_test.rb
193
+ - test/rails3/test/unit/person_test.rb
194
+ - test/rails3/vendor/plugins/.gitkeep