taskmapper-bcx 0.0.1

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,18 @@
1
+ [
2
+ {
3
+ "id": 968316918,
4
+ "name": "Launch list",
5
+ "description": "What we need for launch",
6
+ "updated_at": "2012-03-22T16:56:52-05:00",
7
+ "url": "https://basecamp.com/999999999/api/v1/projects/605816632-bcx/todolists/968316918-launch-list.json",
8
+ "completed": false,
9
+ "position": 1,
10
+ "completed_count": 3,
11
+ "remaining_count": 5,
12
+ "creator": {
13
+ "id": 127326141,
14
+ "name": "David Heinemeier Hansson",
15
+ "avatar_url": "https://asset0.37img.com/global/9d2148cb8ed8e2e8ecbc625dd1cbe7691896c7d9/avatar.96.gif?r=3"
16
+ }
17
+ }
18
+ ]
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe TaskMapper::Provider::Bcx do
4
+ let(:tm) { create_instance }
5
+
6
+ describe "#new" do
7
+ it "creates a new TaskMapper instance" do
8
+ expect(tm).to be_a TaskMapper
9
+ end
10
+
11
+ it "can be explicitly called as a provider" do
12
+ tm = TaskMapper::Provider::Bcx.new(
13
+ :account_id => account_id,
14
+ :username => username,
15
+ :password => password
16
+ )
17
+ expect(tm).to be_a TaskMapper
18
+ end
19
+ end
20
+
21
+ describe "#valid?" do
22
+ context "with a correctly authenticated Basecamp user" do
23
+ it "returns true" do
24
+ expect(tm.valid?).to be_true
25
+ end
26
+ end
27
+
28
+ context "with an invalid Basecamp user" do
29
+ before do
30
+ base = "https://baduser:badpassword@basecamp.com/999999999/api/v1"
31
+ stub_get(base + "/people/me.json", 'invalid_user.txt', 404, 'text/html')
32
+ end
33
+
34
+ let(:tm) { create_instance "baduser", "badpassword" }
35
+
36
+ it "returns false" do
37
+ expect(tm.valid?).to be_false
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe TaskMapper::Provider::Bcx::Ticket do
4
+ let(:tm) { create_instance }
5
+ let(:comment_class) { TaskMapper::Provider::Bcx::Comment }
6
+ let(:project) { tm.project 605816632 }
7
+ let(:ticket) { project.ticket 1 }
8
+
9
+ describe "#comments" do
10
+ context "with no arguments" do
11
+ let(:comments) { ticket.comments }
12
+
13
+ it "returns an array containing all comments" do
14
+ expect(comments).to be_an Array
15
+ expect(comments.first).to be_a comment_class
16
+ end
17
+ end
18
+
19
+ context "with an array of comment IDs" do
20
+ let(:comments) { ticket.comments [1028592764] }
21
+
22
+ it "returns an array of the matching comments" do
23
+ expect(comments).to be_an Array
24
+ expect(comments.first).to be_a comment_class
25
+ expect(comments.first.id).to eq 1028592764
26
+ end
27
+ end
28
+
29
+ context "with a hash containing a comment ID" do
30
+ let(:comments) { ticket.comments :id => 1028592764 }
31
+
32
+ it "returns an array containing the matching comment" do
33
+ expect(comments).to be_an Array
34
+ expect(comments.first).to be_a comment_class
35
+ expect(comments.first.id).to eq 1028592764
36
+ end
37
+ end
38
+ end
39
+
40
+ describe "#comment" do
41
+ context "with a comment ID" do
42
+ let(:comment) { ticket.comment 1028592764 }
43
+
44
+ it "returns the requested comment do" do
45
+ expect(comment).to be_a comment_class
46
+ expect(comment.id).to eq 1028592764
47
+ end
48
+ end
49
+ end
50
+
51
+ describe "#comment!" do
52
+ context "with a new comment body" do
53
+ let(:comment) { ticket.comment! :body => "New Comment!" }
54
+
55
+ it "creates a new comment" do
56
+ expect(comment).to be_a comment_class
57
+ expect(comment.ticket_id).to eq 1
58
+ expect(comment.body).to eq "New Comment!"
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe TaskMapper::Provider::Bcx::Project do
4
+ let(:tm) { create_instance }
5
+ let(:project_class) { TaskMapper::Provider::Bcx::Project }
6
+
7
+ describe "#projects" do
8
+ context "without params" do
9
+ let(:projects) { tm.projects }
10
+
11
+ it "returns an array of all projects" do
12
+ expect(projects).to be_an Array
13
+ expect(projects.first).to be_a project_class
14
+ end
15
+ end
16
+
17
+ context "with an array of IDs" do
18
+ let(:projects) { tm.projects [605816632] }
19
+
20
+ it "returns an array of matching projects" do
21
+ expect(projects).to be_an Array
22
+ expect(projects.first).to be_a project_class
23
+ expect(projects.first.id).to eq 605816632
24
+ end
25
+ end
26
+
27
+ context "with a hash containing an ID" do
28
+ let(:projects) { tm.projects :id => 605816632 }
29
+
30
+ it "returns an array containing the matching project" do
31
+ expect(projects).to be_an Array
32
+ expect(projects.first).to be_a project_class
33
+ expect(projects.first.id).to eq 605816632
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "#project" do
39
+ context "with a project ID" do
40
+ let(:project) { tm.project 605816632 }
41
+
42
+ it "returns the requested project" do
43
+ expect(project).to be_a project_class
44
+ expect(project.id).to eq 605816632
45
+ end
46
+ end
47
+
48
+ context "with a hash containing a project ID" do
49
+ let(:project) { tm.project :id => 605816632 }
50
+
51
+ it "returns the requested project" do
52
+ expect(project).to be_a project_class
53
+ expect(project.id).to eq 605816632
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+
3
+ describe TaskMapper::Provider::Bcx::Project do
4
+ let(:tm) { create_instance }
5
+ let(:ticket_class) { TaskMapper::Provider::Bcx::Ticket }
6
+ let(:project) { tm.project 605816632 }
7
+
8
+ describe "#tickets" do
9
+ context "with no arguments" do
10
+ let(:tickets) { project.tickets }
11
+
12
+ it "returns an array of all tickets" do
13
+ expect(tickets).to be_an Array
14
+ expect(tickets.first).to be_a ticket_class
15
+ end
16
+ end
17
+
18
+ context "with an array of ticket IDs" do
19
+ let(:tickets) { project.tickets [1] }
20
+
21
+ it "returns an array containing the requested tickets" do
22
+ expect(tickets).to be_an Array
23
+ expect(tickets.first).to be_a ticket_class
24
+ expect(tickets.first.id).to eq 1
25
+ end
26
+ end
27
+
28
+ context "with a hash containing a ticket ID" do
29
+ let(:tickets) { project.tickets :id => 1 }
30
+
31
+ it "returns an array containing the requested ticket" do
32
+ expect(tickets).to be_an Array
33
+ expect(tickets.first).to be_a ticket_class
34
+ expect(tickets.first.id).to eq 1
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "#ticket" do
40
+ context "with a ticket ID" do
41
+ let(:ticket) { project.ticket 1 }
42
+
43
+ it "returns the requested ticket" do
44
+ expect(ticket).to be_a ticket_class
45
+ expect(ticket.id).to eq 1
46
+ end
47
+ end
48
+
49
+ describe "#close" do
50
+ let(:ticket) { project.tickets.first }
51
+
52
+ before do
53
+ expect(TaskMapper::Provider::Bcx::API).to receive(:put).with(
54
+ "/projects/605816632/todos/1.json",
55
+ hash_including(:body)
56
+ )
57
+ end
58
+
59
+ it "updates the status and saves the ticket" do
60
+ expect(ticket.status).to eq "open"
61
+ ticket.close
62
+ expect(ticket.status).to eq 'closed'
63
+ end
64
+ end
65
+
66
+ describe "#reopen" do
67
+ let(:ticket) { project.tickets.last }
68
+
69
+ before do
70
+ expect(TaskMapper::Provider::Bcx::API).to receive(:put).with(
71
+ "/projects/605816632/todos/3.json",
72
+ hash_including(:body)
73
+ )
74
+ end
75
+
76
+ it "updates the status and saves the ticket" do
77
+ expect(ticket.status).to eq "closed"
78
+ ticket.reopen
79
+ expect(ticket.status).to eq 'open'
80
+ end
81
+ end
82
+ end
83
+
84
+ describe "#ticket!" do
85
+ context "with new ticket params" do
86
+ let(:ticket) do
87
+ project.ticket!(
88
+ :description => "A New Ticket",
89
+ :todolist_id => 968316918
90
+ )
91
+ end
92
+
93
+ it "should create a new ticket" do
94
+ expect(ticket).to be_a ticket_class
95
+ expect(ticket.description).to eq "A New Ticket"
96
+ expect(ticket.todolist_id).to eq 968316918
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe TaskMapper::Provider::Bcx do
4
+ it "has a VERSION string" do
5
+ expect(TaskMapper::Provider::Bcx::VERSION).to be_a String
6
+ end
7
+ end
@@ -0,0 +1,61 @@
1
+ require 'taskmapper-bcx'
2
+ require 'rspec'
3
+ require 'fakeweb'
4
+
5
+ FakeWeb.allow_net_connect = false
6
+
7
+ def username
8
+ "username"
9
+ end
10
+
11
+ def password
12
+ "password"
13
+ end
14
+
15
+ def account_id
16
+ "999999999"
17
+ end
18
+
19
+ def create_instance(u = username, p = password, id = account_id)
20
+ TaskMapper.new(:bcx, :username => u, :password => p, :account_id => id)
21
+ end
22
+
23
+ def fixture_file(filename)
24
+ return '' if filename == ''
25
+ file_path = File.expand_path("#{File.dirname(__FILE__)}/fixtures/#{filename}")
26
+ File.read(file_path)
27
+ end
28
+
29
+ def stub_request(method, url, filename, status=nil, content_type="application/json")
30
+ options = {:body => ""}
31
+ options.merge!({:body => fixture_file(filename)}) if filename
32
+ options.merge!({:body => status.last}) if status.is_a?(Array)
33
+ options.merge!({:status => status}) if status
34
+ options.merge!({:content_type => content_type})
35
+
36
+ FakeWeb.register_uri method, url, options
37
+ end
38
+
39
+ def stub_get(*args); stub_request(:get, *args) end
40
+ def stub_post(*args); stub_request(:post, *args) end
41
+ def stub_put(*args); stub_request(:put, *args) end
42
+ def stub_delete(*args); stub_request(:delete, *args) end
43
+
44
+ def base_uri
45
+ "https://#{username}:#{password}@basecamp.com/999999999/api/v1"
46
+ end
47
+
48
+ RSpec.configure do |c|
49
+ c.before do
50
+ stub_get(base_uri + '/people/me.json', 'me.json')
51
+ stub_get(base_uri + '/projects.json', 'projects.json')
52
+ stub_get(base_uri + '/projects/605816632.json', 'project.json')
53
+ stub_get(base_uri + '/projects/605816632/todolists.json', 'todolists.json')
54
+ stub_get(base_uri + '/projects/605816632/todolists/968316918.json', 'todolist.json')
55
+ stub_get(base_uri + '/projects/605816632/todos/1.json', 'todo-1.json')
56
+ stub_get(base_uri + '/projects/605816632/todos/2.json', 'todo-2.json')
57
+ stub_get(base_uri + '/projects/605816632/todos/3.json', 'todo-3.json')
58
+ stub_post(base_uri + '/projects/605816632/todolists/968316918/todos.json', 'new_todo.json')
59
+ stub_post(base_uri + '/projects605816632/todos/1/comments.json', 'new_comment.json')
60
+ end
61
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path '../lib/provider/version', __FILE__
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "taskmapper-bcx"
6
+ spec.version = TaskMapper::Provider::Bcx::VERSION
7
+ spec.authors = ["www.hybridgroup.com"]
8
+ spec.email = ["info@hybridgroup.com"]
9
+ spec.description = %q{A TaskMapper provider for interfacing with Basecamp Next.}
10
+ spec.summary = %q{A TaskMapper provider for interfacing with Basecamp Next.}
11
+ spec.homepage = "http://ticketrb.com"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "httparty", "~> 0.11.0"
20
+ spec.add_dependency "taskmapper", "~> 1.0"
21
+ spec.add_dependency "json", "~> 1.8.0"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 2.14.1"
24
+ spec.add_development_dependency "fakeweb", "~> 1.3.0"
25
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: taskmapper-bcx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - www.hybridgroup.com
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.11.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.11.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: taskmapper
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 2.14.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 2.14.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: fakeweb
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.0
97
+ description: A TaskMapper provider for interfacing with Basecamp Next.
98
+ email:
99
+ - info@hybridgroup.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .travis.yml
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - lib/provider/api.rb
111
+ - lib/provider/api/auth.rb
112
+ - lib/provider/api/comments.rb
113
+ - lib/provider/api/projects.rb
114
+ - lib/provider/api/todos.rb
115
+ - lib/provider/bcx.rb
116
+ - lib/provider/comment.rb
117
+ - lib/provider/project.rb
118
+ - lib/provider/ticket.rb
119
+ - lib/provider/version.rb
120
+ - lib/taskmapper-bcx.rb
121
+ - spec/fixtures/.keep
122
+ - spec/fixtures/invalid_user.txt
123
+ - spec/fixtures/me.json
124
+ - spec/fixtures/new_comment.json
125
+ - spec/fixtures/new_todo.json
126
+ - spec/fixtures/project.json
127
+ - spec/fixtures/projects.json
128
+ - spec/fixtures/todo-1.json
129
+ - spec/fixtures/todo-2.json
130
+ - spec/fixtures/todo-3.json
131
+ - spec/fixtures/todolist.json
132
+ - spec/fixtures/todolists.json
133
+ - spec/lib/bcx_spec.rb
134
+ - spec/lib/comment_spec.rb
135
+ - spec/lib/project_spec.rb
136
+ - spec/lib/ticket_spec.rb
137
+ - spec/lib/version_spec.rb
138
+ - spec/spec_helper.rb
139
+ - taskmapper-bcx.gemspec
140
+ homepage: http://ticketrb.com
141
+ licenses:
142
+ - MIT
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.1.2
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: A TaskMapper provider for interfacing with Basecamp Next.
164
+ test_files:
165
+ - spec/fixtures/.keep
166
+ - spec/fixtures/invalid_user.txt
167
+ - spec/fixtures/me.json
168
+ - spec/fixtures/new_comment.json
169
+ - spec/fixtures/new_todo.json
170
+ - spec/fixtures/project.json
171
+ - spec/fixtures/projects.json
172
+ - spec/fixtures/todo-1.json
173
+ - spec/fixtures/todo-2.json
174
+ - spec/fixtures/todo-3.json
175
+ - spec/fixtures/todolist.json
176
+ - spec/fixtures/todolists.json
177
+ - spec/lib/bcx_spec.rb
178
+ - spec/lib/comment_spec.rb
179
+ - spec/lib/project_spec.rb
180
+ - spec/lib/ticket_spec.rb
181
+ - spec/lib/version_spec.rb
182
+ - spec/spec_helper.rb