todaysplan 0.1.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.
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe TodaysPlan::Athlete do
4
+
5
+ let(:response){File.read("spec/fixtures/athletes/response.json")}
6
+
7
+ it "expect to get all athletes" do
8
+ stub_request(:get, "#{TodaysPlan.endpoint}/users/delegates/users").
9
+ with(:headers => {'Accept'=>'application/json',
10
+ 'Authorization'=>'Bearer abc-123', }).
11
+ to_return(:status => 200, :body => response, :headers => {})
12
+ all = TodaysPlan::Athlete.all()
13
+ expect(all).to be_a(Array)
14
+ expect(all[0]).to be_a(TodaysPlan::Athlete)
15
+ expect(all[0].first_name).to_not be_nil
16
+ expect(all[0].last_name).to_not be_nil
17
+ expect(all[0].coach).to_not be_nil
18
+ expect(all[0].timezone).to_not be_nil
19
+ expect(all[0].id).to_not be_nil
20
+ expect(all[0].name).to_not be_nil
21
+ expect(all[0].email).to_not be_nil
22
+ end
23
+
24
+ it "expect to get one athlete" do
25
+ stub_request(:get, "#{TodaysPlan.endpoint}/users/delegates/users").
26
+ with(:headers => {'Accept'=>'application/json',
27
+ 'Authorization'=>'Bearer abc-123', }).
28
+ to_return(:status => 200, :body => response, :headers => {})
29
+ athlete = TodaysPlan::Athlete.find(7187033)
30
+ expect(athlete).to be_a(TodaysPlan::Athlete)
31
+ expect(athlete).to respond_to(:first_name)
32
+ expect(athlete).to respond_to(:last_name)
33
+ expect(athlete).to respond_to(:coach)
34
+ expect(athlete).to respond_to(:timezone)
35
+ expect(athlete).to respond_to(:id)
36
+ expect(athlete).to respond_to(:name)
37
+ expect(athlete).to respond_to(:email)
38
+ expect(athlete).to respond_to(:dob)
39
+ end
40
+
41
+
42
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe TodaysPlan::Client do
4
+
5
+ let(:username){TodaysPlan.username}
6
+ let(:password){TodaysPlan.password}
7
+ let(:client){TodaysPlan::Client.new(username, password)}
8
+
9
+
10
+ it "expect to authenticate" do
11
+ stub_request(:post, TodaysPlan.endpoint+'/auth/login').
12
+ with(:body => "{\"username\":\"#{username}\",\"password\":\"#{password}\",\"token\":true}",
13
+ :headers => {'Accept'=>'application/json',
14
+ 'Content-Type'=>'application/json',}).
15
+ to_return(:status => 200, :body => '{"token":"abc-123"}', :headers => {})
16
+ expect(client.token).to_not be_nil
17
+ end
18
+
19
+ it "expect to logout" do
20
+ stub_request(:get, TodaysPlan.endpoint+"/auth/logout").
21
+ with(:headers => {
22
+ 'Authorization'=>'Bearer abc-123', }).
23
+ to_return(:status => 200, :body => "true", :headers => {})
24
+ expect(client.token).to_not be_nil
25
+ expect(client.logout).to eq "true"
26
+ end
27
+
28
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe TodaysPlan::Connector do
4
+
5
+ let(:username){TodaysPlan.username}
6
+ let(:password){TodaysPlan.password}
7
+ let(:client){TodaysPlan::Client.new(username, password)}
8
+
9
+
10
+ it "expect create new connect without client" do
11
+ client = double
12
+ expect(TodaysPlan::Client).to receive(:new).with(username, password).and_return(client)
13
+ conn = TodaysPlan::Connector.new("/test")
14
+ expect(conn.client).to eq client
15
+ expect(conn.uri).to eq TodaysPlan.endpoint + "/test"
16
+ expect(conn.timeout).to eq TodaysPlan.timeout
17
+ end
18
+
19
+ it "expect to create new connect with client" do
20
+ client = double(token: 'abc-123')
21
+ expect(TodaysPlan::Client).to_not receive(:new)
22
+ TodaysPlan::Connector.new("/test", client)
23
+ end
24
+
25
+ it "expect rest-client get request" do
26
+ response = double(body: '{"message":"test"}')
27
+ client = double(token: 'abc-123')
28
+ expect(TodaysPlan::Client).to receive(:new).with(username, password).and_return(client)
29
+ expect(RestClient::Request).to receive(:execute).and_return(response)
30
+ expect(TodaysPlan::Connector.new("/test",).get()).to eq({"message"=>"test"})
31
+ end
32
+ it "expect rest-client post request" do
33
+ response = double(body: '{"message":"test"}')
34
+ client = double(token: 'abc-123')
35
+ expect(TodaysPlan::Client).to receive(:new).with(username, password).and_return(client)
36
+ expect(RestClient::Request).to receive(:execute).and_return(response)
37
+ expect(TodaysPlan::Connector.new("/test",).post()).to eq({"message"=>"test"})
38
+ end
39
+
40
+
41
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe TodaysPlan do
4
+
5
+
6
+ it "should pass the class back to the given block" do
7
+ TodaysPlan.configure do |plaid_rails|
8
+ expect(TodaysPlan).to eq plaid_rails
9
+ end
10
+ end
11
+
12
+ it "expect default endpoint" do
13
+ expect(TodaysPlan.endpoint).to eq 'https://whats.todaysplan.com.au/rest'
14
+ end
15
+
16
+ it "expect default timeout" do
17
+ expect(TodaysPlan.timeout).to eq 120
18
+ end
19
+
20
+ it "expect default logger" do
21
+ expect(TodaysPlan.logger).to be_nil
22
+ end
23
+
24
+ it "expect default debug" do
25
+ expect(TodaysPlan.debug).to be false
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: todaysplan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Curt Wilhelm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: shoulda-matchers
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A Ruby Library for TodaysPlan
84
+ email:
85
+ - curt@9ksoftware.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - lib/todays_plan.rb
94
+ - lib/todays_plan/activity.rb
95
+ - lib/todays_plan/athlete.rb
96
+ - lib/todays_plan/client.rb
97
+ - lib/todays_plan/connector.rb
98
+ - lib/todays_plan/version.rb
99
+ - spec/fixtures/activities/incomplete.json
100
+ - spec/fixtures/activities/incomplete_response.json
101
+ - spec/fixtures/athletes/response.json
102
+ - spec/spec_helper.rb
103
+ - spec/todays_plan/activity_spec.rb
104
+ - spec/todays_plan/athlete_spec.rb
105
+ - spec/todays_plan/client_spec.rb
106
+ - spec/todays_plan/connector_spec.rb
107
+ - spec/todays_plan_spec.rb
108
+ homepage: https://github.com/9ksoftware/todaysplan-ruby
109
+ licenses:
110
+ - GPL
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.5.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: A Ruby Library for TodaysPlan
132
+ test_files:
133
+ - spec/fixtures/activities/incomplete.json
134
+ - spec/fixtures/activities/incomplete_response.json
135
+ - spec/fixtures/athletes/response.json
136
+ - spec/spec_helper.rb
137
+ - spec/todays_plan/activity_spec.rb
138
+ - spec/todays_plan/athlete_spec.rb
139
+ - spec/todays_plan/client_spec.rb
140
+ - spec/todays_plan/connector_spec.rb
141
+ - spec/todays_plan_spec.rb