tin_can_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +80 -0
  7. data/Rakefile +12 -0
  8. data/lib/tin_can_api/about.rb +15 -0
  9. data/lib/tin_can_api/activity.rb +41 -0
  10. data/lib/tin_can_api/activity_definition.rb +139 -0
  11. data/lib/tin_can_api/agent.rb +44 -0
  12. data/lib/tin_can_api/agent_account.rb +33 -0
  13. data/lib/tin_can_api/attachment.rb +64 -0
  14. data/lib/tin_can_api/client.rb +402 -0
  15. data/lib/tin_can_api/context.rb +54 -0
  16. data/lib/tin_can_api/context_activities.rb +102 -0
  17. data/lib/tin_can_api/documents/activity_profile_document.rb +15 -0
  18. data/lib/tin_can_api/documents/agent_profile_document.rb +15 -0
  19. data/lib/tin_can_api/documents/document.rb +20 -0
  20. data/lib/tin_can_api/documents/state_document.rb +15 -0
  21. data/lib/tin_can_api/enum.rb +42 -0
  22. data/lib/tin_can_api/errors.rb +9 -0
  23. data/lib/tin_can_api/group.rb +37 -0
  24. data/lib/tin_can_api/interaction_component.rb +32 -0
  25. data/lib/tin_can_api/interaction_type.rb +58 -0
  26. data/lib/tin_can_api/lrs_response.rb +14 -0
  27. data/lib/tin_can_api/query_result_format.rb +6 -0
  28. data/lib/tin_can_api/remote_lrs.rb +15 -0
  29. data/lib/tin_can_api/result.rb +45 -0
  30. data/lib/tin_can_api/score.rb +39 -0
  31. data/lib/tin_can_api/statement.rb +53 -0
  32. data/lib/tin_can_api/statement_ref.rb +31 -0
  33. data/lib/tin_can_api/statements/statements_base.rb +70 -0
  34. data/lib/tin_can_api/statements_query.rb +42 -0
  35. data/lib/tin_can_api/statements_query_v095.rb +42 -0
  36. data/lib/tin_can_api/statements_result.rb +17 -0
  37. data/lib/tin_can_api/sub_statement.rb +19 -0
  38. data/lib/tin_can_api/tcapi_version.rb +27 -0
  39. data/lib/tin_can_api/verb.rb +35 -0
  40. data/lib/tin_can_api/version.rb +4 -0
  41. data/lib/tin_can_api.rb +37 -0
  42. data/spec/fixtures/about.json +10 -0
  43. data/spec/fixtures/statement.json +33 -0
  44. data/spec/spec_helper.rb +106 -0
  45. data/spec/support/helpers.rb +43 -0
  46. data/spec/tin_can_api/activity_definition_spec.rb +37 -0
  47. data/spec/tin_can_api/activity_spec.rb +23 -0
  48. data/spec/tin_can_api/agent_account_spec.rb +13 -0
  49. data/spec/tin_can_api/agent_spec.rb +24 -0
  50. data/spec/tin_can_api/attachment_spec.rb +26 -0
  51. data/spec/tin_can_api/client_spec.rb +44 -0
  52. data/spec/tin_can_api/context_activities_spec.rb +57 -0
  53. data/spec/tin_can_api/context_spec.rb +32 -0
  54. data/spec/tin_can_api/group_spec.rb +15 -0
  55. data/spec/tin_can_api/interaction_component_spec.rb +18 -0
  56. data/spec/tin_can_api/result_spec.rb +26 -0
  57. data/spec/tin_can_api/score_spec.rb +12 -0
  58. data/spec/tin_can_api/statement_ref_spec.rb +19 -0
  59. data/spec/tin_can_api/statement_spec.rb +57 -0
  60. data/spec/tin_can_api/sub_statement_spec.rb +30 -0
  61. data/spec/tin_can_api/verb_spec.rb +17 -0
  62. data/tin_can_api.gemspec +30 -0
  63. metadata +238 -0
@@ -0,0 +1,106 @@
1
+ require 'webmock/rspec'
2
+ require 'tin_can_api'
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+
22
+ # Requires supporting files with custom matchers and macros, etc,
23
+ # in ./support/ and its subdirectories.
24
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
25
+
26
+ RSpec.configure do |config|
27
+ # rspec-expectations config goes here. You can use an alternate
28
+ # assertion/expectation library such as wrong or the stdlib/minitest
29
+ # assertions if you prefer.
30
+ config.expect_with :rspec do |expectations|
31
+ # This option will default to `true` in RSpec 4. It makes the `description`
32
+ # and `failure_message` of custom matchers include text for helper methods
33
+ # defined using `chain`, e.g.:
34
+ # be_bigger_than(2).and_smaller_than(4).description
35
+ # # => "be bigger than 2 and smaller than 4"
36
+ # ...rather than:
37
+ # # => "be bigger than 2"
38
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
39
+ end
40
+
41
+ # rspec-mocks config goes here. You can use an alternate test double
42
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
43
+ config.mock_with :rspec do |mocks|
44
+ # Prevents you from mocking or stubbing a method that does not exist on
45
+ # a real object. This is generally recommended, and will default to
46
+ # `true` in RSpec 4.
47
+ mocks.verify_partial_doubles = true
48
+ end
49
+
50
+ # The settings below are suggested to provide a good initial experience
51
+ # with RSpec, but feel free to customize to your heart's content.
52
+ =begin
53
+ # These two settings work together to allow you to limit a spec run
54
+ # to individual examples or groups you care about by tagging them with
55
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
56
+ # get run.
57
+ config.filter_run :focus
58
+ config.run_all_when_everything_filtered = true
59
+
60
+ # Limits the available syntax to the non-monkey patched syntax that is
61
+ # recommended. For more details, see:
62
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
63
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
65
+ config.disable_monkey_patching!
66
+
67
+ # This setting enables warnings. It's recommended, but in some cases may
68
+ # be too noisy due to issues in dependencies.
69
+ config.warnings = true
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = 'doc'
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Run specs in random order to surface order dependencies. If you find an
87
+ # order dependency and want to debug it, you can fix the order by providing
88
+ # the seed, which is printed after each run.
89
+ # --seed 1234
90
+ config.order = :random
91
+
92
+ # Seed global randomization in this process using the `--seed` CLI option.
93
+ # Setting this allows you to use `--seed` to deterministically reproduce
94
+ # test failures related to randomization by passing the same `--seed` value
95
+ # as the one that triggered the failure.
96
+ Kernel.srand config.seed
97
+ =end
98
+ end
99
+
100
+ def fixture_path
101
+ File.expand_path("../fixtures", __FILE__)
102
+ end
103
+
104
+ def fixture(file)
105
+ File.new(File.join(fixture_path, '/', file))
106
+ end
@@ -0,0 +1,43 @@
1
+ module Helpers
2
+ def get_agent(name, type, value)
3
+ agent = TinCanApi::Agent.new(name: name)
4
+ case type
5
+ when :mbox
6
+ agent.mbox = value
7
+ when :open_id
8
+ agent.open_id = value
9
+ when :mbox_sha1_sum
10
+ agent.mbox_sha1_sum = value
11
+ when :account
12
+ parts = value.split('|')
13
+ account = TinCanApi::AgentAccount.new(home_page: parts.first, name: parts.last)
14
+ agent.account = account
15
+ end
16
+ agent
17
+ end
18
+
19
+ def create_interaction_component(id, description)
20
+ component = TinCanApi::InteractionComponent.new
21
+ component.id = id
22
+ map = {}
23
+ map['en-US'] = description
24
+ component.description = map
25
+ [component]
26
+ end
27
+
28
+ def assert_serialize_and_deserialize(object)
29
+ TinCanApi::TCAPIVersion.values.each do |version|
30
+ assert_serialize_and_deserialize_for_version(object, version)
31
+ end
32
+ end
33
+
34
+ def assert_serialize_and_deserialize_for_version(object, version)
35
+ hash = object.serialize(version)
36
+ new_definition = object.class.new(json: hash.to_json)
37
+ expect(hash).to eq(new_definition.serialize(version))
38
+ end
39
+
40
+ def default_request_headers
41
+ {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1', 'X-Experience-Api-Version'=>'1.0.1'}
42
+ end
43
+ end
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::ActivityDefinition do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ definition = TinCanApi::ActivityDefinition.new
9
+ definition.choices = create_interaction_component('choice1', 'Choice 1')
10
+ definition.correct_responses_pattern = ['correct_response']
11
+
12
+ map = {}
13
+ map['en-US'] = 'Activity Definition Description'
14
+ definition.description = map
15
+
16
+ extensions = {}
17
+ extensions['http://example.com/extensions'] = 'extensionValue'
18
+ definition.extensions = extensions
19
+
20
+ map = {}
21
+ map['en-US'] = 'Activity Definition'
22
+ definition.name = map
23
+
24
+ definition.scale = create_interaction_component('scale1', 'Scale 1')
25
+ definition.source = create_interaction_component('source1', 'Source 1')
26
+ definition.steps = create_interaction_component('steps1', 'Steps 1')
27
+ definition.target = create_interaction_component('target1', 'Target 1')
28
+
29
+ definition.type = 'http://adlnet.gov/expapi/activities/assessment'
30
+
31
+ TinCanApi::InteractionType.values.each do |type|
32
+ definition.interaction_type = type
33
+ assert_serialize_and_deserialize(definition)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::Activity do
5
+ include Helpers
6
+
7
+ it 'sets the object type' do
8
+ activity = TinCanApi::Activity.new
9
+ expect(activity.object_type).to eq('Activity')
10
+ end
11
+
12
+ it 'should serialize and deserialize' do
13
+ activity = TinCanApi::Activity.new
14
+ activity.id = 'http://example.com/activity'
15
+ definition = TinCanApi::ActivityDefinition.new
16
+ map = {}
17
+ map['en-US'] = 'Activity Definition'
18
+ definition.name = map
19
+ activity.definition = definition
20
+ assert_serialize_and_deserialize(activity)
21
+ end
22
+
23
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::AgentAccount do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ account = TinCanApi::AgentAccount.new
9
+ account.home_page = 'http://example.com'
10
+ account.name = 'joeuser'
11
+ assert_serialize_and_deserialize(account)
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::Agent do
5
+ include Helpers
6
+ it 'should serialize and deserialize' do
7
+ agent = TinCanApi::Agent.new
8
+ name = 'Joe User'
9
+ ids = {
10
+ mbox: 'mailto:joeuser@example.com',
11
+ open_id: 'http://openid.org/joeuser',
12
+ mbox_sha1_sum: 'b623062e19c5608ab0e1342e5011d48292ce00e3',
13
+ account: 'http://example.com|joeuser'
14
+ }
15
+ ids.each_pair do |key, value|
16
+ TinCanApi::TCAPIVersion.values.each do |version|
17
+ agent = get_agent(name, key, value)
18
+ hash = agent.serialize(version)
19
+ new_agent = TinCanApi::Agent.new(json: hash.to_json)
20
+ expect(hash).to eq(new_agent.serialize(version))
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::Attachment do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ attachment = TinCanApi::Attachment.new
9
+ attachment.content_type = 'text/plain'
10
+ map = {}
11
+ map['en-US'] = 'Some attachment'
12
+ attachment.display = map
13
+
14
+ map = {}
15
+ map['en-US'] = 'Some attachment description'
16
+ attachment.description = map
17
+
18
+ attachment.file_url = URI.parse('http://example.com/somefile')
19
+ attachment.length = 27
20
+ attachment.sha2 = '495395e777cd98da653df9615d09c0fd6bb2f8d4788394cd53c56a3bfdcd848a'
21
+ attachment.usage_type = Addressable::URI.parse('http://example.com/attachment-usage/test')
22
+
23
+ assert_serialize_and_deserialize(attachment)
24
+
25
+ end
26
+ end
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::Client do
5
+ include Helpers
6
+
7
+ describe 'about' do
8
+ it 'is successful' do
9
+ stub_request(:get, "http://user:password@www.example.com/about").
10
+ with(headers: default_request_headers).
11
+ to_return(
12
+ status: 200,
13
+ body: fixture('about.json'),
14
+ headers: {})
15
+
16
+ client = TinCanApi::Client.new do |c|
17
+ c.end_point = 'http://www.example.com'
18
+ c.user_name = 'user'
19
+ c.password = 'password'
20
+ end
21
+
22
+ response = client.about
23
+ expect(response.success).to be(true)
24
+ end
25
+
26
+ it 'creates an about instance' do
27
+ stub_request(:get, "http://user:password@www.example.com/about").
28
+ with(headers: default_request_headers).
29
+ to_return(
30
+ status: 200,
31
+ body: fixture('about.json'),
32
+ headers: {})
33
+
34
+ client = TinCanApi::Client.new do |c|
35
+ c.end_point = 'http://www.example.com'
36
+ c.user_name = 'user'
37
+ c.password = 'password'
38
+ end
39
+
40
+ response = client.about
41
+ expect(response.content).to be_a(TinCanApi::About)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::ContextActivities do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ context = TinCanApi::ContextActivities.new
9
+ activity = TinCanApi::Activity.new
10
+ activity.id = 'http://example.com/parent'
11
+ context.parent = [activity]
12
+
13
+ activity = TinCanApi::Activity.new
14
+ activity.id = 'http://example.com/grouping'
15
+ context.grouping = [activity]
16
+
17
+ activity = TinCanApi::Activity.new
18
+ activity.id = 'http://example.com/other'
19
+ context.other = [activity]
20
+
21
+ assert_serialize_and_deserialize(context)
22
+ end
23
+
24
+ # 'category' arrived in 1.0.0, so confirm it works in everything after that point, which is to say not 0.95
25
+ it 'should work with category in version 1.0.0 and later' do
26
+ context = TinCanApi::ContextActivities.new
27
+ activity = TinCanApi::Activity.new
28
+ activity.id = 'http://example.com/parent'
29
+ context.parent = [activity]
30
+
31
+ activity = TinCanApi::Activity.new
32
+ activity.id = 'http://example.com/grouping'
33
+ context.grouping = [activity]
34
+
35
+ activity = TinCanApi::Activity.new
36
+ activity.id = 'http://example.com/other'
37
+ context.other = [activity]
38
+
39
+ activity = TinCanApi::Activity.new
40
+ activity.id = 'http://example.com/category'
41
+ context.category = [activity]
42
+
43
+ assert_serialize_and_deserialize_for_version(context, TinCanApi::TCAPIVersion::V101)
44
+ assert_serialize_and_deserialize_for_version(context, TinCanApi::TCAPIVersion::V100)
45
+ end
46
+
47
+ # 'category' is not supported in 0.95, make sure it isn't
48
+ it 'should fail with category in version 0.95 and later' do
49
+ context = TinCanApi::ContextActivities.new
50
+
51
+ activity = TinCanApi::Activity.new
52
+ activity.id = 'http://example.com/category'
53
+ context.category = [activity]
54
+
55
+ expect{assert_serialize_and_deserialize_for_version(context, TinCanApi::TCAPIVersion::V095)}.to raise_error(TinCanApi::Errors::IncompatibleTCAPIVersion)
56
+ end
57
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::Context do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ context = TinCanApi::Context.new
9
+ activities = TinCanApi::ContextActivities.new
10
+ activity = TinCanApi::Activity.new
11
+ activity.id = 'http://example.com/activity'
12
+ activities.parent = [activity]
13
+ context.context_activities = activities
14
+
15
+ map = {}
16
+ map['http://example.com/extension'] = 'extension value'
17
+ context.extensions = map
18
+
19
+ context.instructor = get_agent('Instructor', 'mbox', 'mailto:instructor@example.com')
20
+ context.language = 'en-US'
21
+ context.platform = 'iPhone 5'
22
+ context.registration = SecureRandom.uuid
23
+ context.revision = '1.2.3'
24
+ ref = TinCanApi::StatementRef.new
25
+ ref.id = SecureRandom.uuid
26
+ context.statement = ref
27
+ context.team = get_agent('Group', 'mbox', 'mailto:group@example.com')
28
+
29
+ assert_serialize_and_deserialize(context)
30
+ end
31
+
32
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::Group do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ members = (1..10).map {|member| get_agent("Member #{member}", :mbox, "mailto:#{member}@example.com")}
9
+ group = TinCanApi::Group.new
10
+ group.name = 'Group'
11
+ group.mbox = 'mailto:group@example.com'
12
+ group.members = members
13
+ assert_serialize_and_deserialize(group)
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::InteractionComponent do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ component = TinCanApi::InteractionComponent.new
9
+ component.id = 'choice1'
10
+
11
+ map = {}
12
+ map['en-US'] = 'Some choice'
13
+ component.description = map
14
+
15
+ assert_serialize_and_deserialize(component)
16
+ end
17
+
18
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'ruby-duration'
4
+
5
+ describe TinCanApi::Result do
6
+ include Helpers
7
+
8
+ it 'should serialize and deserialize' do
9
+ result = TinCanApi::Result.new
10
+ result.completion = true
11
+ result.duration = Duration.new('P1DT8H')
12
+
13
+ map = {}
14
+ map['http://example.com/extension'] = 'extension value'
15
+ result.extensions = map
16
+
17
+ result.response = "Here's a response"
18
+
19
+ score = TinCanApi::Score.new(raw: 0.43)
20
+ result.score = score
21
+ result.success = false
22
+
23
+ assert_serialize_and_deserialize(result)
24
+
25
+ end
26
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::Score do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ score = TinCanApi::Score.new(max: 100.0, min: 0.0, raw: 80.0, scaled: 0.8)
9
+
10
+ assert_serialize_and_deserialize(score)
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::StatementRef do
5
+ include Helpers
6
+
7
+ it 'sets the object type' do
8
+ ref = TinCanApi::StatementRef.new
9
+ expect(ref.object_type).to eq('StatementRef')
10
+ end
11
+
12
+ it 'should serialize and deserialize' do
13
+ ref = TinCanApi::StatementRef.new
14
+ ref.id = SecureRandom.uuid
15
+
16
+ assert_serialize_and_deserialize(ref)
17
+ end
18
+
19
+ end
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::Statement do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ targets = []
9
+ activity = TinCanApi::Activity.new
10
+ activity.id = 'http://example.com/activity'
11
+ targets << activity
12
+ targets << get_agent('Target', 'mbox', 'mailto:target@example.com')
13
+ ref = TinCanApi::StatementRef.new
14
+ ref.id = SecureRandom.uuid
15
+ targets << ref
16
+
17
+ sub = TinCanApi::SubStatement.new
18
+ sub.actor = get_agent('Sub', 'mbox', 'mailto:sub@example.com')
19
+ verb = TinCanApi::Verb.new
20
+ verb.id = 'http://example.com/verb'
21
+ sub.verb = verb
22
+ activity = TinCanApi::Activity.new
23
+ activity.id = 'http://example.com/sub-activity'
24
+ sub.object = activity
25
+ targets << sub
26
+
27
+ statement = TinCanApi::Statement.new
28
+ statement.actor = get_agent('Joe', 'mbox', 'mailto:joe@example.com')
29
+ attachment = TinCanApi::Attachment.new
30
+ attachment.sha2 = '123'
31
+ statement.attachments = [attachment]
32
+
33
+ statement.authority = get_agent('Authority', 'mbox', 'mailto:authority@example.com')
34
+
35
+ context = TinCanApi::Context.new
36
+ context.language = 'en-US'
37
+ statement.context = context
38
+
39
+ statement.id = SecureRandom.uuid
40
+
41
+ result = TinCanApi::Result.new
42
+ result.completion = true
43
+ statement.result = result
44
+
45
+ statement.stored = Time.now
46
+ statement.timestamp = Time.now
47
+
48
+ verb = TinCanApi::Verb.new
49
+ verb.id = 'http://example.com/verb'
50
+ statement.verb = verb
51
+
52
+ targets.each do |target|
53
+ statement.object = target
54
+ assert_serialize_and_deserialize(statement)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::SubStatement do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ statement = TinCanApi::SubStatement.new
9
+ statement.actor = get_agent('Joe', 'mbox', 'mailto:joe@example.com')
10
+ context = TinCanApi::Context.new
11
+ context.language = 'en-US'
12
+ statement.context = context
13
+
14
+ activity = TinCanApi::Activity.new
15
+ activity.id = 'http://example.com/activity'
16
+ statement.object = activity
17
+
18
+ result = TinCanApi::Result.new
19
+ result.completion = true
20
+ statement.result = result
21
+
22
+ statement.timestamp = Time.now
23
+
24
+ verb = TinCanApi::Verb.new
25
+ verb.id = 'http://example.com/verb'
26
+ statement.verb = verb
27
+
28
+ assert_serialize_and_deserialize(statement)
29
+ end
30
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe TinCanApi::Verb do
5
+ include Helpers
6
+
7
+ it 'should serialize and deserialize' do
8
+ verb = TinCanApi::Verb.new
9
+ verb.id = 'http://example.com/attempted'
10
+ map = {}
11
+ map['en-US'] = 'attempted'
12
+ verb.display = map
13
+
14
+ assert_serialize_and_deserialize(verb)
15
+
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tin_can_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tin_can_api"
8
+ spec.version = TinCanApi::VERSION
9
+ spec.authors = ["Paul Coleman"]
10
+ spec.email = ["pcoleman@coleman.co.uk"]
11
+ spec.summary = "A Ruby library for implementing Tin Can API."
12
+ spec.description = %q{A Ruby library for interacting with a Learning Record Store (LRS) using the Tin Can API (Experience API)}
13
+ spec.homepage = 'https://github.com/pwcoleman/TinCanRuby'
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '~> 3.2'
24
+ spec.add_development_dependency 'pry', '~> 0.10'
25
+ spec.add_development_dependency 'webmock', '~> 1.20'
26
+
27
+ spec.add_runtime_dependency 'faraday', '~> 0.9'
28
+ spec.add_runtime_dependency 'addressable', '~> 2.3'
29
+ spec.add_runtime_dependency 'ruby-duration', '~> 3.2'
30
+ end