pipejump 0.2.0 → 0.3.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/.gitignore +4 -1
- data/.rspec +1 -0
- data/Gemfile +4 -3
- data/Gemfile.lock +20 -15
- data/Rakefile +4 -31
- data/VERSION +1 -1
- data/lib/pipejump/base/collection.rb +15 -15
- data/lib/pipejump/base/connection.rb +14 -14
- data/lib/pipejump/base/resource.rb +49 -41
- data/lib/pipejump/base/session.rb +81 -69
- data/lib/pipejump/resources/contact.rb +131 -121
- data/lib/pipejump/resources/deal.rb +122 -122
- data/lib/pipejump/resources/reminder.rb +97 -94
- data/lib/pipejump/version.rb +3 -0
- data/lib/pipejump.rb +1 -2
- data/pipejump.gemspec +21 -0
- data/spec/pipejump/resources/contact/note_spec.rb +100 -0
- data/spec/pipejump/resources/contact/reminder_spec.rb +128 -0
- data/spec/pipejump/resources/contact_spec.rb +45 -37
- data/spec/pipejump/resources/{note_spec.rb → deal/note_spec.rb} +29 -28
- data/spec/pipejump/resources/{reminder_spec.rb → deal/reminder_spec.rb} +43 -35
- data/spec/pipejump/resources/deal_spec.rb +45 -39
- data/spec/pipejump/resources/source_spec.rb +29 -26
- data/spec/pipejump/session_spec.rb +12 -13
- data/spec/spec_helper.rb +17 -2
- metadata +25 -45
- data/lib/pipejump/resources/client.rb +0 -162
- data/spec/pipejump/resources/client_spec.rb +0 -119
@@ -1,119 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
describe Pipejump::Client do
|
3
|
-
|
4
|
-
before do
|
5
|
-
@session = PipejumpSpec.session
|
6
|
-
@client1 = @session.clients.create(:name => 'Client1')
|
7
|
-
@client1.id.should_not be_nil
|
8
|
-
@client2 = @session.clients.create(:name => 'Client2')
|
9
|
-
@client2.id.should_not be_nil
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
@client1.destroy
|
14
|
-
@client2.destroy
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '@session.clients' do
|
18
|
-
|
19
|
-
it ".all should return all clients" do
|
20
|
-
@session.clients.all.collect(&:name).should == [@client1, @client2].collect(&:name)
|
21
|
-
end
|
22
|
-
|
23
|
-
it ".first should return first client" do
|
24
|
-
@session.clients.first.name.should == @client1.name
|
25
|
-
end
|
26
|
-
|
27
|
-
it ".last should return last client" do
|
28
|
-
@session.clients.last.name.should == @client2.name
|
29
|
-
end
|
30
|
-
|
31
|
-
it ".find should find exact client" do
|
32
|
-
@session.clients.find(@client1.id).name.should == @client1.name
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#method_missing' do
|
38
|
-
|
39
|
-
it "should correctly get and set attributes" do
|
40
|
-
@client1.attributes.keys.sort.should == ['id', 'name']
|
41
|
-
@client1.attributes.keys.each do |attribute|
|
42
|
-
@client1.send(attribute).should == @client1.attributes[attribute]
|
43
|
-
end
|
44
|
-
@client1.name = 'Different name'
|
45
|
-
@client1.name.should == 'Different name'
|
46
|
-
@client1.attributes['name'].should == 'Different name'
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should raise a NoMethodError when no accessor is set" do
|
50
|
-
lambda {
|
51
|
-
@client1.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
|
-
@client3 = @session.clients.create(:name => 'Client3')
|
61
|
-
@client3.id.should_not be_nil
|
62
|
-
@client3.name.should == 'Client3'
|
63
|
-
@session.clients.find(@client3.id).name.should == 'Client3'
|
64
|
-
@client3.destroy
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should return error on validation fail" do
|
68
|
-
@client3 = @session.clients.create(:name => '')
|
69
|
-
@client3.id.should be_nil
|
70
|
-
@client3.errors.should_not == {}
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
describe '#update' do
|
76
|
-
|
77
|
-
it "should update record" do
|
78
|
-
@client1.name = 'Different name'
|
79
|
-
@client1.save.should == true
|
80
|
-
@session.clients.find(@client1.id).name.should == 'Different name'
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should return error on validation fail" do
|
84
|
-
@client1.name = ''
|
85
|
-
@client1.save.should == false
|
86
|
-
@client1.errors.should_not == {}
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '#contacts' do
|
92
|
-
|
93
|
-
before do
|
94
|
-
@contact1 = @session.contacts.create(:name => 'contact1', :client_id => @client1.id)
|
95
|
-
@contact2 = @session.contacts.create(:name => 'contact2', :client_id => @client1.id)
|
96
|
-
end
|
97
|
-
|
98
|
-
describe '#all' do
|
99
|
-
|
100
|
-
it "should return contacts of a client" do
|
101
|
-
contacts = @client1.contacts
|
102
|
-
contacts.size.should == 2
|
103
|
-
contacts.collect(&:name).should == ['contact1', 'contact2']
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
describe '#find' do
|
109
|
-
|
110
|
-
it "should return a single contact of a client" do
|
111
|
-
contact = @client1.contacts.find(@contact1.id)
|
112
|
-
contact.name == 'contact1'
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|