openstax_api 2.5.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -6
  3. data/app/controllers/openstax/api/v1/api_controller.rb +1 -1
  4. data/app/representers/openstax/api/v1/abstract_search_representer.rb +40 -0
  5. data/lib/openstax/api/constraints.rb +3 -4
  6. data/lib/openstax/api/engine.rb +3 -8
  7. data/lib/openstax/api/representable_schema_printer.rb +58 -35
  8. data/lib/openstax/api/roar.rb +50 -93
  9. data/lib/openstax/api/version.rb +1 -1
  10. data/spec/controllers/openstax/api/v1/api_controller_spec.rb +88 -2
  11. data/spec/dummy/README.md +1 -1
  12. data/spec/dummy/Rakefile +1 -2
  13. data/spec/dummy/app/assets/javascripts/application.js +3 -5
  14. data/spec/dummy/app/assets/stylesheets/application.css +5 -3
  15. data/spec/dummy/app/models/user.rb +2 -0
  16. data/spec/dummy/app/representers/user_representer.rb +13 -0
  17. data/spec/dummy/app/representers/user_search_representer.rb +5 -0
  18. data/spec/dummy/app/routines/search_users.rb +22 -0
  19. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  20. data/spec/dummy/bin/bundle +3 -0
  21. data/spec/dummy/bin/rails +4 -0
  22. data/spec/dummy/bin/rake +4 -0
  23. data/spec/dummy/config/application.rb +0 -30
  24. data/spec/dummy/config/boot.rb +4 -9
  25. data/spec/dummy/config/database.yml +8 -8
  26. data/spec/dummy/config/environment.rb +3 -3
  27. data/spec/dummy/config/environments/development.rb +21 -13
  28. data/spec/dummy/config/environments/production.rb +41 -32
  29. data/spec/dummy/config/environments/test.rb +17 -13
  30. data/spec/dummy/config/initializers/assets.rb +8 -0
  31. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  32. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  33. data/spec/dummy/config/initializers/inflections.rb +6 -5
  34. data/spec/dummy/config/initializers/mime_types.rb +0 -1
  35. data/spec/dummy/config/initializers/openstax_api.rb +2 -2
  36. data/spec/dummy/config/initializers/session_store.rb +1 -6
  37. data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
  38. data/spec/dummy/config/locales/en.yml +20 -2
  39. data/spec/dummy/config/secrets.yml +22 -0
  40. data/spec/dummy/config.ru +1 -1
  41. data/spec/dummy/db/development.sqlite3 +0 -0
  42. data/spec/dummy/db/migrate/1_create_users.rb +16 -0
  43. data/spec/dummy/db/schema.rb +38 -32
  44. data/spec/dummy/db/test.sqlite3 +0 -0
  45. data/spec/dummy/lib/controller_includes.rb +2 -6
  46. data/spec/dummy/log/development.log +486 -1445
  47. data/spec/dummy/log/test.log +16720 -3757
  48. data/spec/dummy/public/404.html +54 -13
  49. data/spec/dummy/public/422.html +54 -13
  50. data/spec/dummy/public/500.html +53 -12
  51. data/spec/factories/user.rb +8 -0
  52. data/spec/lib/openstax/api/apipie_spec.rb +15 -0
  53. data/spec/lib/openstax/api/constraints_spec.rb +6 -6
  54. data/spec/lib/openstax/api/doorkeeper_application_includes_spec.rb +1 -1
  55. data/spec/lib/openstax/api/representable_schema_printer_spec.rb +5 -3
  56. data/spec/lib/openstax/api/roar_spec.rb +22 -0
  57. data/spec/lib/openstax/api/routing_mapper_includes_spec.rb +1 -1
  58. data/spec/lib/openstax_api_spec.rb +19 -0
  59. data/spec/models/openstax/api/api_user_spec.rb +2 -2
  60. data/spec/rails_helper.rb +54 -0
  61. data/spec/representers/openstax/api/v1/abstract_search_representer_spec.rb +127 -0
  62. data/spec/spec_helper.rb +80 -13
  63. metadata +85 -18
  64. data/spec/dummy/app/models/dummy_user.rb +0 -2
  65. data/spec/dummy/app/representers/dummy_user_representer.rb +0 -9
  66. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  67. data/spec/dummy/db/migrate/1_create_dummy_users.rb +0 -10
  68. data/spec/dummy/script/rails +0 -6
  69. data/spec/lib/openstax/api/apipie.rb +0 -11
  70. data/spec/lib/openstax/api/roar.rb +0 -11
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,85 @@
1
- # Configure Rails Environment
2
- ENV['RAILS_ENV'] ||= 'test'
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
+ end
3
31
 
4
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
- require 'rspec/rails'
6
- require 'rspec/autorun'
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
39
+ end
7
40
 
8
- Rails.backtrace_cleaner.remove_silencers!
41
+ # The settings below are suggested to provide a good initial experience
42
+ # with RSpec, but feel free to customize to your heart's content.
43
+ =begin
44
+ # These two settings work together to allow you to limit a spec run
45
+ # to individual examples or groups you care about by tagging them with
46
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
+ # get run.
48
+ config.filter_run :focus
49
+ config.run_all_when_everything_filtered = true
9
50
 
10
- # Load support files
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
51
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
+ # For more details, see:
53
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
+ config.disable_monkey_patching!
12
57
 
13
- RSpec.configure do |config|
14
- config.mock_with :rspec
15
- config.use_transactional_fixtures = true
16
- config.infer_base_class_for_anonymous_controllers = false
17
- config.order = "random"
58
+ # Many RSpec users commonly either run the entire suite or an individual
59
+ # file, and it's useful to allow more verbose output when running an
60
+ # individual spec file.
61
+ if config.files_to_run.one?
62
+ # Use the documentation formatter for detailed output,
63
+ # unless a formatter has already been configured
64
+ # (e.g. via a command-line flag).
65
+ config.default_formatter = 'doc'
66
+ end
67
+
68
+ # Print the 10 slowest examples and example groups at the
69
+ # end of the spec run, to help surface which specs are running
70
+ # particularly slow.
71
+ config.profile_examples = 10
72
+
73
+ # Run specs in random order to surface order dependencies. If you find an
74
+ # order dependency and want to debug it, you can fix the order by providing
75
+ # the seed, which is printed after each run.
76
+ # --seed 1234
77
+ config.order = :random
78
+
79
+ # Seed global randomization in this process using the `--seed` CLI option.
80
+ # Setting this allows you to use `--seed` to deterministically reproduce
81
+ # test failures related to randomization by passing the same `--seed` value
82
+ # as the one that triggered the failure.
83
+ Kernel.srand config.seed
84
+ =end
18
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dante Soares
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-29 00:00:00.000000000 Z
12
+ date: 2014-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: 1.0.1
104
+ version: 4.0.0
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: 1.0.1
111
+ version: 4.0.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: sqlite3
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +137,48 @@ dependencies:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: factory_girl_rails
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: faker
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: squeel
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
140
182
  description: Provides models, controllers and libraries that help OpenStax products
141
183
  define API's for user applications.
142
184
  email:
@@ -151,6 +193,7 @@ files:
151
193
  - Rakefile
152
194
  - app/controllers/openstax/api/v1/api_controller.rb
153
195
  - app/models/openstax/api/api_user.rb
196
+ - app/representers/openstax/api/v1/abstract_search_representer.rb
154
197
  - lib/openstax/api/apipie.rb
155
198
  - lib/openstax/api/constraints.rb
156
199
  - lib/openstax/api/doorkeeper_application_includes.rb
@@ -167,8 +210,14 @@ files:
167
210
  - spec/dummy/app/assets/javascripts/application.js
168
211
  - spec/dummy/app/assets/stylesheets/application.css
169
212
  - spec/dummy/app/helpers/application_helper.rb
170
- - spec/dummy/app/models/dummy_user.rb
171
- - spec/dummy/app/representers/dummy_user_representer.rb
213
+ - spec/dummy/app/models/user.rb
214
+ - spec/dummy/app/representers/user_representer.rb
215
+ - spec/dummy/app/representers/user_search_representer.rb
216
+ - spec/dummy/app/routines/search_users.rb
217
+ - spec/dummy/app/views/layouts/application.html.erb
218
+ - spec/dummy/bin/bundle
219
+ - spec/dummy/bin/rails
220
+ - spec/dummy/bin/rake
172
221
  - spec/dummy/config.ru
173
222
  - spec/dummy/config/application.rb
174
223
  - spec/dummy/config/boot.rb
@@ -177,19 +226,22 @@ files:
177
226
  - spec/dummy/config/environments/development.rb
178
227
  - spec/dummy/config/environments/production.rb
179
228
  - spec/dummy/config/environments/test.rb
229
+ - spec/dummy/config/initializers/assets.rb
180
230
  - spec/dummy/config/initializers/backtrace_silencers.rb
231
+ - spec/dummy/config/initializers/cookies_serializer.rb
181
232
  - spec/dummy/config/initializers/doorkeeper.rb
233
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
182
234
  - spec/dummy/config/initializers/inflections.rb
183
235
  - spec/dummy/config/initializers/mime_types.rb
184
236
  - spec/dummy/config/initializers/openstax_api.rb
185
- - spec/dummy/config/initializers/secret_token.rb
186
237
  - spec/dummy/config/initializers/session_store.rb
187
238
  - spec/dummy/config/initializers/wrap_parameters.rb
188
239
  - spec/dummy/config/locales/en.yml
189
240
  - spec/dummy/config/routes.rb
241
+ - spec/dummy/config/secrets.yml
190
242
  - spec/dummy/db/development.sqlite3
191
243
  - spec/dummy/db/migrate/0_create_doorkeeper_tables.rb
192
- - spec/dummy/db/migrate/1_create_dummy_users.rb
244
+ - spec/dummy/db/migrate/1_create_users.rb
193
245
  - spec/dummy/db/schema.rb
194
246
  - spec/dummy/db/test.sqlite3
195
247
  - spec/dummy/lib/controller_includes.rb
@@ -199,14 +251,17 @@ files:
199
251
  - spec/dummy/public/422.html
200
252
  - spec/dummy/public/500.html
201
253
  - spec/dummy/public/favicon.ico
202
- - spec/dummy/script/rails
203
- - spec/lib/openstax/api/apipie.rb
254
+ - spec/factories/user.rb
255
+ - spec/lib/openstax/api/apipie_spec.rb
204
256
  - spec/lib/openstax/api/constraints_spec.rb
205
257
  - spec/lib/openstax/api/doorkeeper_application_includes_spec.rb
206
258
  - spec/lib/openstax/api/representable_schema_printer_spec.rb
207
- - spec/lib/openstax/api/roar.rb
259
+ - spec/lib/openstax/api/roar_spec.rb
208
260
  - spec/lib/openstax/api/routing_mapper_includes_spec.rb
261
+ - spec/lib/openstax_api_spec.rb
209
262
  - spec/models/openstax/api/api_user_spec.rb
263
+ - spec/rails_helper.rb
264
+ - spec/representers/openstax/api/v1/abstract_search_representer_spec.rb
210
265
  - spec/spec_helper.rb
211
266
  homepage: https://github.com/openstax/openstax_api
212
267
  licenses:
@@ -237,8 +292,14 @@ test_files:
237
292
  - spec/dummy/app/assets/javascripts/application.js
238
293
  - spec/dummy/app/assets/stylesheets/application.css
239
294
  - spec/dummy/app/helpers/application_helper.rb
240
- - spec/dummy/app/models/dummy_user.rb
241
- - spec/dummy/app/representers/dummy_user_representer.rb
295
+ - spec/dummy/app/models/user.rb
296
+ - spec/dummy/app/representers/user_representer.rb
297
+ - spec/dummy/app/representers/user_search_representer.rb
298
+ - spec/dummy/app/routines/search_users.rb
299
+ - spec/dummy/app/views/layouts/application.html.erb
300
+ - spec/dummy/bin/bundle
301
+ - spec/dummy/bin/rails
302
+ - spec/dummy/bin/rake
242
303
  - spec/dummy/config/application.rb
243
304
  - spec/dummy/config/boot.rb
244
305
  - spec/dummy/config/database.yml
@@ -246,20 +307,23 @@ test_files:
246
307
  - spec/dummy/config/environments/development.rb
247
308
  - spec/dummy/config/environments/production.rb
248
309
  - spec/dummy/config/environments/test.rb
310
+ - spec/dummy/config/initializers/assets.rb
249
311
  - spec/dummy/config/initializers/backtrace_silencers.rb
312
+ - spec/dummy/config/initializers/cookies_serializer.rb
250
313
  - spec/dummy/config/initializers/doorkeeper.rb
314
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
251
315
  - spec/dummy/config/initializers/inflections.rb
252
316
  - spec/dummy/config/initializers/mime_types.rb
253
317
  - spec/dummy/config/initializers/openstax_api.rb
254
- - spec/dummy/config/initializers/secret_token.rb
255
318
  - spec/dummy/config/initializers/session_store.rb
256
319
  - spec/dummy/config/initializers/wrap_parameters.rb
257
320
  - spec/dummy/config/locales/en.yml
258
321
  - spec/dummy/config/routes.rb
322
+ - spec/dummy/config/secrets.yml
259
323
  - spec/dummy/config.ru
260
324
  - spec/dummy/db/development.sqlite3
261
325
  - spec/dummy/db/migrate/0_create_doorkeeper_tables.rb
262
- - spec/dummy/db/migrate/1_create_dummy_users.rb
326
+ - spec/dummy/db/migrate/1_create_users.rb
263
327
  - spec/dummy/db/schema.rb
264
328
  - spec/dummy/db/test.sqlite3
265
329
  - spec/dummy/lib/controller_includes.rb
@@ -271,12 +335,15 @@ test_files:
271
335
  - spec/dummy/public/favicon.ico
272
336
  - spec/dummy/Rakefile
273
337
  - spec/dummy/README.md
274
- - spec/dummy/script/rails
275
- - spec/lib/openstax/api/apipie.rb
338
+ - spec/factories/user.rb
339
+ - spec/lib/openstax/api/apipie_spec.rb
276
340
  - spec/lib/openstax/api/constraints_spec.rb
277
341
  - spec/lib/openstax/api/doorkeeper_application_includes_spec.rb
278
342
  - spec/lib/openstax/api/representable_schema_printer_spec.rb
279
- - spec/lib/openstax/api/roar.rb
343
+ - spec/lib/openstax/api/roar_spec.rb
280
344
  - spec/lib/openstax/api/routing_mapper_includes_spec.rb
345
+ - spec/lib/openstax_api_spec.rb
281
346
  - spec/models/openstax/api/api_user_spec.rb
347
+ - spec/rails_helper.rb
348
+ - spec/representers/openstax/api/v1/abstract_search_representer_spec.rb
282
349
  - spec/spec_helper.rb
@@ -1,2 +0,0 @@
1
- class DummyUser < ActiveRecord::Base
2
- end
@@ -1,9 +0,0 @@
1
- require 'representable/json'
2
-
3
- module DummyUserRepresenter
4
- include Roar::Representer::JSON
5
-
6
- property :username, :schema_info => { :required => true }
7
- property :name
8
- property :password_hash, readable: false, writeable: false
9
- end
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = 'b230f4e50b455110724fca292b4f33304d40c8d059118e382150a12ba7701f31ec1333b592b3c8e1447ca736dbdab99f8124ab26dae8a1eb416d9928a171e345'
@@ -1,10 +0,0 @@
1
- class CreateDummyUsers < ActiveRecord::Migration
2
- def change
3
- create_table :dummy_users do |t|
4
- t.string :username
5
- t.string :password_hash
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,6 +0,0 @@
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'
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module OpenStax
4
- module Api
5
- module V1
6
- describe Apipie do
7
- # TODO: Test apipie helpers using dummy app
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module OpenStax
4
- module Api
5
- module V1
6
- describe Roar do
7
- # TODO: Test generic REST api methods using dummy app
8
- end
9
- end
10
- end
11
- end