turingstudio-basecamp-rb 0.0.1 → 0.0.2

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.
Files changed (37) hide show
  1. data/Rakefile +21 -0
  2. data/lib/basecamp/attachment.rb +23 -23
  3. data/lib/basecamp/attachment_category.rb +10 -0
  4. data/lib/basecamp/base.rb +5 -109
  5. data/lib/basecamp/company.rb +10 -0
  6. data/lib/basecamp/message.rb +24 -22
  7. data/lib/basecamp/milestone.rb +50 -0
  8. data/lib/basecamp/person.rb +18 -0
  9. data/lib/basecamp/post_category.rb +10 -0
  10. data/lib/basecamp/project.rb +22 -0
  11. data/lib/basecamp/record.rb +42 -13
  12. data/lib/basecamp/resource.rb +9 -9
  13. data/lib/basecamp/time_entry.rb +11 -9
  14. data/lib/basecamp/todoitem.rb +6 -6
  15. data/lib/basecamp/todolist.rb +16 -14
  16. data/lib/basecamp/version.rb +1 -1
  17. data/lib/basecamp.rb +7 -1
  18. data/spec/lib/basecamp/attachment_category_spec.rb +12 -0
  19. data/spec/lib/basecamp/attachment_spec.rb +26 -0
  20. data/spec/lib/basecamp/base_spec.rb +44 -0
  21. data/spec/lib/basecamp/company_spec.rb +13 -0
  22. data/spec/lib/basecamp/message_spec.rb +45 -0
  23. data/spec/lib/basecamp/milestone_spec.rb +44 -0
  24. data/spec/lib/basecamp/person_spec.rb +18 -0
  25. data/spec/lib/basecamp/post_category_spec.rb +13 -0
  26. data/spec/lib/basecamp/project_spec.rb +12 -0
  27. data/spec/lib/basecamp/record_spec.rb +57 -0
  28. data/spec/lib/basecamp/time_entry_spec.rb +23 -0
  29. data/spec/lib/basecamp/todo_item_spec.rb +38 -0
  30. data/spec/lib/basecamp/todo_list_spec.rb +36 -0
  31. data/spec/spec_helper.rb +68 -1
  32. metadata +44 -18
  33. data/spec/basecamp_spec.rb +0 -61
  34. data/spec/lib/basecamp_base.rb +0 -75
  35. data/spec/lib/basecamp_message_spec.rb +0 -42
  36. data/spec/lib/basecamp_todo_item_spec.rb +0 -40
  37. data/spec/lib/basecamp_todo_list_spec.rb +0 -32
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::Attachment do
4
+ before(:each) do
5
+ establish_connection
6
+ end
7
+
8
+ it "should create attachments for comment" do
9
+ a1 = Basecamp::Attachment.create('test1', File.read(File.dirname(__FILE__) + '/../fixtures/attachment1'))
10
+ a2 = Basecamp::Attachment.create('test2', File.read(File.dirname(__FILE__) + '/../fixtures/attachment2'))
11
+
12
+ comment = Basecamp::Comment.new(:post_id => TEST_MESSAGE_ID)
13
+ comment.body = "test comment with attachment"
14
+ comment.attachments = [a1, a2]
15
+ comment.save
16
+ comment_id = comment.id
17
+
18
+ comment = Basecamp::Comment.find(comment_id)
19
+
20
+ a1.should_not be_blank
21
+ a1.should_not be_blank
22
+ comment.attachments_count.should == 2
23
+
24
+ Basecamp::Comment.delete(comment_id)
25
+ end
26
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::Base do
4
+ before(:each) do
5
+ establish_connection
6
+ end
7
+
8
+ describe "Creating a resource" do
9
+ it "should create a comment for post" do
10
+ comment = Basecamp::Comment.new(:post_id => TEST_MESSAGE_ID)
11
+ comment.body = "test comment"
12
+ comment.save
13
+
14
+ c = Basecamp::Comment.find(comment.id)
15
+ c.body.should == "test comment"
16
+ c.id.should == comment.id.to_i
17
+ end
18
+ end
19
+
20
+ describe "Finding a resource" do
21
+ it "should find message" do
22
+ message = Basecamp::Message.find(TEST_MESSAGE_ID)
23
+ message.body.should_not be_blank
24
+ message.category_id.should_not be_blank
25
+ end
26
+ end
27
+
28
+ describe "Updating a Resource" do
29
+ it "should update message" do
30
+ m = Basecamp::Message.find(TEST_MESSAGE_ID)
31
+ m.body = 'Changed'
32
+ m.save
33
+ message = Basecamp::Message.find(TEST_MESSAGE_ID)
34
+ message.body.should == 'Changed'
35
+ end
36
+ end
37
+
38
+ describe "Deleting a Resource" do
39
+ it "should delete todo item" do
40
+ todo = Basecamp::TodoItem.create(:todo_list_id => TEST_TODO_LIST_ID, :content => 'Todo for destroy')
41
+ Basecamp::TodoItem.delete(todo.id)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::Company do
4
+ before(:each) do
5
+ establish_connection
6
+ end
7
+
8
+ it "should return information for the company with the given id" do
9
+ company = Basecamp::Company.find(TEST_COMPANY_ID)
10
+ company.should_not be_blank
11
+ company.name.should_not be_blank
12
+ end
13
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::Message do
4
+ before(:each) do
5
+ establish_connection
6
+ end
7
+
8
+ it "should return the most recent 25 messages in the given project" do
9
+ messages = Basecamp::Message.list(TEST_PROJECT_ID)
10
+ messages.should_not be_blank
11
+ messages.should be_kind_of(Array)
12
+ messages.size.should_not > 25
13
+ end
14
+
15
+ it "should get a list of messages for given project and specified category" do
16
+ category_id = Basecamp::Message.find(TEST_MESSAGE_ID).category_id
17
+ messages = Basecamp::Message.list(TEST_PROJECT_ID, :category_id => category_id)
18
+ messages.should_not be_blank
19
+ messages.should be_kind_of(Array)
20
+ messages.each{ |m| m.category_id.should == category_id }
21
+ end
22
+
23
+ it "should return a summary of all messages in the given project" do
24
+ messages = Basecamp::Message.archive(TEST_PROJECT_ID)
25
+ messages.should_not be_blank
26
+ messages.should be_kind_of(Array)
27
+ end
28
+
29
+ it "should return a summary of all messages in the given project and specified category " do
30
+ category_id = Basecamp::Message.find(TEST_MESSAGE_ID).category_id
31
+ messages = Basecamp::Message.archive(TEST_PROJECT_ID, :category_id => category_id)
32
+ messages.should_not be_blank
33
+ messages.should be_kind_of(Array)
34
+ end
35
+
36
+ it "should return list of message comments" do
37
+ create_comments_for_message(TEST_MESSAGE_ID)
38
+
39
+ message = Basecamp::Message.find(TEST_MESSAGE_ID)
40
+ message.comments.should_not be_blank
41
+ message.comments.should be_kind_of(Array)
42
+
43
+ delete_comments_for_message(TEST_MESSAGE_ID)
44
+ end
45
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::Milestone do
4
+ before(:all) do
5
+ establish_connection
6
+ @milestones = [create_milestone_for_project(TEST_PROJECT_ID)]
7
+ end
8
+
9
+ after(:all) do
10
+ @milestones.each {|m| m.destroy }
11
+ end
12
+
13
+ it "should return a list of all milestones for the given project" do
14
+ milestones = Basecamp::Milestone.list(TEST_PROJECT_ID)
15
+ milestones.should be_kind_of(Array)
16
+ milestones.should_not be_blank
17
+ end
18
+
19
+ it "should create a new milestone for given project" do
20
+ milestones = Basecamp::Milestone.create(TEST_PROJECT_ID,
21
+ :title => 'new',
22
+ :responsible_party => TEST_PERSON_ID,
23
+ :deadline => Time.now,
24
+ :notify => false
25
+ )
26
+
27
+ milestones.should_not be_blank
28
+ @milestones << milestones
29
+ end
30
+
31
+ it "should complete milestone" do
32
+ milestone = Basecamp::Milestone.list(TEST_PROJECT_ID).first
33
+ milestone.complete!.completed.should be_true
34
+ end
35
+
36
+ it "should uncomplete milestone" do
37
+ milestone = Basecamp::Milestone.list(TEST_PROJECT_ID).first
38
+ milestone.uncomplete!.completed.should be_false
39
+ end
40
+
41
+ it "should destroy all milestones" do
42
+ lambda { create_milestone_for_project(TEST_PROJECT_ID).destroy }.should_not raise_error
43
+ end
44
+ end
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::Person do
4
+ before(:each) do
5
+ establish_connection
6
+ end
7
+
8
+ it "should find person with the given id" do
9
+ person = Basecamp::Person.find(TEST_PERSON_ID)
10
+ person.should_not be_blank
11
+ end
12
+
13
+ it "should return an array of the people in the given company" do
14
+ people = Basecamp::Person.list((TEST_COMPANY_ID))
15
+ people.should_not be_blank
16
+ people.should be_kind_of(Array)
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::PostCategory do
4
+ before(:each) do
5
+ establish_connection
6
+ end
7
+
8
+ it "should return the list of message categories for the given project" do
9
+ categories = Basecamp::PostCategory.list(TEST_PROJECT_ID)
10
+ categories.should_not be_blank
11
+ categories.should be_kind_of(Array)
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::Project do
4
+ before(:each) do
5
+ establish_connection
6
+ end
7
+
8
+ it "should return the list of all accessible projects" do
9
+ Basecamp::Project.list.should_not be_blank
10
+ Basecamp::Project.list.should be_a_kind_of(Array)
11
+ end
12
+ end
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::Record do
4
+ before(:each) do
5
+ # @base = mock('Base')
6
+ # Basecamp::Base.stub!(:new).and_return(@base)
7
+ end
8
+
9
+ describe "init from xml" do
10
+ before(:each) do
11
+ xml_data = '<?xml version="1.0" encoding="UTF-8"?>
12
+ <projects type="array">
13
+ <project>
14
+ <announcement nil="true"></announcement>
15
+ <created-on type="date">2009-02-02</created-on>
16
+ <id type="integer">2864720</id>
17
+ <last-changed-on type="datetime">2009-02-13T09:58:41Z</last-changed-on>
18
+ <name>ProductMadness - Development</name>
19
+ <show-announcement type="boolean">false</show-announcement>
20
+ <show-writeboards type="boolean">true</show-writeboards>
21
+ <start-page>log</start-page>
22
+ <status>active</status>
23
+ <company>
24
+ <id type="integer">1255848</id>
25
+ <name>Product Madness</name>
26
+ </company>
27
+ </project>
28
+ </projects>'
29
+
30
+ @response = mock('Response', :body => xml_data, :code => 200)
31
+ @connection = mock('Connection', :post => @response)
32
+ Basecamp::Base.stub!(:connection).and_return(@connection)
33
+ @projects = Basecamp::Project.list
34
+ @project = @projects.first
35
+ end
36
+
37
+ it "should initialize correct object from xml" do
38
+ @projects.should be_a(Array)
39
+ end
40
+
41
+ it "should return array of projects" do
42
+ @project.should be_a(Basecamp::Project)
43
+ end
44
+
45
+ it "should provide accessors for all attributes" do
46
+ @project.announcement.should == nil
47
+ @project.created_on.should == Date.parse('2009-02-02')
48
+ @project.id.should == 2864720
49
+ @project.last_changed_on.should == Time.parse('2009-02-13T09:58:41Z')
50
+ @project.name.should == 'ProductMadness - Development'
51
+ @project.show_announcement.should == false
52
+ @project.show_writeboards.should == true
53
+ @project.start_page.should == 'log'
54
+ @project.status.should == 'active'
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::TimeEntry do
4
+ before(:all) do
5
+ establish_connection
6
+ end
7
+
8
+ it "should return all time entries" do
9
+ entries = Basecamp::TimeEntry.report
10
+ entries.should be_kind_of(Array)
11
+ end
12
+
13
+ it "should return all time entries for a specified project" do
14
+ entries = Basecamp::TimeEntry.all(TEST_PROJECT_ID)
15
+ entries.should be_kind_of(Array)
16
+ end
17
+
18
+ # it "should return parent todo item" do
19
+ # entry = Basecamp::TimeEntry.find()
20
+ # entry.todo_item.should_not be_blank
21
+ # entry.todo_item.class.to_s.should == 'Basecamp::TodoItem'
22
+ # end
23
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::TodoItem do
4
+ before(:all) do
5
+ establish_connection
6
+ @todo = create_todo_list_for_project_with_todo(TEST_PROJECT_ID)
7
+ end
8
+
9
+ after(:all) do
10
+ Basecamp::TodoList.delete(@todo.todo_list_id)
11
+ end
12
+
13
+ it "should have todo list" do
14
+ @todo.todo_list.should_not be_blank
15
+ end
16
+
17
+ it "should return list of comments" do
18
+ @todo.comments.should_not be_blank
19
+ @todo.comments.should be_kind_of(Array)
20
+ end
21
+
22
+ # it "should return array of time entries" do
23
+ # todo.time_entries.should_not be_blank
24
+ # todo.time_entries.should be_kind_of(Array)
25
+ # end
26
+
27
+ it "should complete todo item" do
28
+ @todo.complete!
29
+ todo = Basecamp::TodoItem.find(@todo.id)
30
+ todo.completed.should == true
31
+ end
32
+
33
+ it "should uncomplete todo item" do
34
+ @todo.uncomplete!
35
+ todo = Basecamp::TodoItem.find(@todo.id)
36
+ todo.completed.should == false
37
+ end
38
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe Basecamp::TodoList do
4
+ before(:all) do
5
+ establish_connection
6
+ @todo = create_todo_list_for_project_with_todo(TEST_PROJECT_ID)
7
+ @list = @todo.todo_list
8
+ end
9
+
10
+ after(:all) do
11
+ Basecamp::TodoList.delete(@list.id)
12
+ end
13
+
14
+ it "should return todo items" do
15
+ @list.todo_items.should_not be_blank
16
+ @list.todo_items.should be_kind_of(Array)
17
+ end
18
+
19
+ it "should return all lists for a specified project" do
20
+ lists = Basecamp::TodoList.all(TEST_PROJECT_ID)
21
+ lists.should_not be_blank
22
+ lists.should be_kind_of(Array)
23
+ end
24
+
25
+ it "should return all finished lists for a specified project" do
26
+ lists = Basecamp::TodoList.all(TEST_PROJECT_ID, true)
27
+ lists.should be_kind_of(Array)
28
+ lists.each { |item| item.complete.should == "true" }
29
+ end
30
+
31
+ it "should return all pending lists for a specified project" do
32
+ lists = Basecamp::TodoList.all(TEST_PROJECT_ID, false)
33
+ lists.should be_kind_of(Array)
34
+ lists.each { |item| item.complete.should == "false" }
35
+ end
36
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,4 +4,71 @@ rescue LoadError
4
4
  require 'rubygems'
5
5
  gem 'rspec'
6
6
  require 'spec'
7
- end
7
+ end
8
+
9
+ require File.dirname(__FILE__) + '/../lib/basecamp'
10
+
11
+ SITE_URL = 'flatsoft.grouphub.com'
12
+ LOGIN = 'alexey.panin'
13
+ PASSWORD = '5721955'
14
+ USE_SSL = true
15
+
16
+ TEST_PROJECT_ID = 2971868
17
+ TEST_MESSAGE_ID = 20216236 # TEST_MESSAGE SHOULD BELONG TO TEST PROJECT!!!
18
+ TEST_COMPANY_ID = 1040098
19
+ TEST_PERSON_ID = 2766635
20
+ TEST_TODO_LIST_ID = 5576947
21
+
22
+ def establish_connection
23
+ Basecamp::Base.establish_connection!(SITE_URL, LOGIN, PASSWORD, USE_SSL)
24
+ end
25
+
26
+ def create_comments_for_message(id)
27
+ comment = Basecamp::Comment.new(:post_id => id)
28
+ comment.body = "test comment"
29
+ comment.save
30
+ end
31
+
32
+ def delete_comments_for_message(id)
33
+ message = Basecamp::Message.find(id)
34
+ message.comments.each {|c| Basecamp::Comment.delete(c.id)}
35
+ end
36
+
37
+ def delete_time_entries_for_project(id)
38
+ entry = Basecamp::Project.find(id)
39
+ message.comments.each {|c| Basecamp::Comment.delete(c.id)}
40
+ end
41
+
42
+ def create_todo_list_for_project_with_todo(id)
43
+ todo_list = Basecamp::TodoList.create(
44
+ :project_id => id,
45
+ :tracked => true,
46
+ :description => 'private',
47
+ :private => false
48
+ )
49
+ todo = Basecamp::TodoItem.create(
50
+ :todo_list_id => todo_list.id,
51
+ :content => 'Do it'
52
+ )
53
+ comment = Basecamp::Comment.new(:todo_item_id => todo.id)
54
+ comment.body = "test comment"
55
+ comment.save
56
+
57
+ todo.todo_list_id = todo_list.id
58
+ todo
59
+ end
60
+
61
+ def create_pending_and_finished_lists(id)
62
+ list1 = Basecamp::TodoList.create(:project_id => id, :tracked => true, :description => 'private1', :private => false)
63
+ list2 = Basecamp::TodoList.create(:project_id => id, :tracked => true, :description => 'private2', :private => false)
64
+ [ list1.id, list2.id ]
65
+ end
66
+
67
+ def create_milestone_for_project(id)
68
+ Basecamp::Milestone.create(TEST_PROJECT_ID,
69
+ :title => 'new',
70
+ :responsible_party => TEST_PERSON_ID,
71
+ :deadline => Time.now,
72
+ :notify => false
73
+ )
74
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turingstudio-basecamp-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Turing Studio, Inc.
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-25 00:00:00 -08:00
12
+ date: 2009-03-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.0.11
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: activesupport
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.2.2
34
+ version:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: activeresource
27
37
  type: :runtime
@@ -32,43 +42,59 @@ dependencies:
32
42
  - !ruby/object:Gem::Version
33
43
  version: 2.2.2
34
44
  version:
35
- description: FIX (describe your package)
45
+ description: A Ruby gem for working with the Basecamp web-services API.
36
46
  email:
37
- - operations@turingstudio.com
47
+ - support@turingstudio.com
38
48
  executables: []
39
49
 
40
50
  extensions: []
41
51
 
42
- extra_rdoc_files:
43
- - README.rdoc
52
+ extra_rdoc_files: []
53
+
44
54
  files:
45
55
  - History.txt
46
56
  - README.rdoc
57
+ - Rakefile
47
58
  - lib/basecamp.rb
48
- - lib/basecamp/base.rb
49
- - lib/basecamp/version.rb
50
- - lib/basecamp/resource.rb
51
59
  - lib/basecamp/attachment.rb
60
+ - lib/basecamp/attachment_category.rb
61
+ - lib/basecamp/base.rb
52
62
  - lib/basecamp/comment.rb
63
+ - lib/basecamp/company.rb
53
64
  - lib/basecamp/connection.rb
54
65
  - lib/basecamp/message.rb
66
+ - lib/basecamp/milestone.rb
67
+ - lib/basecamp/person.rb
68
+ - lib/basecamp/post_category.rb
69
+ - lib/basecamp/project.rb
55
70
  - lib/basecamp/record.rb
71
+ - lib/basecamp/resource.rb
56
72
  - lib/basecamp/time_entry.rb
57
73
  - lib/basecamp/todoitem.rb
58
74
  - lib/basecamp/todolist.rb
59
- - spec/basecamp_spec.rb
75
+ - lib/basecamp/version.rb
60
76
  - spec/spec.opts
61
77
  - spec/spec_helper.rb
62
- - spec/lib/basecamp_base.rb
63
- - spec/lib/basecamp_message_spec.rb
64
- - spec/lib/basecamp_todo_item_spec.rb
65
- - spec/lib/basecamp_todo_list_spec.rb
78
+ - spec/lib/basecamp/attachment_category_spec.rb
79
+ - spec/lib/basecamp/attachment_spec.rb
80
+ - spec/lib/basecamp/base_spec.rb
81
+ - spec/lib/basecamp/company_spec.rb
82
+ - spec/lib/basecamp/message_spec.rb
83
+ - spec/lib/basecamp/milestone_spec.rb
84
+ - spec/lib/basecamp/person_spec.rb
85
+ - spec/lib/basecamp/post_category_spec.rb
86
+ - spec/lib/basecamp/project_spec.rb
87
+ - spec/lib/basecamp/record_spec.rb
88
+ - spec/lib/basecamp/time_entry_spec.rb
89
+ - spec/lib/basecamp/todo_item_spec.rb
90
+ - spec/lib/basecamp/todo_list_spec.rb
66
91
  - tasks/rspec.rake
67
92
  has_rdoc: true
68
93
  homepage: http://github.com/turingstudio/basecamp-rb/
69
94
  post_install_message:
70
- rdoc_options: []
71
-
95
+ rdoc_options:
96
+ - --main
97
+ - README.rdoc
72
98
  require_paths:
73
99
  - lib
74
100
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -85,10 +111,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
111
  version:
86
112
  requirements: []
87
113
 
88
- rubyforge_project:
114
+ rubyforge_project: basecamp-rb
89
115
  rubygems_version: 1.2.0
90
116
  signing_key:
91
117
  specification_version: 2
92
- summary: FIX (describe your package)
118
+ summary: A Ruby gem for working with the Basecamp web-services API.
93
119
  test_files: []
94
120
 
@@ -1,61 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
- require File.dirname(__FILE__) + '/../lib/basecamp.rb'
3
-
4
- describe Basecamp do
5
-
6
- before(:each) do
7
- Basecamp::Base.establish_connection!('flatsoft-test.grouphub.com', 'flatsoft', '123456')
8
- @basecamp = Basecamp::Base.new
9
- end
10
-
11
- describe "Creating a resource" do
12
- it "should create a comment for post" do
13
- comment = Basecamp::Comment.new(:post_id => 15797423)
14
- comment.body = "test comment"
15
- comment.save
16
- c = Basecamp::Comment.find(comment.id)
17
- c.body.should == "test comment"
18
- c.id.should == comment.id.to_i
19
- end
20
- end
21
-
22
- describe "Finding a resource" do
23
- it "should find message" do
24
- message = Basecamp::Message.find(15797423)
25
- message.body.should_not be_blank
26
- message.category_id.should_not be_blank
27
- end
28
- end
29
-
30
- describe "Updating a Resource" do
31
- it "should update message" do
32
- m = Basecamp::Message.find(15797423)
33
- m.body = 'Changed'
34
- m.save
35
- message = Basecamp::Message.find(15797423)
36
- message.body.should == 'Changed'
37
- end
38
- end
39
-
40
- describe "Deleting a Resource" do
41
- it "should delete todo item" do
42
- todo = Basecamp::TodoItem.create(:todo_list_id => 4501767, :content => 'Todo for destroy')
43
- Basecamp::TodoItem.delete(todo.id)
44
- end
45
- end
46
-
47
- describe "Using the non-REST inteface" do
48
- it "should return array of projects" do
49
- @basecamp.projects.should be_kind_of(Array)
50
- end
51
-
52
- it "should return valid project with name" do
53
- @basecamp.projects.first.name.should_not be_empty
54
- end
55
-
56
- it "should find person" do
57
- person = @basecamp.person(2926255)
58
- person.should_not be_blank
59
- end
60
- end
61
- end