simple_update_field 0.2.3 → 1.0.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.
Files changed (55) hide show
  1. data/.rvmrc +1 -0
  2. data/Gemfile +19 -5
  3. data/Gemfile.lock +150 -0
  4. data/Rakefile +6 -0
  5. data/VERSION +1 -1
  6. data/app/assets/images/rails.png +0 -0
  7. data/app/assets/javascripts/application.js +14 -0
  8. data/app/assets/stylesheets/application.css +7 -0
  9. data/app/controllers/application_controller.rb +3 -0
  10. data/app/controllers/phrases_controller.rb +12 -0
  11. data/app/helpers/application_helper.rb +2 -0
  12. data/app/mailers/.gitkeep +0 -0
  13. data/app/models/.gitkeep +0 -0
  14. data/app/models/phrase.rb +4 -0
  15. data/app/views/layouts/application.html.erb +14 -0
  16. data/app/views/phrases/_phrase.html.erb +8 -0
  17. data/app/views/phrases/index.html.erb +1 -0
  18. data/config/application.rb +54 -0
  19. data/config/boot.rb +6 -0
  20. data/config/database.yml +25 -0
  21. data/config/environment.rb +5 -0
  22. data/config/environments/development.rb +30 -0
  23. data/config/environments/production.rb +60 -0
  24. data/config/environments/test.rb +42 -0
  25. data/config/initializers/backtrace_silencers.rb +7 -0
  26. data/config/initializers/inflections.rb +10 -0
  27. data/config/initializers/mime_types.rb +5 -0
  28. data/config/initializers/secret_token.rb +7 -0
  29. data/config/initializers/session_store.rb +8 -0
  30. data/config/initializers/wrap_parameters.rb +14 -0
  31. data/config/locales/en.yml +5 -0
  32. data/config/routes.rb +4 -0
  33. data/config.ru +4 -0
  34. data/db/migrate/20120213182817_create_phrases.rb +9 -0
  35. data/db/schema.rb +22 -0
  36. data/db/seeds.rb +7 -0
  37. data/lib/assets/.gitkeep +0 -0
  38. data/lib/tasks/.gitkeep +0 -0
  39. data/lib/tasks/admin.rake +9 -0
  40. data/lib/tasks/jasmine.rake +8 -0
  41. data/script/rails +6 -0
  42. data/simple_update_field.gemspec +76 -2
  43. data/spec/controllers/phrases_controller_spec.rb +22 -0
  44. data/spec/javascripts/editable_list_spec.js +411 -0
  45. data/spec/javascripts/helpers/mock-ajax.js +207 -0
  46. data/spec/javascripts/spec.css +3 -0
  47. data/spec/javascripts/spec.js +2 -0
  48. data/spec/{simple_update_field_spec.rb → lib/simple_update_field_spec.rb} +1 -2
  49. data/spec/models/phrase_spec.rb +11 -0
  50. data/spec/routing/phrase_spec.rb +12 -0
  51. data/spec/routing/root_spec.rb +7 -0
  52. data/spec/spec_helper.rb +28 -8
  53. data/spec/views/_phrase.html.erb_spec.rb +9 -0
  54. data/spec/views/index.html.erb_spec.rb +10 -0
  55. metadata +157 -11
@@ -0,0 +1,207 @@
1
+ /*
2
+ Jasmine-Ajax : a set of helpers for testing AJAX requests under the Jasmine
3
+ BDD framework for JavaScript.
4
+
5
+ Supports both Prototype.js and jQuery.
6
+
7
+ http://github.com/pivotal/jasmine-ajax
8
+
9
+ Jasmine Home page: http://pivotal.github.com/jasmine
10
+
11
+ Copyright (c) 2008-2010 Pivotal Labs
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining
14
+ a copy of this software and associated documentation files (the
15
+ "Software"), to deal in the Software without restriction, including
16
+ without limitation the rights to use, copy, modify, merge, publish,
17
+ distribute, sublicense, and/or sell copies of the Software, and to
18
+ permit persons to whom the Software is furnished to do so, subject to
19
+ the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be
22
+ included in all copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
+
32
+ */
33
+
34
+ // Jasmine-Ajax interface
35
+ var ajaxRequests = [];
36
+
37
+ function mostRecentAjaxRequest() {
38
+ if (ajaxRequests.length > 0) {
39
+ return ajaxRequests[ajaxRequests.length - 1];
40
+ } else {
41
+ return null;
42
+ }
43
+ }
44
+
45
+ function clearAjaxRequests() {
46
+ ajaxRequests = [];
47
+ }
48
+
49
+ // Fake XHR for mocking Ajax Requests & Responses
50
+ function FakeXMLHttpRequest() {
51
+ var extend = Object.extend || $.extend;
52
+ extend(this, {
53
+ requestHeaders: {},
54
+
55
+ open: function() {
56
+ this.method = arguments[0];
57
+ this.url = arguments[1];
58
+ this.readyState = 1;
59
+ },
60
+
61
+ setRequestHeader: function(header, value) {
62
+ this.requestHeaders[header] = value;
63
+ },
64
+
65
+ abort: function() {
66
+ this.readyState = 0;
67
+ },
68
+
69
+ readyState: 0,
70
+
71
+ onreadystatechange: function(isTimeout) {
72
+ },
73
+
74
+ status: null,
75
+
76
+ send: function(data) {
77
+ this.params = data;
78
+ this.readyState = 2;
79
+ },
80
+
81
+ getResponseHeader: function(name) {
82
+ return this.responseHeaders[name];
83
+ },
84
+
85
+ getAllResponseHeaders: function() {
86
+ var responseHeaders = [];
87
+ for (var i in this.responseHeaders) {
88
+ if (this.responseHeaders.hasOwnProperty(i)) {
89
+ responseHeaders.push(i + ': ' + this.responseHeaders[i]);
90
+ }
91
+ }
92
+ return responseHeaders.join('\r\n');
93
+ },
94
+
95
+ responseText: null,
96
+
97
+ response: function(response) {
98
+ this.status = response.status;
99
+ this.responseText = response.responseText || "";
100
+ this.readyState = 4;
101
+ this.responseHeaders = response.responseHeaders ||
102
+ {"Content-type": response.contentType || "application/json" };
103
+ // uncomment for jquery 1.3.x support
104
+ // jasmine.Clock.tick(20);
105
+
106
+ this.onreadystatechange();
107
+ },
108
+ responseTimeout: function() {
109
+ this.readyState = 4;
110
+ jasmine.Clock.tick(jQuery.ajaxSettings.timeout || 30000);
111
+ this.onreadystatechange('timeout');
112
+ }
113
+ });
114
+
115
+ return this;
116
+ }
117
+
118
+
119
+ jasmine.Ajax = {
120
+
121
+ isInstalled: function() {
122
+ return jasmine.Ajax.installed == true;
123
+ },
124
+
125
+ assertInstalled: function() {
126
+ if (!jasmine.Ajax.isInstalled()) {
127
+ throw new Error("Mock ajax is not installed, use jasmine.Ajax.useMock()")
128
+ }
129
+ },
130
+
131
+ useMock: function() {
132
+ if (!jasmine.Ajax.isInstalled()) {
133
+ var spec = jasmine.getEnv().currentSpec;
134
+ spec.after(jasmine.Ajax.uninstallMock);
135
+
136
+ jasmine.Ajax.installMock();
137
+ }
138
+ },
139
+
140
+ installMock: function() {
141
+ if (typeof jQuery != 'undefined') {
142
+ jasmine.Ajax.installJquery();
143
+ } else if (typeof Prototype != 'undefined') {
144
+ jasmine.Ajax.installPrototype();
145
+ } else {
146
+ throw new Error("jasmine.Ajax currently only supports jQuery and Prototype");
147
+ }
148
+ jasmine.Ajax.installed = true;
149
+ },
150
+
151
+ installJquery: function() {
152
+ jasmine.Ajax.mode = 'jQuery';
153
+ jasmine.Ajax.real = jQuery.ajaxSettings.xhr;
154
+ jQuery.ajaxSettings.xhr = jasmine.Ajax.jQueryMock;
155
+
156
+ },
157
+
158
+ installPrototype: function() {
159
+ jasmine.Ajax.mode = 'Prototype';
160
+ jasmine.Ajax.real = Ajax.getTransport;
161
+
162
+ Ajax.getTransport = jasmine.Ajax.prototypeMock;
163
+ },
164
+
165
+ uninstallMock: function() {
166
+ jasmine.Ajax.assertInstalled();
167
+ if (jasmine.Ajax.mode == 'jQuery') {
168
+ jQuery.ajaxSettings.xhr = jasmine.Ajax.real;
169
+ } else if (jasmine.Ajax.mode == 'Prototype') {
170
+ Ajax.getTransport = jasmine.Ajax.real;
171
+ }
172
+ jasmine.Ajax.reset();
173
+ },
174
+
175
+ reset: function() {
176
+ jasmine.Ajax.installed = false;
177
+ jasmine.Ajax.mode = null;
178
+ jasmine.Ajax.real = null;
179
+ },
180
+
181
+ jQueryMock: function() {
182
+ var newXhr = new FakeXMLHttpRequest();
183
+ ajaxRequests.push(newXhr);
184
+ return newXhr;
185
+ },
186
+
187
+ prototypeMock: function() {
188
+ return new FakeXMLHttpRequest();
189
+ },
190
+
191
+ installed: false,
192
+ mode: null
193
+ }
194
+
195
+
196
+ // Jasmine-Ajax Glue code for Prototype.js
197
+ if (typeof Prototype != 'undefined' && Ajax && Ajax.Request) {
198
+ Ajax.Request.prototype.originalRequest = Ajax.Request.prototype.request;
199
+ Ajax.Request.prototype.request = function(url) {
200
+ this.originalRequest(url);
201
+ ajaxRequests.push(this);
202
+ };
203
+
204
+ Ajax.Request.prototype.response = function(responseOptions) {
205
+ return this.transport.response(responseOptions);
206
+ };
207
+ }
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require application
3
+ * /
@@ -0,0 +1,2 @@
1
+ //=require application
2
+ //=require_tree ./
@@ -1,5 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
1
+ require 'spec_helper'
3
2
  describe "SimpleUpdateField" do
4
3
  it "should define an engine" do
5
4
  lambda do
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Phrase do
4
+ it "can be created with text" do
5
+ p = Phrase.create!(:text => "hello there")
6
+ end
7
+ it "text must not be blank" do
8
+ p = Phrase.new
9
+ p.should_not be_valid
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+ describe "/phrases" do
3
+ it "routes to index" do
4
+ { :get => '/phrases'}.should(
5
+ route_to(
6
+ :controller => "phrases",
7
+ :action => "index"
8
+ ))
9
+
10
+
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+ describe '/' do
3
+ it "routes to phrases index" do
4
+ {:get => "/"}.should(route_to(:controller => 'phrases',
5
+ :action => 'index'))
6
+ end
7
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,32 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'simple_update_field'
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../../config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
5
6
 
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
7
+ # Requires supporting ruby files with custom matchers and macros, etc,
8
+ # in spec/support/ and its subdirectories.
9
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
9
10
 
10
11
  RSpec.configure do |config|
11
-
12
+ # ## Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+
20
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
21
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
+
23
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
+ # examples within a transaction, remove the following line or assign false
25
+ # instead of true.
26
+ config.use_transactional_fixtures = true
27
+
28
+ # If true, the base class of anonymous controllers will be inferred
29
+ # automatically. This will be the default behavior in future versions of
30
+ # rspec-rails.
31
+ config.infer_base_class_for_anonymous_controllers = false
12
32
  end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+ describe "phrases/_phrase.html.erb" do
3
+ it "displays" do
4
+ a_phrase =Phrase.create!(:text => 'snuggly')
5
+ render "phrases/phrase", :phrase => a_phrase
6
+ rendered.should have_css('.phrase .text', :text => 'snuggly')
7
+ end
8
+ end
9
+
@@ -0,0 +1,10 @@
1
+ require "spec_helper"
2
+ describe "phrases/index.html.erb" do
3
+ it "renders a phrase template for each phrase" do
4
+ my_phrases = [Phrase.create!(:text => 'snuggly'),
5
+ Phrase.create!(:text => 'bear')]
6
+ assign(:phrases, my_phrases) # @phrases = my_phrases in view
7
+ render
8
+ view.should render_template(:partial => "_phrase", :count => 2)
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_update_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70188579086400 !ruby/object:Gem::Requirement
16
+ requirement: &70105491568520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.8.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70188579086400
24
+ version_requirements: *70105491568520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &70188579085880 !ruby/object:Gem::Requirement
27
+ requirement: &70105491528520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.12'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70188579085880
35
+ version_requirements: *70105491528520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70188579085280 !ruby/object:Gem::Requirement
38
+ requirement: &70105491523260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.1.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70188579085280
46
+ version_requirements: *70105491523260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70188579084700 !ruby/object:Gem::Requirement
49
+ requirement: &70105491505920 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,106 @@ dependencies:
54
54
  version: 1.8.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70188579084700
57
+ version_requirements: *70105491505920
58
+ - !ruby/object:Gem::Dependency
59
+ name: rails
60
+ requirement: &70105491478960 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - =
64
+ - !ruby/object:Gem::Version
65
+ version: 3.1.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70105491478960
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: &70105491468780 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70105491468780
80
+ - !ruby/object:Gem::Dependency
81
+ name: jquery-rails
82
+ requirement: &70105491442300 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70105491442300
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec-rails
93
+ requirement: &70105491398040 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70105491398040
102
+ - !ruby/object:Gem::Dependency
103
+ name: autotest
104
+ requirement: &70105491327080 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70105491327080
113
+ - !ruby/object:Gem::Dependency
114
+ name: capybara
115
+ requirement: &70105491282080 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *70105491282080
124
+ - !ruby/object:Gem::Dependency
125
+ name: jasminerice
126
+ requirement: &70105491272440 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *70105491272440
135
+ - !ruby/object:Gem::Dependency
136
+ name: guard-jasmine
137
+ requirement: &70105491232080 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: *70105491232080
146
+ - !ruby/object:Gem::Dependency
147
+ name: faker
148
+ requirement: &70105491209800 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: *70105491209800
58
157
  description: Your resources text attributes will gain inplace update ability with
59
158
  keybindings for quick editing
60
159
  email: curtis@ram9.cc
@@ -66,16 +165,63 @@ extra_rdoc_files:
66
165
  files:
67
166
  - .document
68
167
  - .rspec
168
+ - .rvmrc
69
169
  - Gemfile
70
170
  - Gemfile.lock
71
171
  - LICENSE.txt
72
172
  - README.rdoc
73
173
  - Rakefile
74
174
  - VERSION
175
+ - app/assets/images/rails.png
176
+ - app/assets/javascripts/application.js
177
+ - app/assets/stylesheets/application.css
178
+ - app/controllers/application_controller.rb
179
+ - app/controllers/phrases_controller.rb
180
+ - app/helpers/application_helper.rb
181
+ - app/mailers/.gitkeep
182
+ - app/models/.gitkeep
183
+ - app/models/phrase.rb
184
+ - app/views/layouts/application.html.erb
185
+ - app/views/phrases/_phrase.html.erb
186
+ - app/views/phrases/index.html.erb
187
+ - config.ru
188
+ - config/application.rb
189
+ - config/boot.rb
190
+ - config/database.yml
191
+ - config/environment.rb
192
+ - config/environments/development.rb
193
+ - config/environments/production.rb
194
+ - config/environments/test.rb
195
+ - config/initializers/backtrace_silencers.rb
196
+ - config/initializers/inflections.rb
197
+ - config/initializers/mime_types.rb
198
+ - config/initializers/secret_token.rb
199
+ - config/initializers/session_store.rb
200
+ - config/initializers/wrap_parameters.rb
201
+ - config/locales/en.yml
202
+ - config/routes.rb
203
+ - db/migrate/20120213182817_create_phrases.rb
204
+ - db/schema.rb
205
+ - db/seeds.rb
206
+ - lib/assets/.gitkeep
75
207
  - lib/simple_update_field.rb
208
+ - lib/tasks/.gitkeep
209
+ - lib/tasks/admin.rake
210
+ - lib/tasks/jasmine.rake
211
+ - script/rails
76
212
  - simple_update_field.gemspec
77
- - spec/simple_update_field_spec.rb
213
+ - spec/controllers/phrases_controller_spec.rb
214
+ - spec/javascripts/editable_list_spec.js
215
+ - spec/javascripts/helpers/mock-ajax.js
216
+ - spec/javascripts/spec.css
217
+ - spec/javascripts/spec.js
218
+ - spec/lib/simple_update_field_spec.rb
219
+ - spec/models/phrase_spec.rb
220
+ - spec/routing/phrase_spec.rb
221
+ - spec/routing/root_spec.rb
78
222
  - spec/spec_helper.rb
223
+ - spec/views/_phrase.html.erb_spec.rb
224
+ - spec/views/index.html.erb_spec.rb
79
225
  - vendor/assets/javascripts/editable_list.js
80
226
  homepage: http://github.com/robotarmy/simple_update_field
81
227
  licenses:
@@ -92,7 +238,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
238
  version: '0'
93
239
  segments:
94
240
  - 0
95
- hash: -3195811587096967023
241
+ hash: -3437147205302710675
96
242
  required_rubygems_version: !ruby/object:Gem::Requirement
97
243
  none: false
98
244
  requirements: