ruby-iactionable 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +3 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +43 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/lib/iactionable/api.rb +170 -0
- data/lib/iactionable/connection.rb +114 -0
- data/lib/iactionable/error.rb +17 -0
- data/lib/iactionable/objects/achievement.rb +29 -0
- data/lib/iactionable/objects/awardable.rb +50 -0
- data/lib/iactionable/objects/challenge.rb +27 -0
- data/lib/iactionable/objects/goal.rb +30 -0
- data/lib/iactionable/objects/i_actionable_object.rb +36 -0
- data/lib/iactionable/objects/identifier.rb +17 -0
- data/lib/iactionable/objects/leaderboard.rb +15 -0
- data/lib/iactionable/objects/leaderboard_report.rb +30 -0
- data/lib/iactionable/objects/level.rb +24 -0
- data/lib/iactionable/objects/level_type.rb +15 -0
- data/lib/iactionable/objects/point_type.rb +15 -0
- data/lib/iactionable/objects/profile_achievements.rb +20 -0
- data/lib/iactionable/objects/profile_challenges.rb +20 -0
- data/lib/iactionable/objects/profile_goals.rb +20 -0
- data/lib/iactionable/objects/profile_level.rb +20 -0
- data/lib/iactionable/objects/profile_notifications.rb +29 -0
- data/lib/iactionable/objects/profile_points.rb +29 -0
- data/lib/iactionable/objects/profile_summary.rb +32 -0
- data/lib/iactionable/objects/progress.rb +46 -0
- data/lib/iactionable/objects.rb +27 -0
- data/lib/iactionable/settings.rb +30 -0
- data/lib/iactionable/version.rb +3 -0
- data/lib/iactionable.rb +9 -0
- data/ruby_iactionable.gemspec +28 -0
- data/spec/api/get_achievements_api_response_spec.rb +46 -0
- data/spec/api/get_challenges_api_response_spec.rb +42 -0
- data/spec/api/get_goals_api_response_spec.rb +46 -0
- data/spec/api/get_leaderboard_api_response_spec.rb +76 -0
- data/spec/api/get_profile_achievements_api_response_spec.rb +99 -0
- data/spec/api/get_profile_api_response_spec.rb +103 -0
- data/spec/api/get_profile_challenges_api_response_spec.rb +85 -0
- data/spec/api/get_profile_goals_api_response_spec.rb +89 -0
- data/spec/api/get_profile_notifications_api_response_spec.rb +75 -0
- data/spec/api/get_profile_points_api_response_spec.rb +67 -0
- data/spec/api_spec.rb +314 -0
- data/spec/connection_spec.rb +111 -0
- data/spec/settings_spec.rb +52 -0
- data/spec/spec_helper.rb +1 -0
- metadata +163 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe "API response to get_profile_achievements" do
|
4
|
+
before do
|
5
|
+
@sample_response = {
|
6
|
+
"Available" => [
|
7
|
+
{
|
8
|
+
"Key" => "super_user",
|
9
|
+
"Description" => "Post 35 Photos and make 50 Comments",
|
10
|
+
"ImageURL" => "http://iactionable.blob.core.windows.net/achievementimages/99999",
|
11
|
+
"Name" => "Super User",
|
12
|
+
"Progress" => [
|
13
|
+
{
|
14
|
+
"ConditionMetDate" => nil,
|
15
|
+
"CurrentValue" => 12,
|
16
|
+
"Description" => "Post 35 Photos",
|
17
|
+
"RequiredValue" => "35"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"ConditionMetDate" => nil,
|
21
|
+
"CurrentValue" => 6,
|
22
|
+
"Description" => "Make 50 Comments",
|
23
|
+
"RequiredValue" => "50"
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"Completed" => [
|
29
|
+
{
|
30
|
+
"Key" => "you_can_talk",
|
31
|
+
"Description" => "Post a Comment on any blog post.",
|
32
|
+
"ImageURL" => "http://iactionable.blob.core.windows.net/achievementimages/99998",
|
33
|
+
"Name" => "You can talk!",
|
34
|
+
"Progress" => [
|
35
|
+
{
|
36
|
+
"ConditionMetDate" => "/Date(1275706032317-0600)/",
|
37
|
+
"CurrentValue" => 1,
|
38
|
+
"Description" => "Make 1 Comment",
|
39
|
+
"RequiredValue" => "1"
|
40
|
+
}
|
41
|
+
],
|
42
|
+
"AwardDate" => "/Date(1275706032317-0600)/"
|
43
|
+
}
|
44
|
+
]
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not raise error on wrapping in an object" do
|
49
|
+
lambda { IActionable::Objects::ProfileAchievements.new(@sample_response) }.should_not raise_error
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "when wrapped in an object" do
|
53
|
+
before do
|
54
|
+
@wrapped = IActionable::Objects::ProfileAchievements.new(Marshal.load(Marshal.dump(@sample_response)))
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should contain ar array of available achievements" do
|
58
|
+
@wrapped.available.should be_instance_of Array
|
59
|
+
@wrapped.available.first.key.should == @sample_response["Available"][0]["Key"]
|
60
|
+
@wrapped.available.first.description.should == @sample_response["Available"][0]["Description"]
|
61
|
+
@wrapped.available.first.image_url.should == @sample_response["Available"][0]["ImageURL"]
|
62
|
+
@wrapped.available.first.name.should == @sample_response["Available"][0]["Name"]
|
63
|
+
@wrapped.available.first.award_date.should be_nil
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should contain an array of progresses within each available achievement" do
|
67
|
+
@wrapped.available.first.progress.should be_instance_of Array
|
68
|
+
@wrapped.available.first.progress.first.condition_met_date.should be_nil
|
69
|
+
@wrapped.available.first.progress.first.current_value.should == @sample_response["Available"][0]["Progress"][0]["CurrentValue"]
|
70
|
+
@wrapped.available.first.progress.first.description.should == @sample_response["Available"][0]["Progress"][0]["Description"]
|
71
|
+
@wrapped.available.first.progress.first.required_value.should == @sample_response["Available"][0]["Progress"][0]["RequiredValue"]
|
72
|
+
@wrapped.available.first.progress.last.condition_met_date.should be_nil
|
73
|
+
@wrapped.available.first.progress.last.current_value.should == @sample_response["Available"][0]["Progress"][1]["CurrentValue"]
|
74
|
+
@wrapped.available.first.progress.last.description.should == @sample_response["Available"][0]["Progress"][1]["Description"]
|
75
|
+
@wrapped.available.first.progress.last.required_value.should == @sample_response["Available"][0]["Progress"][1]["RequiredValue"]
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should contain ar array of completed achievements" do
|
79
|
+
@wrapped.completed.should be_instance_of Array
|
80
|
+
@wrapped.completed.first.key.should == @sample_response["Completed"][0]["Key"]
|
81
|
+
@wrapped.completed.first.description.should == @sample_response["Completed"][0]["Description"]
|
82
|
+
@wrapped.completed.first.image_url.should == @sample_response["Completed"][0]["ImageURL"]
|
83
|
+
@wrapped.completed.first.name.should == @sample_response["Completed"][0]["Name"]
|
84
|
+
@wrapped.completed.first.award_date.should_not be_nil
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should contain an array of progresses within each completed achievement" do
|
88
|
+
@wrapped.completed.first.progress.should be_instance_of Array
|
89
|
+
@wrapped.completed.first.progress.first.condition_met_date.should_not be_nil
|
90
|
+
@wrapped.completed.first.progress.first.current_value.should == @sample_response["Completed"][0]["Progress"][0]["CurrentValue"]
|
91
|
+
@wrapped.completed.first.progress.first.description.should == @sample_response["Completed"][0]["Progress"][0]["Description"]
|
92
|
+
@wrapped.completed.first.progress.first.required_value.should == @sample_response["Completed"][0]["Progress"][0]["RequiredValue"]
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should convert to a hash equal to the original" do
|
96
|
+
hash_including(@sample_response).should == @wrapped.to_hash
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe "API response to get_profile" do
|
4
|
+
before do
|
5
|
+
@sample_response = {
|
6
|
+
"DisplayName" => "Jason",
|
7
|
+
"Identifiers" => [
|
8
|
+
{
|
9
|
+
"ID" => "jason@example.com",
|
10
|
+
"IDHash" => "eba69e62f8bc92297b7a97659b5d6130",
|
11
|
+
"IDType" => "Email"
|
12
|
+
}
|
13
|
+
],
|
14
|
+
"Points" => [
|
15
|
+
{
|
16
|
+
"Level" => {
|
17
|
+
"Current" => {
|
18
|
+
"LevelType" => {
|
19
|
+
"Key" => "player_experience_level",
|
20
|
+
"Name" => "Experience Level"
|
21
|
+
},
|
22
|
+
"Name" => "Noobie",
|
23
|
+
"Number" => 1,
|
24
|
+
"RequiredPoints" => 10
|
25
|
+
},
|
26
|
+
"Next" => {
|
27
|
+
"LevelType" => {
|
28
|
+
"Key" => "player_experience_level",
|
29
|
+
"Name" => "Experience Level"
|
30
|
+
},
|
31
|
+
"Name" => "Expert",
|
32
|
+
"Number" => 2,
|
33
|
+
"RequiredPoints" => 100
|
34
|
+
},
|
35
|
+
},
|
36
|
+
"PointType" => {
|
37
|
+
"Key" => "experience_points",
|
38
|
+
"Name" => "Experience Points"
|
39
|
+
},
|
40
|
+
"Points" => 12
|
41
|
+
}
|
42
|
+
],
|
43
|
+
"RecentAchievements" => [
|
44
|
+
{
|
45
|
+
"Key" => "i_love_stuff",
|
46
|
+
"Description" => "Favorite 10 Items",
|
47
|
+
"ImageURL" => "http://iactionable.blob.core.windows.net/achievementimages/9999",
|
48
|
+
"Name" => "I love stuff!"
|
49
|
+
}
|
50
|
+
]
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should not raise error on wrapping in an object" do
|
55
|
+
lambda { IActionable::Objects::ProfileSummary.new(@sample_response) }.should_not raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "when wrapped in an object" do
|
59
|
+
before do
|
60
|
+
@wrapped = IActionable::Objects::ProfileSummary.new(Marshal.load(Marshal.dump(@sample_response)))
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should contain the display name" do
|
64
|
+
@wrapped.display_name.should == @sample_response["DisplayName"]
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should contain ar array of identifiers" do
|
68
|
+
@wrapped.identifiers.should be_instance_of Array
|
69
|
+
@wrapped.identifiers.first.id.should == @sample_response["Identifiers"][0]["ID"]
|
70
|
+
@wrapped.identifiers.first.id_hash.should == @sample_response["Identifiers"][0]["IDHash"]
|
71
|
+
@wrapped.identifiers.first.id_type.should == @sample_response["Identifiers"][0]["IDType"]
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should contain an array of point summaries" do
|
75
|
+
@wrapped.points.should be_instance_of Array
|
76
|
+
@wrapped.points.first.points.should == @sample_response["Points"][0]["Points"]
|
77
|
+
@wrapped.points.first.point_type.key.should == @sample_response["Points"][0]["PointType"]["Key"]
|
78
|
+
@wrapped.points.first.point_type.name.should == @sample_response["Points"][0]["PointType"]["Name"]
|
79
|
+
@wrapped.points.first.level.current.name.should == @sample_response["Points"][0]["Level"]["Current"]["Name"]
|
80
|
+
@wrapped.points.first.level.current.number.should == @sample_response["Points"][0]["Level"]["Current"]["Number"]
|
81
|
+
@wrapped.points.first.level.current.required_points.should == @sample_response["Points"][0]["Level"]["Current"]["RequiredPoints"]
|
82
|
+
@wrapped.points.first.level.current.level_type.key.should == @sample_response["Points"][0]["Level"]["Current"]["LevelType"]["Key"]
|
83
|
+
@wrapped.points.first.level.current.level_type.name.should == @sample_response["Points"][0]["Level"]["Current"]["LevelType"]["Name"]
|
84
|
+
@wrapped.points.first.level.next.name.should == @sample_response["Points"][0]["Level"]["Next"]["Name"]
|
85
|
+
@wrapped.points.first.level.next.number.should == @sample_response["Points"][0]["Level"]["Next"]["Number"]
|
86
|
+
@wrapped.points.first.level.next.required_points.should == @sample_response["Points"][0]["Level"]["Next"]["RequiredPoints"]
|
87
|
+
@wrapped.points.first.level.next.level_type.key.should == @sample_response["Points"][0]["Level"]["Next"]["LevelType"]["Key"]
|
88
|
+
@wrapped.points.first.level.next.level_type.name.should == @sample_response["Points"][0]["Level"]["Next"]["LevelType"]["Name"]
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should contain an array of recent achievements" do
|
92
|
+
@wrapped.recent_achievements.should be_instance_of Array
|
93
|
+
@wrapped.recent_achievements.first.key.should == @sample_response["RecentAchievements"][0]["Key"]
|
94
|
+
@wrapped.recent_achievements.first.description.should == @sample_response["RecentAchievements"][0]["Description"]
|
95
|
+
@wrapped.recent_achievements.first.image_url.should == @sample_response["RecentAchievements"][0]["ImageURL"]
|
96
|
+
@wrapped.recent_achievements.first.name.should == @sample_response["RecentAchievements"][0]["Name"]
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should convert to a hash equal to the original" do
|
100
|
+
hash_including(@sample_response).should == @wrapped.to_hash
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe "API response to get_profile_challenges" do
|
4
|
+
before do
|
5
|
+
@sample_response = {
|
6
|
+
"Available" => [
|
7
|
+
{
|
8
|
+
"Key" => "hard_challenge",
|
9
|
+
"Description" => "Do something hard 10 times and earn 200 points",
|
10
|
+
"Name" => "Easy Challenge",
|
11
|
+
"Progress" => [
|
12
|
+
{
|
13
|
+
"ConditionMetDate" => nil,
|
14
|
+
"CurrentValue" => 9,
|
15
|
+
"Description" => "Do something hard 10 times",
|
16
|
+
"RequiredValue" => 10
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"Completed" => [
|
22
|
+
{
|
23
|
+
"Key" => "easy_challenge",
|
24
|
+
"Description" => "Do something easy 5 times and earn 100 points",
|
25
|
+
"Name" => "Easy Challenge",
|
26
|
+
"Progress" => [
|
27
|
+
{
|
28
|
+
"ConditionMetDate" => "/Date(1275706032317-0600)/",
|
29
|
+
"CurrentValue" => 5,
|
30
|
+
"Description" => "Do something easy 5 times",
|
31
|
+
"RequiredValue" => "5"
|
32
|
+
}
|
33
|
+
],
|
34
|
+
"AwardDate" => "/Date(1275706032317-0600)/"
|
35
|
+
}
|
36
|
+
]
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should not raise error on wrapping in an object" do
|
41
|
+
lambda { IActionable::Objects::ProfileChallenges.new(@sample_response) }.should_not raise_error
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "when wrapped in an object" do
|
45
|
+
before do
|
46
|
+
@wrapped = IActionable::Objects::ProfileChallenges.new(Marshal.load(Marshal.dump(@sample_response)))
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should contain ar array of available challenges" do
|
50
|
+
@wrapped.available.should be_instance_of Array
|
51
|
+
@wrapped.available.first.key.should == @sample_response["Available"][0]["Key"]
|
52
|
+
@wrapped.available.first.description.should == @sample_response["Available"][0]["Description"]
|
53
|
+
@wrapped.available.first.name.should == @sample_response["Available"][0]["Name"]
|
54
|
+
@wrapped.available.first.award_date.should be_nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should contain an array of progresses within each available challenge" do
|
58
|
+
@wrapped.available.first.progress.should be_instance_of Array
|
59
|
+
@wrapped.available.first.progress.first.condition_met_date.should be_nil
|
60
|
+
@wrapped.available.first.progress.first.current_value.should == @sample_response["Available"][0]["Progress"][0]["CurrentValue"]
|
61
|
+
@wrapped.available.first.progress.first.description.should == @sample_response["Available"][0]["Progress"][0]["Description"]
|
62
|
+
@wrapped.available.first.progress.first.required_value.should == @sample_response["Available"][0]["Progress"][0]["RequiredValue"]
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should contain ar array of completed challenges" do
|
66
|
+
@wrapped.completed.should be_instance_of Array
|
67
|
+
@wrapped.completed.first.key.should == @sample_response["Completed"][0]["Key"]
|
68
|
+
@wrapped.completed.first.description.should == @sample_response["Completed"][0]["Description"]
|
69
|
+
@wrapped.completed.first.name.should == @sample_response["Completed"][0]["Name"]
|
70
|
+
@wrapped.completed.first.award_date.should_not be_nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should contain an array of progresses within each completed achievement" do
|
74
|
+
@wrapped.completed.first.progress.should be_instance_of Array
|
75
|
+
@wrapped.completed.first.progress.first.condition_met_date.should_not be_nil
|
76
|
+
@wrapped.completed.first.progress.first.current_value.should == @sample_response["Completed"][0]["Progress"][0]["CurrentValue"]
|
77
|
+
@wrapped.completed.first.progress.first.description.should == @sample_response["Completed"][0]["Progress"][0]["Description"]
|
78
|
+
@wrapped.completed.first.progress.first.required_value.should == @sample_response["Completed"][0]["Progress"][0]["RequiredValue"]
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should convert to a hash equal to the original" do
|
82
|
+
hash_including(@sample_response).should == @wrapped.to_hash
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe "API response to get_profile_goals" do
|
4
|
+
before do
|
5
|
+
@sample_response = {
|
6
|
+
"Available" => [
|
7
|
+
{
|
8
|
+
"Key" => "hard_goal",
|
9
|
+
"Description" => "Do something hard 10 times within a week and earn 200 points",
|
10
|
+
"Name" => "Hard Goal",
|
11
|
+
"Interval" => "Weekly",
|
12
|
+
"Progress" => [
|
13
|
+
{
|
14
|
+
"ConditionMetDate" => nil,
|
15
|
+
"CurrentValue" => 9,
|
16
|
+
"Description" => "Do something hard 10 times",
|
17
|
+
"RequiredValue" => 10
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
],
|
22
|
+
"Completed" => [
|
23
|
+
{
|
24
|
+
"Key" => "easy_goal",
|
25
|
+
"Description" => "Do something easy 5 times today and earn 100 points",
|
26
|
+
"Name" => "Easy Goal",
|
27
|
+
"Interval" => "Daily",
|
28
|
+
"Progress" => [
|
29
|
+
{
|
30
|
+
"ConditionMetDate" => "/Date(1275706032317-0600)/",
|
31
|
+
"CurrentValue" => 5,
|
32
|
+
"Description" => "Do something easy 5 times",
|
33
|
+
"RequiredValue" => "5"
|
34
|
+
}
|
35
|
+
],
|
36
|
+
"AwardDate" => "/Date(1275706032317-0600)/"
|
37
|
+
}
|
38
|
+
]
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should not raise error on wrapping in an object" do
|
43
|
+
lambda { IActionable::Objects::ProfileGoals.new(@sample_response) }.should_not raise_error
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "when wrapped in an object" do
|
47
|
+
before do
|
48
|
+
@wrapped = IActionable::Objects::ProfileGoals.new(Marshal.load(Marshal.dump(@sample_response)))
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should contain ar array of available goals" do
|
52
|
+
@wrapped.available.should be_instance_of Array
|
53
|
+
@wrapped.available.first.key.should == @sample_response["Available"][0]["Key"]
|
54
|
+
@wrapped.available.first.description.should == @sample_response["Available"][0]["Description"]
|
55
|
+
@wrapped.available.first.name.should == @sample_response["Available"][0]["Name"]
|
56
|
+
@wrapped.available.first.interval.should == @sample_response["Available"][0]["Interval"]
|
57
|
+
@wrapped.available.first.award_date.should be_nil
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should contain an array of progresses within each available goals" do
|
61
|
+
@wrapped.available.first.progress.should be_instance_of Array
|
62
|
+
@wrapped.available.first.progress.first.condition_met_date.should be_nil
|
63
|
+
@wrapped.available.first.progress.first.current_value.should == @sample_response["Available"][0]["Progress"][0]["CurrentValue"]
|
64
|
+
@wrapped.available.first.progress.first.description.should == @sample_response["Available"][0]["Progress"][0]["Description"]
|
65
|
+
@wrapped.available.first.progress.first.required_value.should == @sample_response["Available"][0]["Progress"][0]["RequiredValue"]
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should contain ar array of completed goals" do
|
69
|
+
@wrapped.completed.should be_instance_of Array
|
70
|
+
@wrapped.completed.first.key.should == @sample_response["Completed"][0]["Key"]
|
71
|
+
@wrapped.completed.first.description.should == @sample_response["Completed"][0]["Description"]
|
72
|
+
@wrapped.completed.first.name.should == @sample_response["Completed"][0]["Name"]
|
73
|
+
@wrapped.available.first.interval.should == @sample_response["Available"][0]["Interval"]
|
74
|
+
@wrapped.completed.first.award_date.should_not be_nil
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should contain an array of progresses within each completed goals" do
|
78
|
+
@wrapped.completed.first.progress.should be_instance_of Array
|
79
|
+
@wrapped.completed.first.progress.first.condition_met_date.should_not be_nil
|
80
|
+
@wrapped.completed.first.progress.first.current_value.should == @sample_response["Completed"][0]["Progress"][0]["CurrentValue"]
|
81
|
+
@wrapped.completed.first.progress.first.description.should == @sample_response["Completed"][0]["Progress"][0]["Description"]
|
82
|
+
@wrapped.completed.first.progress.first.required_value.should == @sample_response["Completed"][0]["Progress"][0]["RequiredValue"]
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should convert to a hash equal to the original" do
|
86
|
+
hash_including(@sample_response).should == @wrapped.to_hash
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe "API response to get_profile_notifications" do
|
4
|
+
before do
|
5
|
+
@sample_response = {
|
6
|
+
"Achievements" => {
|
7
|
+
"Available" => [ ],
|
8
|
+
"Completed" => [
|
9
|
+
{
|
10
|
+
"Description" => "Achieve the impossible",
|
11
|
+
"ImageURL" => "http://iactionable.blob.core.windows.net/achievementimages/99999",
|
12
|
+
"Key" => "mission_impossible",
|
13
|
+
"Name" => "Mission Impossible"
|
14
|
+
}
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"Challenges" => {
|
18
|
+
"Available" => [ ],
|
19
|
+
"Completed" => [
|
20
|
+
{
|
21
|
+
"Description" => "Do something extraordinary",
|
22
|
+
"Key" => "super_challenge",
|
23
|
+
"Name" => "Super Challenge"
|
24
|
+
}
|
25
|
+
]
|
26
|
+
},
|
27
|
+
"Goals" => {
|
28
|
+
"Available" => [ ],
|
29
|
+
"Completed" => [
|
30
|
+
{
|
31
|
+
"Description" => "Complete an awesome goal",
|
32
|
+
"Key" => "awesome_goal",
|
33
|
+
"Name" => "Awesome Goal"
|
34
|
+
}
|
35
|
+
]
|
36
|
+
},
|
37
|
+
"Levels" => [
|
38
|
+
{
|
39
|
+
"LevelType" => {
|
40
|
+
"Key" => "player_experience_points",
|
41
|
+
"Name" => "Player Experience Points"
|
42
|
+
},
|
43
|
+
"Name" => "Noobie",
|
44
|
+
"Number" => 2,
|
45
|
+
"RequiredPoints" => 10
|
46
|
+
}
|
47
|
+
],
|
48
|
+
"Points" => [
|
49
|
+
{
|
50
|
+
"PointType" => {
|
51
|
+
"Key" => "experience_points",
|
52
|
+
"Name" => "Experience Points"
|
53
|
+
},
|
54
|
+
"Points" => 20,
|
55
|
+
"Reason" => "Achieve the impossible"
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should not raise error on wrapping in an object" do
|
62
|
+
lambda { IActionable::Objects::ProfileNotifications.new(@sample_response) }.should_not raise_error
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "when wrapped in an object" do
|
66
|
+
before do
|
67
|
+
@wrapped = IActionable::Objects::ProfileNotifications.new(Marshal.load(Marshal.dump(@sample_response)))
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
it "should convert to a hash equal to the original" do
|
72
|
+
hash_including(@sample_response).should == @wrapped.to_hash
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe "API response to get_profile_points" do
|
4
|
+
before do
|
5
|
+
@sample_response = {
|
6
|
+
"Level" => {
|
7
|
+
"Current" =>
|
8
|
+
{
|
9
|
+
"Name" => "Beginner",
|
10
|
+
"Number" => 1,
|
11
|
+
"RequiredPoints" => 200,
|
12
|
+
"LevelType" =>
|
13
|
+
{
|
14
|
+
"Key" => "player_experience_level",
|
15
|
+
"Name" => "Experience Level"
|
16
|
+
},
|
17
|
+
},
|
18
|
+
"Next" =>
|
19
|
+
{
|
20
|
+
"Name" => "Member",
|
21
|
+
"Number" => 2,
|
22
|
+
"RequiredPoints" => 300,
|
23
|
+
"LevelType" =>
|
24
|
+
{
|
25
|
+
"Key" => "player_experience_level",
|
26
|
+
"Name" => "Experience Level"
|
27
|
+
},
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"PointType" => {
|
31
|
+
"Key" => "experience_points",
|
32
|
+
"Name" => "Experience Points"
|
33
|
+
},
|
34
|
+
"Points" => 200
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not raise error on wrapping in an object" do
|
39
|
+
lambda { IActionable::Objects::ProfilePoints.new(@sample_response) }.should_not raise_error
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "when wrapped in an object" do
|
43
|
+
before do
|
44
|
+
@wrapped = IActionable::Objects::ProfilePoints.new(Marshal.load(Marshal.dump(@sample_response)))
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should contain all the correct fields for a profile point summary" do
|
48
|
+
@wrapped.points.should == @sample_response["Points"]
|
49
|
+
@wrapped.point_type.key.should == @sample_response["PointType"]["Key"]
|
50
|
+
@wrapped.point_type.name.should == @sample_response["PointType"]["Name"]
|
51
|
+
@wrapped.level.current.name.should == @sample_response["Level"]["Current"]["Name"]
|
52
|
+
@wrapped.level.current.number.should == @sample_response["Level"]["Current"]["Number"]
|
53
|
+
@wrapped.level.current.required_points.should == @sample_response["Level"]["Current"]["RequiredPoints"]
|
54
|
+
@wrapped.level.current.level_type.key.should == @sample_response["Level"]["Current"]["LevelType"]["Key"]
|
55
|
+
@wrapped.level.current.level_type.name.should == @sample_response["Level"]["Current"]["LevelType"]["Name"]
|
56
|
+
@wrapped.level.next.name.should == @sample_response["Level"]["Next"]["Name"]
|
57
|
+
@wrapped.level.next.number.should == @sample_response["Level"]["Next"]["Number"]
|
58
|
+
@wrapped.level.next.required_points.should == @sample_response["Level"]["Next"]["RequiredPoints"]
|
59
|
+
@wrapped.level.next.level_type.key.should == @sample_response["Level"]["Next"]["LevelType"]["Key"]
|
60
|
+
@wrapped.level.next.level_type.name.should == @sample_response["Level"]["Next"]["LevelType"]["Name"]
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should convert to a hash equal to the original" do
|
64
|
+
hash_including(@sample_response).should == @wrapped.to_hash
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|