openstax_exchange 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.gitignore +15 -0
  2. data/.rspec +1 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +8 -0
  6. data/Gemfile +4 -0
  7. data/MIT-LICENSE +3 -1
  8. data/README.md +58 -20
  9. data/Rakefile +5 -13
  10. data/exchange-client.gemspec +30 -0
  11. data/lib/openstax/exchange/client_instance.rb +23 -0
  12. data/lib/openstax/exchange/configuration.rb +12 -0
  13. data/lib/openstax/exchange/exceptions.rb +21 -0
  14. data/lib/openstax/exchange/exchange.rb +65 -0
  15. data/lib/openstax/exchange/fake_client/configuration.rb +13 -0
  16. data/lib/openstax/exchange/fake_client/fake_client.rb +71 -0
  17. data/lib/openstax/exchange/real_client/real_client.rb +76 -0
  18. data/lib/openstax/exchange/version.rb +1 -1
  19. data/lib/openstax_exchange.rb +8 -112
  20. data/spec/cassettes/OpenStax_Exchange/client_instance_configuration/can_be_configured_to_use_a_real_exchange_client.yml +48 -0
  21. data/spec/cassettes/OpenStax_Exchange/internal_client_instance/_client_defaults_to_a_real_exchange_client.yml +48 -0
  22. data/spec/cassettes/OpenStax_Exchange/internal_client_instance/_reset_causes_a_new_client_object_to_be_returned_by_client.yml +48 -0
  23. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_create_identifier/success/creates_a_distinct_identifer_per_invokation.yml +146 -0
  24. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_create_identifier/success/creates_and_returns_a_new_identifier.yml +97 -0
  25. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_initialize/invalid_platform_id/raises_an_exception.yml +52 -0
  26. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_initialize/invalid_platform_secret/raises_an_exception.yml +52 -0
  27. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_initialize/success/initializes_the_authentication_token.yml +48 -0
  28. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/duplicate_identifer_resource_trial_triplet/raises_an_exception.yml +194 -0
  29. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/invalid_resource_string/raises_an_exception.yml +145 -0
  30. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/allows_answers_with_distinct_identifiers_to_be_saved.yml +244 -0
  31. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/allows_answers_with_distinct_resources_to_be_saved.yml +195 -0
  32. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/allows_answers_with_distinct_trials_to_be_saved.yml +195 -0
  33. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/creates_a_multiple_choice_answer_associated_with_the_given_identifier.yml +146 -0
  34. data/spec/lib/openstax/exchange/client_configuration_spec.rb +58 -0
  35. data/spec/lib/openstax/exchange/fake_client_v1_spec.rb +14 -0
  36. data/spec/lib/openstax/exchange/real_client_v1_spec.rb +9 -0
  37. data/spec/lib/openstax/exchange/shared_examples_for_exchange_client_v1.rb +208 -0
  38. data/spec/spec_helper.rb +52 -38
  39. metadata +97 -100
  40. checksums.yaml +0 -15
  41. data/spec/dummy/README.md +0 -1
  42. data/spec/dummy/Rakefile +0 -7
  43. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  44. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  45. data/spec/dummy/app/controllers/api/dummy_controller.rb +0 -11
  46. data/spec/dummy/app/controllers/api/events_controller.rb +0 -7
  47. data/spec/dummy/app/controllers/application_controller.rb +0 -7
  48. data/spec/dummy/app/controllers/oauth_controller.rb +0 -8
  49. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  50. data/spec/dummy/config.ru +0 -4
  51. data/spec/dummy/config/application.rb +0 -55
  52. data/spec/dummy/config/boot.rb +0 -10
  53. data/spec/dummy/config/database.yml +0 -25
  54. data/spec/dummy/config/environment.rb +0 -5
  55. data/spec/dummy/config/environments/development.rb +0 -29
  56. data/spec/dummy/config/environments/production.rb +0 -69
  57. data/spec/dummy/config/environments/test.rb +0 -35
  58. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  59. data/spec/dummy/config/initializers/inflections.rb +0 -15
  60. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  61. data/spec/dummy/config/initializers/openstax_exchange.rb +0 -10
  62. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  63. data/spec/dummy/config/initializers/session_store.rb +0 -8
  64. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  65. data/spec/dummy/config/locales/en.yml +0 -5
  66. data/spec/dummy/config/routes.rb +0 -11
  67. data/spec/dummy/db/development.sqlite3 +0 -0
  68. data/spec/dummy/db/schema.rb +0 -16
  69. data/spec/dummy/db/test.sqlite3 +0 -0
  70. data/spec/dummy/log/development.log +0 -929
  71. data/spec/dummy/log/test.log +0 -46753
  72. data/spec/dummy/public/404.html +0 -26
  73. data/spec/dummy/public/422.html +0 -26
  74. data/spec/dummy/public/500.html +0 -25
  75. data/spec/dummy/public/favicon.ico +0 -0
  76. data/spec/dummy/script/rails +0 -6
  77. data/spec/lib/openstax_exchange_spec.rb +0 -23
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- </div>
24
- </body>
25
- </html>
File without changes
@@ -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,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module OpenStax
4
- describe Exchange do
5
-
6
- it 'makes api calls' do
7
- expect(::Api::DummyController.last_action).to be_nil
8
- expect(Api::DummyController.last_params).to be_nil
9
- Exchange.api_call(:post, 'dummy', :params => {:test => true})
10
- expect(Api::DummyController.last_action).to eq :dummy
11
- expect(Api::DummyController.last_params).to include 'test' => 'true'
12
- end
13
-
14
- it 'makes api calls to events (index)' do
15
- Api::EventsController.last_action = nil
16
- Api::EventsController.last_params = nil
17
- Exchange.search_events('sth')
18
- expect(Api::EventsController.last_action).to eq :index
19
- expect(Api::EventsController.last_params).to include :q => 'sth'
20
- end
21
-
22
- end
23
- end