pipejump 0.2.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.
- data/.document +5 -0
- data/.gitignore +25 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +25 -0
- data/LICENSE +20 -0
- data/README.rdoc +120 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/lib/pipejump/base/collection.rb +117 -0
- data/lib/pipejump/base/connection.rb +54 -0
- data/lib/pipejump/base/errors.rb +11 -0
- data/lib/pipejump/base/resource.rb +182 -0
- data/lib/pipejump/base/session.rb +172 -0
- data/lib/pipejump/resources/account.rb +20 -0
- data/lib/pipejump/resources/client.rb +162 -0
- data/lib/pipejump/resources/contact.rb +225 -0
- data/lib/pipejump/resources/deal.rb +246 -0
- data/lib/pipejump/resources/note.rb +159 -0
- data/lib/pipejump/resources/reminder.rb +171 -0
- data/lib/pipejump/resources/source.rb +159 -0
- data/lib/pipejump.rb +19 -0
- data/spec/connection.sample.yml +3 -0
- data/spec/pipejump/resources/client_spec.rb +119 -0
- data/spec/pipejump/resources/contact_spec.rb +93 -0
- data/spec/pipejump/resources/deal_spec.rb +115 -0
- data/spec/pipejump/resources/note_spec.rb +100 -0
- data/spec/pipejump/resources/reminder_spec.rb +120 -0
- data/spec/pipejump/resources/source_spec.rb +91 -0
- data/spec/pipejump/session_spec.rb +44 -0
- data/spec/spec_helper.rb +12 -0
- metadata +117 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
describe Pipejump::Reminder do
|
3
|
+
|
4
|
+
before do
|
5
|
+
@session = PipejumpSpec.session
|
6
|
+
@client = @session.clients.create(:name => 'Client1')
|
7
|
+
@deal = @session.deals.create(:name => 'New deal', :client_id => @client.id)
|
8
|
+
@valid = { :content => 'Some reminder', :time => '13:00', :date => Time.now + 7 * 60 * 60 * 24 }
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
@client.destroy
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#all' do
|
16
|
+
|
17
|
+
before do
|
18
|
+
@reminder = @deal.reminders.create(@valid)
|
19
|
+
end
|
20
|
+
|
21
|
+
after do
|
22
|
+
@reminder.destroy
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should fetch reminders within a deal" do
|
26
|
+
@deal.reminders.size.should == 1
|
27
|
+
@deal.reminders.first.content.should == 'Some reminder'
|
28
|
+
@deal.reminders.first.time.should == '13:00'
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#find' do
|
34
|
+
|
35
|
+
it "should find reminder" do
|
36
|
+
@reminder = @deal.reminders.create(@valid)
|
37
|
+
@found = @deal.reminders.find(@reminder.id)
|
38
|
+
@found.content.should == 'Some reminder'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should raise an error if not found" do
|
42
|
+
lambda {
|
43
|
+
@deal.reminders.find(-1)
|
44
|
+
}.should raise_error(Pipejump::ResourceNotFound)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#create' do
|
50
|
+
|
51
|
+
describe 'with remind' do
|
52
|
+
|
53
|
+
it "should create reminder with valid params" do
|
54
|
+
@reminder = @deal.reminders.create(@valid)
|
55
|
+
@reminder.attributes.keys.sort.should == ["content", "date", "done", "id", "remind", "time"]
|
56
|
+
@reminder.destroy
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not create reminder with invalid params" do
|
60
|
+
@reminder = @deal.reminders.create(:content => '')
|
61
|
+
@reminder.errors['reminder'].collect{ |e| e['error']['field'] }.sort.should == ["content", "date", "time"]
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'without remind' do
|
67
|
+
|
68
|
+
it "should create reminder with valid params" do
|
69
|
+
@reminder = @deal.reminders.create(:content => 'Foo', :remind => false)
|
70
|
+
@reminder.attributes.keys.sort.should == ["content", "date", "done", "id", "remind", "time"]
|
71
|
+
@reminder.destroy
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should not create reminder with invalid params" do
|
75
|
+
@reminder = @deal.reminders.create(:content => '', :remind => false)
|
76
|
+
@reminder.errors['reminder'].collect{ |e| e['error']['field'] }.sort.should == ["content"]
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#update' do
|
84
|
+
|
85
|
+
before do
|
86
|
+
@reminder = @deal.reminders.create(@valid)
|
87
|
+
end
|
88
|
+
|
89
|
+
after do
|
90
|
+
@reminder.destroy
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should update reminder with valid params" do
|
94
|
+
@reminder.content = 'Updated reminder'
|
95
|
+
@reminder.save.should == true
|
96
|
+
@deal.reminders.find(@reminder.id).content.should == 'Updated reminder'
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should not update reminder with invalid params" do
|
100
|
+
@reminder.content = ''
|
101
|
+
@reminder.save.should == false
|
102
|
+
@reminder.errors['reminder'].collect{ |e| e['error']['field'] }.sort.should == ['content']
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#destroy' do
|
108
|
+
|
109
|
+
it "should destroy a reminder" do
|
110
|
+
@reminder = @deal.reminders.create(@valid)
|
111
|
+
@reminder.destroy.should == true
|
112
|
+
lambda {
|
113
|
+
@deal.reminders.find(@reminder.id)
|
114
|
+
}.should raise_error(Pipejump::ResourceNotFound)
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
describe Pipejump::Source do
|
3
|
+
|
4
|
+
before do
|
5
|
+
@session = PipejumpSpec.session
|
6
|
+
@source1 = @session.sources.create(:name => 'Source1')
|
7
|
+
@source1.id.should_not be_nil
|
8
|
+
@source2 = @session.sources.create(:name => 'Source2')
|
9
|
+
@source2.id.should_not be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
@source1.destroy
|
14
|
+
@source2.destroy
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '@session.sources' do
|
18
|
+
|
19
|
+
it ".all should return all sources" do
|
20
|
+
@session.sources.all.collect(&:name).should == [@source1, @source2].collect(&:name)
|
21
|
+
end
|
22
|
+
|
23
|
+
it ".first should return first source" do
|
24
|
+
@session.sources.first.name.should == @source1.name
|
25
|
+
end
|
26
|
+
|
27
|
+
it ".last should return last source" do
|
28
|
+
@session.sources.last.name.should == @source2.name
|
29
|
+
end
|
30
|
+
|
31
|
+
it ".find should find exact source" do
|
32
|
+
@session.sources.find(@source1.id).name.should == @source1.name
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#method_missing' do
|
38
|
+
|
39
|
+
it "should correctly get and set attributes" do
|
40
|
+
@source1.attributes.keys.sort.should == ['id', 'name']
|
41
|
+
@source1.attributes.keys.each do |attribute|
|
42
|
+
@source1.send(attribute).should == @source1.attributes[attribute]
|
43
|
+
end
|
44
|
+
@source1.name = 'Different name'
|
45
|
+
@source1.name.should == 'Different name'
|
46
|
+
@source1.attributes['name'].should == 'Different name'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should raise a NoMethodError when no accessor is set" do
|
50
|
+
lambda {
|
51
|
+
@source1.not_a_method_name
|
52
|
+
}.should raise_error(NoMethodError)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#create' do
|
58
|
+
|
59
|
+
it "should create record" do
|
60
|
+
@source3 = @session.sources.create(:name => 'Source3')
|
61
|
+
@source3.id.should_not be_nil
|
62
|
+
@source3.name.should == 'Source3'
|
63
|
+
@session.sources.find(@source3.id).name.should == 'Source3'
|
64
|
+
@source3.destroy
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return error on validation fail" do
|
68
|
+
@source3 = @session.sources.create(:name => '')
|
69
|
+
@source3.id.should be_nil
|
70
|
+
@source3.errors.should_not == {}
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#update' do
|
76
|
+
|
77
|
+
it "should update record" do
|
78
|
+
@source1.name = 'Different name'
|
79
|
+
@source1.save.should == true
|
80
|
+
@session.sources.find(@source1.id).name.should == 'Different name'
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should return error on validation fail" do
|
84
|
+
@source1.name = ''
|
85
|
+
@source1.save.should == false
|
86
|
+
@source1.errors.should_not == {}
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
describe Pipejump::Session do
|
3
|
+
|
4
|
+
before do
|
5
|
+
@session = Pipejump::Session.new(AUTH.dup)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have token" do
|
9
|
+
@session.token.should_not be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should raise an error on wrong credentials" do
|
13
|
+
lambda {
|
14
|
+
@session = Pipejump::Session.new(AUTH.merge({'password' => 'NOT_CORRECT_PASSWORD_123qwe'}).dup)
|
15
|
+
}.should raise_error(Pipejump::AuthenticationFailed)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return account data on /account" do
|
19
|
+
account = @session.account
|
20
|
+
account.class.should == Pipejump::Account
|
21
|
+
account.attributes.keys.sort.should == ["currency_name", "id", "name"]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "#connection should return a connection" do
|
25
|
+
@session.connection.class.should == Pipejump::Connection
|
26
|
+
end
|
27
|
+
|
28
|
+
it "#clients should return a collection of clients" do
|
29
|
+
@session.clients.class.should == Pipejump::Collection
|
30
|
+
end
|
31
|
+
|
32
|
+
it "#contacts should return a collection of contacts" do
|
33
|
+
@session.contacts.class.should == Pipejump::Collection
|
34
|
+
end
|
35
|
+
|
36
|
+
it "#sources should return a collection of sources" do
|
37
|
+
@session.sources.class.should == Pipejump::Collection
|
38
|
+
end
|
39
|
+
|
40
|
+
it "#deals should return a collection of deals" do
|
41
|
+
@session.deals.class.should == Pipejump::Collection
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'lib/pipejump'
|
4
|
+
require 'yaml'
|
5
|
+
AUTH = YAML.load_file(File.join(Dir.pwd, 'spec', 'connection.yml'))
|
6
|
+
|
7
|
+
class PipejumpSpec
|
8
|
+
class << self
|
9
|
+
attr_accessor :session
|
10
|
+
end
|
11
|
+
end
|
12
|
+
PipejumpSpec.session = Pipejump::Session.new(AUTH.dup)
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pipejump
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Marcin Bunsch
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-03 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
name: bundler
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
requirement: *id001
|
35
|
+
description: Pipejump API Ruby client
|
36
|
+
email: marcin@pipejump.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- Gemfile
|
48
|
+
- Gemfile.lock
|
49
|
+
- LICENSE
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- VERSION
|
53
|
+
- lib/pipejump.rb
|
54
|
+
- lib/pipejump/base/collection.rb
|
55
|
+
- lib/pipejump/base/connection.rb
|
56
|
+
- lib/pipejump/base/errors.rb
|
57
|
+
- lib/pipejump/base/resource.rb
|
58
|
+
- lib/pipejump/base/session.rb
|
59
|
+
- lib/pipejump/resources/account.rb
|
60
|
+
- lib/pipejump/resources/client.rb
|
61
|
+
- lib/pipejump/resources/contact.rb
|
62
|
+
- lib/pipejump/resources/deal.rb
|
63
|
+
- lib/pipejump/resources/note.rb
|
64
|
+
- lib/pipejump/resources/reminder.rb
|
65
|
+
- lib/pipejump/resources/source.rb
|
66
|
+
- spec/connection.sample.yml
|
67
|
+
- spec/pipejump/resources/client_spec.rb
|
68
|
+
- spec/pipejump/resources/contact_spec.rb
|
69
|
+
- spec/pipejump/resources/deal_spec.rb
|
70
|
+
- spec/pipejump/resources/note_spec.rb
|
71
|
+
- spec/pipejump/resources/reminder_spec.rb
|
72
|
+
- spec/pipejump/resources/source_spec.rb
|
73
|
+
- spec/pipejump/session_spec.rb
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
has_rdoc: true
|
76
|
+
homepage: http://github.com/pipejump/pipejump
|
77
|
+
licenses: []
|
78
|
+
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options:
|
81
|
+
- --charset=UTF-8
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
requirements: []
|
103
|
+
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.3.7
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: Pipejump API Ruby client
|
109
|
+
test_files:
|
110
|
+
- spec/pipejump/resources/client_spec.rb
|
111
|
+
- spec/pipejump/resources/contact_spec.rb
|
112
|
+
- spec/pipejump/resources/deal_spec.rb
|
113
|
+
- spec/pipejump/resources/note_spec.rb
|
114
|
+
- spec/pipejump/resources/reminder_spec.rb
|
115
|
+
- spec/pipejump/resources/source_spec.rb
|
116
|
+
- spec/pipejump/session_spec.rb
|
117
|
+
- spec/spec_helper.rb
|