ten_thousand_feet 0.0.111 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89721edb3f29e30d80b2cc8dde6c71a4c9fb054b
4
- data.tar.gz: 5de31ab2ff2025979e85597b3ce0446ccbad5f44
3
+ metadata.gz: f1fdd5d2926c0b445200fe7f2da92a179d9fb48b
4
+ data.tar.gz: d159ede9918fe9e0e20069b981564d501fb68928
5
5
  SHA512:
6
- metadata.gz: 7f5885d453ec0725bcfe20081dbfd8ea490f1a790c8ae5116b12d87339f6527f7a656a10ac729f45c483e3fdebe040cc04c536bc537e9f57680fd1d11f07a47e
7
- data.tar.gz: 79a744f1491348a728438a4a4460a15a407b157194b0e88e34059fd17c58b3027d73b808f9848b3f692ecb91a157776a886d4add404d2195293ddcaf416c16d7
6
+ metadata.gz: 114ef833cccb39e9f1737034fd55edaadf0931661637f70fe0ae90f9cba83f09f18a867c64010ef1c30944b31d348910eaba00ef2d0bb4586082205676b73697
7
+ data.tar.gz: b12983dde0384d72b57f252714d77fba6fef508e903c3bc2bc299cba0ae8710a32071428b500efeb46a19210811d77e50f074372477e10de50d35ddb75b5da28
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ auth.yml
19
+ fixtures
data/README.md CHANGED
@@ -4,15 +4,84 @@ Ruby wrapper for the [10,000ft API (BETA)](http://10kft.github.io/api-documentat
4
4
 
5
5
  ## Installation
6
6
 
7
- gem install 'ten_thousand_feet'
7
+ gem 'ten_thousand_feet'
8
8
 
9
- ## Usage
9
+ Or
10
+
11
+ gem install ten_thousand_feet
12
+
13
+ ## Setup
10
14
 
11
15
  require 'ten_thousand_feet'
12
16
 
13
17
  # Initialize a new 10,000ft client
14
18
  client = TenThousandFeet.new(auth: YOUR_AUTH_TOKEN)
15
19
 
20
+ # API Methods
21
+ Note: 'options' will be different for each method. Check the official API documentation for a list of available options for each call.
22
+
23
+ 'options' should be passed in as a hash:
24
+
25
+ # user_id = 1969
26
+ #
27
+ # options = {
28
+ # first_name: 'Austin',
29
+ # last_name: 'Powers',
30
+ # display_name: 'Austin Danger Powers'
31
+ # }
32
+ #
33
+ # client.update_user(user_id, options)
34
+
35
+ ## Users
36
+
37
+ client.get_users(options)
38
+ client.show_user(user_id, options)
39
+ client.update_user(user_id, options)
40
+ client.create_user(options)
41
+
42
+ ## User Status
43
+
44
+ client.get_user_statuses(user_id, options)
45
+ client.create_user_status(user_id, options)
46
+
47
+ ## Assignments
48
+
49
+ client.get_assignments(user_id, options)
50
+ client.show_assignment(assignment_id, user_id, options)
51
+ client.create_assignment(project_id, user_id, options)
52
+ client.delete_assignment(assignment_id, user_id, options)
53
+
54
+ ## Projects
55
+
56
+ client.get_projects(options)
57
+ client.show_project(project_id, options)
58
+ client.update_project(project_id, options)
59
+ client.create_project(options)
60
+ client.delete_project(project_id, options)
61
+ client.get_project_time_entries(project_id, options)
62
+ client.get_project_users(project_id, options)
63
+
64
+ ## Phases
65
+
66
+ client.get_phases(project_id, options)
67
+ client.create_phases(project_id, options)
68
+ client.update_phases(project_id, phase_id, options)
69
+
70
+ ## Time Entries
71
+
72
+ client.get_time_entries(user_id, options)
73
+ client.show_time_entry(time_entry_id, user_id, options)
74
+ client.update_time_entry(time_entry_id, user_id, options)
75
+ client.create_time_entry(user_id, options)
76
+ client.delete_time_entry(time_entry_id, user_id, project_id, options)
77
+
78
+ ## To-Do
79
+
80
+ * Budget Items
81
+ * Budget Item Categories
82
+ * Tags Per Project
83
+ * Tags Per User
84
+
16
85
  ## Contributing
17
86
 
18
87
  1. Fork it
@@ -0,0 +1,23 @@
1
+ module TenThousandFeet
2
+ module API
3
+ module Assignments
4
+
5
+ def get_assignments(user_id, options={})
6
+ get("/users/#{user_id}/assignments", options)
7
+ end
8
+
9
+ def show_assignment(id, user_id, options={})
10
+ get("/users/#{user_id}/assignments/#{id}", options)
11
+ end
12
+
13
+ def create_assignment(project_id, user_id, options={})
14
+ post("/users/#{user_id}/assignments", options)
15
+ end
16
+
17
+ def delete_assignment(id, user_id, options={})
18
+ delete("/users/#{user_id}/assignments/#{id}", options)
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module TenThousandFeet
2
+ module API
3
+ module Phases
4
+
5
+ def get_phases(project_id, options={})
6
+ get("/projects/#{project_id}/phases", options)
7
+ end
8
+
9
+ def create_phase(project_id, options={})
10
+ post("/projects/#{project_id}/phases", options)
11
+ end
12
+
13
+ def update_phase(project_id, phase_id, options={})
14
+ put("/projects/#{project_id}/phases/#{phase_id}", options)
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ module TenThousandFeet
2
+ module API
3
+ module Projects
4
+
5
+ def get_projects(options={})
6
+ get("/projects", options)
7
+ end
8
+
9
+ def show_project(id, options={})
10
+ get("/projects/#{id}", options)
11
+ end
12
+
13
+ def create_project(options={})
14
+ post("/projects", options)
15
+ end
16
+
17
+ def update_project(id, options={})
18
+ put("/projects/#{id}", options)
19
+ end
20
+
21
+ def delete_project(id, options={})
22
+ delete("/projects/#{id}", options)
23
+ end
24
+
25
+ def get_project_time_entries(id, options={})
26
+ get("/projects/#{id}/time_entries", options)
27
+ end
28
+
29
+ def get_project_users(id, options={})
30
+ get("/projects/#{id}/users", options)
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ module TenThousandFeet
2
+ module API
3
+ module TimeEntries
4
+
5
+ def get_time_entries(user_id, options={})
6
+ get("/users/#{user_id}/time_entries", options)
7
+ end
8
+
9
+ def show_time_entry(id, user_id, options={})
10
+ get("/users/#{user_id}/time_entries/#{id}", options)
11
+ end
12
+
13
+ def create_time_entry(user_id, options={})
14
+ post("/users/#{user_id}/time_entries", options)
15
+ end
16
+
17
+ def update_time_entry(id, user_id, options={})
18
+ put("/users/#{user_id}/time_entries/#{id}", options)
19
+ end
20
+
21
+ def delete_time_entry(id, user_id, project_id, options={})
22
+ delete("projects/#{project_id}/users/#{user_id}/time_entries/#{id}", options)
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ module TenThousandFeet
2
+ module API
3
+ module UserStatus
4
+
5
+ def get_user_statuses(user_id, options={})
6
+ get("/users/#{user_id}/statuses", options)
7
+ end
8
+
9
+ def create_user_status(user_id, options={})
10
+ post("/users/#{user_id}/statuses", options)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -2,22 +2,20 @@ module TenThousandFeet
2
2
  module API
3
3
  module Users
4
4
 
5
- def get_users
6
- get("/users", { auth: self.auth })
5
+ def get_users(options={})
6
+ get("/users", options)
7
7
  end
8
8
 
9
- def show_user(id)
10
- get("/users/#{id}", { auth: self.auth })
9
+ def show_user(id, options={})
10
+ get("/users/#{id}", options)
11
11
  end
12
12
 
13
13
  def create_user(options={})
14
- default_options = { auth: self.auth }
15
- post("/users/", default_options.merge(options))
14
+ post("/users", options)
16
15
  end
17
16
 
18
17
  def update_user(id, options={})
19
- default_options = { auth: self.auth }
20
- put("/users/#{id}", default_options.merge(options))
18
+ put("/users/#{id}", options)
21
19
  end
22
20
 
23
21
  end
@@ -1,6 +1,12 @@
1
- require 'ten_thousand_feet/api/users'
2
- require 'rest-client'
3
1
  require 'json'
2
+ require 'rest-client'
3
+
4
+ require 'ten_thousand_feet/api/users'
5
+ require 'ten_thousand_feet/api/phases'
6
+ require 'ten_thousand_feet/api/projects'
7
+ require 'ten_thousand_feet/api/user_status'
8
+ require 'ten_thousand_feet/api/assignments'
9
+ require 'ten_thousand_feet/api/time_entries'
4
10
 
5
11
  module TenThousandFeet
6
12
  class Client
@@ -8,29 +14,67 @@ module TenThousandFeet
8
14
  attr_reader :auth
9
15
 
10
16
  include API::Users
17
+ include API::Phases
18
+ include API::Projects
19
+ include API::UserStatus
20
+ include API::Assignments
21
+ include API::TimeEntries
11
22
 
12
23
  def initialize(options={})
13
24
  @auth = options[:auth]
14
25
  end
15
26
 
16
27
  def api_url
17
- "https://vnext-api.10000ft.com/api/v1"
28
+ "https://pre-prod-api.10000ft.com/api/v1"
29
+ end
30
+
31
+ def default_options
32
+ { auth: @auth }
33
+ end
34
+
35
+ def query_string(options)
36
+ nodes = (options.count - 1)
37
+ params = "?"
38
+
39
+ options.each_with_index do |(key, value), index|
40
+ if index == nodes
41
+ params += key.to_s + "=" + value
42
+ else
43
+ params += key.to_s + "=" + value + "&"
44
+ end
45
+ end
46
+
47
+ params
48
+ end
49
+
50
+ def full_url(path, options)
51
+ if options.empty?
52
+ api_url + path
53
+ else
54
+ api_url + path + query_string(options)
55
+ end
18
56
  end
19
57
 
20
58
  def get(path, options = {})
21
- JSON.parse( RestClient.get(api_url + path, options) )
59
+ response = RestClient.get(full_url(path, options), default_options)
60
+
61
+ JSON.parse(response)
22
62
  end
23
63
 
24
64
  def post(path, options = {})
25
- JSON.parse( RestClient.post(api_url + path, options) )
65
+ response = RestClient.post(full_url(path, options), default_options)
66
+
67
+ JSON.parse(response)
26
68
  end
27
69
 
28
70
  def put(path, options = {})
29
- JSON.parse( RestClient.put(api_url + path, options) )
71
+ response = RestClient.put(full_url(path, options), default_options)
72
+
73
+ JSON.parse(response)
30
74
  end
31
75
 
32
76
  def delete(path, options = {})
33
- JSON.parse( RestClient.delete(api_url + path, options) )
77
+ RestClient.delete(full_url(path, options), default_options)
34
78
  end
35
79
  end
36
80
  end
@@ -1,3 +1,3 @@
1
1
  module TenThousandFeet
2
- VERSION = "0.0.111"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,15 @@
1
1
  require 'pry'
2
2
  require 'rest-client'
3
3
  require 'ten_thousand_feet/client'
4
- require 'ten_thousand_feet'
4
+ require 'ten_thousand_feet'
5
+ require 'yaml'
6
+ require 'vcr'
7
+ require 'webmock'
8
+
9
+ $AUTH = YAML.load_file('auth.yml')
10
+
11
+ VCR.configure do |c|
12
+ c.cassette_library_dir = 'fixtures/vcr_cassettes'
13
+ c.hook_into :webmock
14
+ c.allow_http_connections_when_no_cassette = true
15
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ module TenThousandFeet
4
+ module API
5
+ describe Assignments do
6
+
7
+ let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
+ let!(:user) { client.get_users['data'][0] }
9
+ let!(:projects) {
10
+ VCR.use_cassette('projects') do
11
+ client.get_projects
12
+ end
13
+ }
14
+ let!(:project) { projects['data'][0] }
15
+ let!(:assignments) {
16
+ VCR.use_cassette('assignments') do
17
+ client.get_assignments(user['id'])
18
+ end
19
+ }
20
+ let!(:assignment) { assignments['data'][0] }
21
+ let!(:id) { assignment['id'] }
22
+
23
+ describe '#get_assignments' do
24
+ it 'retrieves a list of assignments for a user' do
25
+ VCR.use_cassette('get_assignments') do
26
+ expect(assignments['data']).to_not be_nil
27
+ end
28
+ end
29
+ end
30
+
31
+ describe '#show_assignments' do
32
+ it 'retrieves details of a assignment' do
33
+ VCR.use_cassette('show_assignments') do
34
+ id = assignments['data'][0]['id']
35
+ assignment = client.show_assignment(id, user['id'])
36
+ expect(assignment['id']).to eq id
37
+ end
38
+ end
39
+ end
40
+
41
+ describe '#create_assignment' do
42
+ def assignment_attributes
43
+ {
44
+ project_id: project['id'],
45
+ starts_at: '2013-10-10',
46
+ ends_at: '2013-10-10'
47
+ }
48
+ end
49
+
50
+ it 'creates a new assignment' do
51
+ VCR.use_cassette('create_assignment') do
52
+ assignment_count_before = assignments['data'].count
53
+ response = client.create_assignment(project['id'], user['id'], assignment_attributes)
54
+
55
+ new_assignments = client.get_assignments(user['id'])
56
+ assignment_count_after = new_assignments['data'].count
57
+
58
+ expect(assignment_count_after).to eq (assignment_count_before + 1)
59
+ end
60
+ end
61
+ end
62
+
63
+ describe '#delete_assignment' do
64
+ context 'given a valid time entry' do
65
+ it 'deletes the assignment' do
66
+ VCR.use_cassette('delete_assignment') do
67
+ response = client.delete_assignment(id, user['id'])
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ module TenThousandFeet
4
+ module API
5
+ describe Phases do
6
+
7
+ let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
+ let!(:projects) {
9
+ VCR.use_cassette('projects') do
10
+ client.get_projects
11
+ end
12
+ }
13
+ let!(:project) { projects['data'][0] }
14
+ let!(:id) { project['id'] }
15
+
16
+ describe '#get_phases' do
17
+ it 'retrieves a list of phases for a given project' do
18
+ VCR.use_cassette('get_phases') do
19
+ phases = client.get_phases(id)
20
+ expect(phases['data']).to_not be_nil
21
+ end
22
+ end
23
+ end
24
+
25
+ describe '#create_phase' do
26
+ def phase_attributes
27
+ {
28
+ phase_name: 'Groovy baby',
29
+ starts_at: '2014-09-15',
30
+ ends_at: '2014-10-15'
31
+ }
32
+ end
33
+
34
+ it 'creates a new phase for a given project' do
35
+ VCR.use_cassette('create_phase') do
36
+ response = client.create_phase(id, phase_attributes)
37
+ phase = client.get_phases(id)
38
+ expect(phase['data'][0]['phase_name']).to eq phase_attributes[:phase_name]
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '#update_phase' do
44
+ def phase_attributes
45
+ {
46
+ phase_name: 'Groovy baby',
47
+ starts_at: '2014-09-15',
48
+ ends_at: '2014-10-15'
49
+ }
50
+ end
51
+
52
+ it 'updates a given phases attributes' do
53
+ phase = client.create_phase(id, phase_attributes)
54
+ phase_name = "#{rand(0..100)} So Groovy"
55
+ response = client.update_phase(id, phase['id'], { phase_name: phase_name })
56
+ expect(response['phase_name']).to eq phase_name
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ module TenThousandFeet
4
+ module API
5
+ describe Projects do
6
+
7
+ let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
+ let!(:projects) {
9
+ VCR.use_cassette('projects') do
10
+ client.get_projects
11
+ end
12
+ }
13
+ let!(:project) { projects['data'][0] }
14
+ let!(:id) { project['id'] }
15
+
16
+ describe '#get_projects' do
17
+ it 'retrieves a list of projects' do
18
+ VCR.use_cassette('get_projects') do
19
+ name = projects['data'][0]['name']
20
+ expect(name).to_not be_nil
21
+ end
22
+ end
23
+ end
24
+
25
+ describe '#show_projects' do
26
+ it 'retrieves details of a specific project' do
27
+ VCR.use_cassette('show_projects') do
28
+ id = projects['data'][0]['id']
29
+ project = client.show_project(id)
30
+ expect(project['id']).to eq id
31
+ end
32
+ end
33
+ end
34
+
35
+ describe '#create_projects' do
36
+ def project_attributes
37
+ {
38
+ name: '1 Billion Dollars',
39
+ client: 'Dr. Evil'
40
+ }
41
+ end
42
+
43
+ it 'creates a new project' do
44
+ VCR.use_cassette('create_project') do
45
+ project_count_before = projects['data'].count
46
+ response = client.create_project(project_attributes)
47
+
48
+ new_projects = client.get_projects
49
+ project_count_after = new_projects['data'].count
50
+
51
+ expect(project_count_after).to eq (project_count_before + 1)
52
+ end
53
+ end
54
+ end
55
+
56
+ describe '#update_project' do
57
+ context 'given a valid project' do
58
+ it 'updates an attribute for the project' do
59
+ name = "#{rand(0..100)} Billion Dollars"
60
+ response = client.update_project(id, { name: name })
61
+ expect(response['name']).to eq name
62
+ end
63
+ end
64
+ end
65
+
66
+ describe '#delete_project' do
67
+ context 'given a valid project' do
68
+ def project_attributes
69
+ {
70
+ name: '1 Billion Dollars',
71
+ client: 'Dr. Evil'
72
+ }
73
+ end
74
+
75
+ it 'deletes a project' do
76
+ VCR.use_cassette('delete_project') do
77
+ new_project = client.create_project(project_attributes)
78
+ response = client.delete_project(new_project['id'])
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#get_project_time_entries' do
85
+ it 'retrieves a list of time entries for a given project' do
86
+ VCR.use_cassette('get_project_time_entries') do
87
+ response = client.get_project_time_entries(id)
88
+ expect(response['data']).to_not be_nil
89
+ end
90
+ end
91
+ end
92
+
93
+ describe '#get_project_time_users' do
94
+ it 'retrieves a list of users for a given project' do
95
+ VCR.use_cassette('get_project_time_users') do
96
+ response = client.get_project_users(id)
97
+ expect(response['data']).to_not be_nil
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ module TenThousandFeet
4
+ module API
5
+ describe TimeEntries do
6
+
7
+ let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
+ let!(:user) { client.get_users['data'][0] }
9
+ let!(:projects) {
10
+ VCR.use_cassette('projects') do
11
+ client.get_projects
12
+ end
13
+ }
14
+ let!(:project) { projects['data'][0] }
15
+ let!(:time_entries) {
16
+ VCR.use_cassette('time_entries') do
17
+ client.get_time_entries(user['id'])
18
+ end
19
+ }
20
+ let!(:time_entry) { time_entries['data'][0] }
21
+ let!(:id) { time_entry['id'] }
22
+
23
+ describe '#get_time_entries' do
24
+ it 'retrieves a list of time entries for a user' do
25
+ VCR.use_cassette('get_time_entries') do
26
+ hours = time_entries['data'][0]['hours']
27
+ expect(hours).to_not be_nil
28
+ end
29
+ end
30
+ end
31
+
32
+ describe '#show_time_entries' do
33
+ it 'retrieves details of a specific time entry' do
34
+ VCR.use_cassette('show_time_entries') do
35
+ id = time_entries['data'][0]['id']
36
+ time_entry = client.show_time_entry(id, user['id'])
37
+ expect(time_entry['id']).to eq id
38
+ end
39
+ end
40
+ end
41
+
42
+ describe '#create_time_entry' do
43
+ #Required parameters: :date, :hours, :leave_type_id/:project_id/:assignable_id
44
+ def time_entry_attributes
45
+ {
46
+ hours: 10,
47
+ date: '2013-10-10',
48
+ project_id: project['id']
49
+ }
50
+ end
51
+
52
+ it 'creates a new project' do
53
+ VCR.use_cassette('create_time_entry') do
54
+ time_entry_count_before = time_entries['data'].count
55
+ response = client.create_time_entry(user['id'], time_entry_attributes)
56
+
57
+ new_time_entries = client.get_time_entries(user['id'])
58
+ time_entry_count_after = new_time_entries['data'].count
59
+
60
+ expect(time_entry_count_after).to eq (time_entry_count_before + 1)
61
+ end
62
+ end
63
+ end
64
+
65
+ describe '#update_time_entry' do
66
+ context 'given a valid time entry' do
67
+ it 'updates an attribute for the entry' do
68
+ hours = rand(0..100)
69
+ response = client.update_time_entry(id, user['id'], { hours: hours })
70
+ expect(response['hours']).to eq hours
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ module TenThousandFeet
4
+ module API
5
+ describe UserStatus do
6
+
7
+ let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
+ let!(:users) {
9
+ VCR.use_cassette('users') do
10
+ client.get_users
11
+ end
12
+ }
13
+ let!(:user) { users['data'][0] }
14
+ let!(:id) { user['id'] }
15
+
16
+ describe '#get_user_statuses' do
17
+ it 'retrieves a list of statuses for a given user' do
18
+ VCR.use_cassette('get_user_statuses') do
19
+ status = client.get_user_statuses(id)
20
+ expect(status['data']).to_not be_nil
21
+ end
22
+ end
23
+ end
24
+
25
+ describe '#create_user_status' do
26
+ def user_status_attributes
27
+ {
28
+ status: 'ITO'
29
+ }
30
+ end
31
+
32
+ it 'creates a new status for a given user' do
33
+ VCR.use_cassette('create_user_status') do
34
+ response = client.create_user_status(id, user_status_attributes)
35
+ status = client.get_user_statuses(id)
36
+ expect(status['data'][0]['status']).to eq 'ITO'
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -4,24 +4,31 @@ module TenThousandFeet
4
4
  module API
5
5
  describe Users do
6
6
 
7
- let!(:auth) { "Smg3M3czMiszU0djK0t3MytLV09OREFlWEdqa0JvRHFkRXdqcE9ueXFKRlVaK29heWpOYTY2RTM4eWJaCjdVc0pWbUhOUUc5ZEtMNkMyZURTMWJVeFNCdWpTMkhmUlpFTmtIMnBpd1Y0aSs5bk44RkZvMHZyMmg4MgpCaTdmdmhRcAo=" }
8
- let!(:client) { TenThousandFeet.new({ auth: auth }) }
9
- let!(:users) { client.get_users }
7
+ let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
+ let!(:users) {
9
+ VCR.use_cassette('users') do
10
+ client.get_users
11
+ end
12
+ }
10
13
  let!(:user) { users['data'][0] }
11
14
  let!(:id) { user['id'] }
12
15
 
13
16
  describe '#get_users' do
14
17
  it 'retrieves a list of users' do
15
- name = users['data'][0]['first_name']
16
- expect(name).to_not be_nil
18
+ VCR.use_cassette('get_users') do
19
+ name = users['data'][0]['first_name']
20
+ expect(name).to_not be_nil
21
+ end
17
22
  end
18
23
  end
19
24
 
20
25
  describe '#show_users' do
21
26
  it 'retrieves details of a specific user' do
22
- id = users['data'][0]['id']
23
- user = client.show_user(id)
24
- expect(user['id']).to eq id
27
+ VCR.use_cassette('show_users') do
28
+ id = users['data'][0]['id']
29
+ user = client.show_user(id)
30
+ expect(user['id']).to eq id
31
+ end
25
32
  end
26
33
  end
27
34
 
@@ -35,34 +42,25 @@ module TenThousandFeet
35
42
  end
36
43
 
37
44
  it 'creates a new user' do
38
- user_count_before = users['data'].count
39
- response = client.create_user(user_attributes)
45
+ VCR.use_cassette('create_user') do
46
+ user_count_before = users['data'].count
47
+ response = client.create_user(user_attributes)
40
48
 
41
- new_users = client.get_users
42
- user_count_after = new_users['data'].count
49
+ new_users = client.get_users
50
+ user_count_after = new_users['data'].count
43
51
 
44
- expect(user_count_after).to eq (user_count_before + 1)
52
+ expect(user_count_after).to eq (user_count_before + 1)
53
+ end
45
54
  end
46
55
  end
47
56
 
48
57
  describe '#update_user' do
49
58
  context 'given a valid user' do
50
-
51
- context 'given valid params' do
52
- it 'updates an attribute for the user' do
53
- name = "AustinPowers#{rand(0..100)}"
54
- response = client.update_user(id, { first_name: name })
55
- expect(response['first_name']).to eq name
56
- end
57
- end
58
-
59
- context 'given no params' do
60
- it 'returns the user unchanged' do
61
- response = client.update_user(id, {})
62
- expect(response['first_name']).to eq user['first_name']
63
- end
59
+ it 'updates an attribute for the user' do
60
+ name = "AustinPowers#{rand(0..100)}"
61
+ response = client.update_user(id, { first_name: name })
62
+ expect(response['first_name']).to eq name
64
63
  end
65
-
66
64
  end
67
65
  end
68
66
  end
@@ -2,13 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  module TenThousandFeet
4
4
  describe Client do
5
- let!(:auth) {
6
- "Smg3M3czMiszU0djK0t3MytLV09OREFlWEdqa0JvRHFkRXdqcE9ueXFKRlVaK29heWpOYTY2RTM4eWJaCjdVc0pWbUhOUUc5ZEtMNkMyZURTMWJVeFNCdWpTMkhmUlpFTmtIMnBpd1Y0aSs5bk44RkZvMHZyMmg4MgpCaTdmdmhRcAo="
7
- }
8
-
9
5
  it 'Sets the value of the auth token on the client' do
10
- client = TenThousandFeet.new({ auth: auth })
11
- expect(client.auth).to eq auth
6
+ client = TenThousandFeet.new({ auth: $AUTH })
7
+ expect(client.auth).to eq $AUTH
12
8
  end
13
9
  end
14
10
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["susskyle@gmail.com"]
11
11
  spec.description = %q{The 10,000ft Ruby API Client}
12
12
  spec.summary = %q{Provides Ruby wrappers for the 10,000ft API.}
13
- spec.homepage = "http://tackmobile.com"
13
+ spec.homepage = "https://github.com/TackMobile/ten_thousand_feet"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "rest-client"
22
- spec.add_dependency "hashie"
23
22
  spec.add_development_dependency "bundler", "~> 1.3"
24
23
  spec.add_development_dependency "rake"
25
24
  spec.add_development_dependency "rspec"
26
25
  spec.add_development_dependency "multi_json"
27
26
  spec.add_development_dependency "vcr"
28
27
  spec.add_development_dependency "pry"
28
+ spec.add_development_dependency "webmock", "1.8.0"
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ten_thousand_feet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.111
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Suss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-12 00:00:00.000000000 Z
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: hashie
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +108,20 @@ dependencies:
122
108
  - - '>='
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.8.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.8.0
125
125
  description: The 10,000ft Ruby API Client
126
126
  email:
127
127
  - susskyle@gmail.com
@@ -136,14 +136,24 @@ files:
136
136
  - README.md
137
137
  - Rakefile
138
138
  - lib/ten_thousand_feet.rb
139
+ - lib/ten_thousand_feet/api/assignments.rb
140
+ - lib/ten_thousand_feet/api/phases.rb
141
+ - lib/ten_thousand_feet/api/projects.rb
142
+ - lib/ten_thousand_feet/api/time_entries.rb
143
+ - lib/ten_thousand_feet/api/user_status.rb
139
144
  - lib/ten_thousand_feet/api/users.rb
140
145
  - lib/ten_thousand_feet/client.rb
141
146
  - lib/ten_thousand_feet/version.rb
142
147
  - spec/spec_helper.rb
148
+ - spec/ten_thousand_feet/api/assignment_spec.rb
149
+ - spec/ten_thousand_feet/api/phases_spec.rb
150
+ - spec/ten_thousand_feet/api/projects_spec.rb
151
+ - spec/ten_thousand_feet/api/time_entries_spec.rb
152
+ - spec/ten_thousand_feet/api/user_status_spec.rb
143
153
  - spec/ten_thousand_feet/api/users_spec.rb
144
154
  - spec/ten_thousand_feet/client_spec.rb
145
155
  - ten_thousand_feet.gemspec
146
- homepage: http://tackmobile.com
156
+ homepage: https://github.com/TackMobile/ten_thousand_feet
147
157
  licenses:
148
158
  - MIT
149
159
  metadata: {}
@@ -169,5 +179,10 @@ specification_version: 4
169
179
  summary: Provides Ruby wrappers for the 10,000ft API.
170
180
  test_files:
171
181
  - spec/spec_helper.rb
182
+ - spec/ten_thousand_feet/api/assignment_spec.rb
183
+ - spec/ten_thousand_feet/api/phases_spec.rb
184
+ - spec/ten_thousand_feet/api/projects_spec.rb
185
+ - spec/ten_thousand_feet/api/time_entries_spec.rb
186
+ - spec/ten_thousand_feet/api/user_status_spec.rb
172
187
  - spec/ten_thousand_feet/api/users_spec.rb
173
188
  - spec/ten_thousand_feet/client_spec.rb