sk_sdk 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -16,7 +16,7 @@ Dependencies (gem's):
16
16
 
17
17
  == Classes
18
18
 
19
- All classes must be explicitly required
19
+ All classes must be explicitly required so each can be used on their own.
20
20
 
21
21
  require 'sk_sdk/signed_request'
22
22
  require 'sk_sdk/oauth'
@@ -37,6 +37,12 @@ PubSub/Webhook callbacks.
37
37
  Create classes out if thin air to CRUD SalesKing object's using activeresource
38
38
  {see README}[https://github.com/salesking/sk_sdk/blob/master/lib/sk_sdk/README_ArCli.rdoc]
39
39
 
40
+ This client uses HTTPBasic Auth with email/password and does NOT use oAuth. This
41
+ authentication method might be kicked in the future, as oAuth2 is considered
42
+ safer.
43
+ If you have found a convenient way to enable ActiveResource with oAuth2 we are
44
+ glad to hear from you.
45
+
40
46
  == Usage
41
47
 
42
48
  Read specs: https://github.com/salesking/sk_sdk/tree/master/spec/sk_sdk
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -34,11 +34,13 @@ First create the classes:
34
34
  SK::SDK::ArCli.make(:credit_note, King)
35
35
 
36
36
  Now the classes are available they need connection settings first. Those Must
37
- be set for each class separate.
37
+ be set for each class separate and you MUST provide the full url using the right
38
+ protocol http/https + SUBDomain + salesking url + /api
39
+ Our production system only supports HTTPS.
38
40
 
39
41
  [Client, CreditNote].each do |i|
40
- i.send(:set_connection, {:site => 'my_sub.salesking.eu',
41
- :user => 'demo@salesking.eu',
42
+ i.send(:set_connection, {:site => 'https://my_sub.salesking.eu/api',
43
+ :user => 'my-users@login-email.com',
42
44
  :password => 'password' })
43
45
  client = Client.new(:last_name=> 'Meister')
44
46
  client.first_name = "Bau"
@@ -59,7 +61,7 @@ using your SalesKing login email and password.
59
61
 
60
62
  For a production environment be advised to create a user, per api client, and
61
63
  restrict his rights with our build in role-system!
62
- SalesKing only supports HTTPS.
64
+
63
65
 
64
66
  === API Tutorial and Tools
65
67
 
@@ -75,6 +77,8 @@ http-basic-auth can be used.
75
77
 
76
78
  == Tests / Specs
77
79
 
80
+ Take a look into spec/resources to see a how-to
81
+
78
82
  rake coverage
79
83
 
80
84
  Copyright (c) 2011 Georg Leciejewski, released under the MIT license
data/lib/sk_sdk/ar_cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'sk_sdk'
2
3
  require 'active_resource'
3
4
  require 'active_resource/version'
4
5
  # patches are for specific AR version
@@ -10,9 +11,6 @@ elsif ActiveResource::VERSION::MAJOR < 3
10
11
  require 'sk_sdk/ar_cli/patches/ar2/base'
11
12
  end
12
13
 
13
- # schema gem
14
- #require 'sk_api_schema'
15
-
16
14
  module SK::SDK
17
15
  class ArCli
18
16
  # Create a class for a given name
data/lib/sk_sdk/oauth.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'cgi'
2
2
  require 'curb'
3
+ require 'sk_sdk'
3
4
  module SK::SDK
4
5
  # Authenticate your SalesKing App using oAuth2. This class provides helpers
5
6
  # to create the token & dialog url and to get an access token
@@ -1,6 +1,7 @@
1
1
  require 'base64'
2
2
  require "active_support/json"
3
3
  require 'openssl'
4
+ require 'sk_sdk'
4
5
 
5
6
  module SK::SDK
6
7
  # Decode and validate signed requests which Salesking sends to canvas pages
data/sk_sdk.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sk_sdk}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Georg Leciejewski"]
12
- s.date = %q{2011-03-28}
12
+ s.date = %q{2011-05-01}
13
13
  s.description = %q{Connect your business world with SalesKing. This gem gives ruby developers a jump-start for building SalesKing Business Apps. Under the hood it provides classes to handle oAuth, make RESTfull API requests and parses JSON Schema }
14
14
  s.email = %q{gl@salesking.eu}
15
15
  s.extra_rdoc_files = [
@@ -30,9 +30,15 @@ Gem::Specification.new do |s|
30
30
  "lib/sk_sdk/oauth.rb",
31
31
  "lib/sk_sdk/signed_request.rb",
32
32
  "sk_sdk.gemspec",
33
+ "spec/resources_spec_helper.rb",
33
34
  "spec/settings.yml",
34
35
  "spec/sk_sdk/ar_cli_spec.rb",
35
36
  "spec/sk_sdk/oauth_spec.rb",
37
+ "spec/sk_sdk/resources/README.rdoc",
38
+ "spec/sk_sdk/resources/clients_spec.rb",
39
+ "spec/sk_sdk/resources/credit_note_spec.rb",
40
+ "spec/sk_sdk/resources/invoice_spec.rb",
41
+ "spec/sk_sdk/resources/product_spec.rb",
36
42
  "spec/sk_sdk/signed_request_spec.rb",
37
43
  "spec/spec_helper.rb"
38
44
  ]
@@ -41,8 +47,13 @@ Gem::Specification.new do |s|
41
47
  s.rubygems_version = %q{1.6.2}
42
48
  s.summary = %q{SalesKing SDK Ruby}
43
49
  s.test_files = [
50
+ "spec/resources_spec_helper.rb",
44
51
  "spec/sk_sdk/ar_cli_spec.rb",
45
52
  "spec/sk_sdk/oauth_spec.rb",
53
+ "spec/sk_sdk/resources/clients_spec.rb",
54
+ "spec/sk_sdk/resources/credit_note_spec.rb",
55
+ "spec/sk_sdk/resources/invoice_spec.rb",
56
+ "spec/sk_sdk/resources/product_spec.rb",
46
57
  "spec/sk_sdk/signed_request_spec.rb",
47
58
  "spec/spec_helper.rb"
48
59
  ]
@@ -0,0 +1,43 @@
1
+ CONNECTION = {
2
+ :site => "https://demo.dev.salesking.eu/api/",
3
+ # :site => "http://demo.salesking.local:3000/api/",
4
+ :user => "demo@salesking.eu",
5
+ :password => "demouser",
6
+ :format => :json
7
+ } unless defined?(CONNECTION)
8
+
9
+ # create all classes and set their connection
10
+ # instead of
11
+ # SK::SDK::ArCli.make(:client) unless Object.const_defined?('Client')
12
+ # Client.set_connection( CONNECTION )
13
+ [:client, :address, :credit_note, :line_item, :invoice, :product].each do |name|
14
+ class_name = "#{name}".camelize
15
+ SK::SDK::ArCli.make(class_name) unless Object.const_defined?(class_name)
16
+ class_name.constantize.set_connection( CONNECTION )
17
+ end
18
+
19
+
20
+ # check if a SalesKing instance is available by calling /users/current.json
21
+ def sk_available?
22
+ SK::SDK::ArCli.make(:user) unless Object.const_defined?('User')
23
+ User.set_connection( CONNECTION )
24
+ begin
25
+ User.get(:current)
26
+ rescue Errno::ECONNREFUSED #ActiveResource::ResourceNotFound => e
27
+ return false
28
+ end
29
+
30
+ end
31
+
32
+
33
+ def delete_test_data(doc, client)
34
+ doc.destroy
35
+ client.destroy
36
+ lambda {
37
+ doc = Invoice.find(doc.id)
38
+ }.should raise_error(ActiveResource::ResourceNotFound)
39
+ lambda {
40
+ client = Client.find(client.id)
41
+ }.should raise_error(ActiveResource::ResourceNotFound)
42
+ end
43
+
@@ -1,12 +1,8 @@
1
1
  require 'spec/spec_helper'
2
+ require 'spec/resources_spec_helper'
2
3
 
3
4
  describe SK::SDK::ArCli, "make new class" do
4
5
 
5
- before :all do
6
- SK::SDK::ArCli.make(:client)
7
- Client.set_connection( CONNECTION )
8
- end
9
-
10
6
  it "should create class" do
11
7
  c = Client.new
12
8
  c.first_name = 'herbert' # implicit setter
@@ -42,23 +38,4 @@ describe SK::SDK::ArCli, "make new class" do
42
38
  c.id
43
39
  }.should_not raise_error(RuntimeError)
44
40
  end
45
- end
46
-
47
- if sk_available?
48
- describe SK::SDK::ArCli, "with real connection" do
49
-
50
- before :all do
51
- SK::SDK::ArCli.make(:client) unless Object.const_defined?('Client')
52
- Client.set_connection( CONNECTION )
53
- end
54
-
55
- it "should save" do
56
- c = Client.new :organisation=>"Rack'n Roll"
57
- c.save.should be_true
58
- c.id.should_not be_empty
59
- c.number.should_not be_empty
60
- end
61
- end
62
- else
63
- puts "Sorry your local SalesKing server ain't running, skipping real connections tests"
64
- end
41
+ end
@@ -0,0 +1,9 @@
1
+ = SalesKing SDK Resources Specs
2
+
3
+ The specs in here serve mainly as an example using the ActiveResource client
4
+ with username+password to CRUD objects against a real sk server.
5
+
6
+ Of course we also have internal specs for all api controllers but sometimes a
7
+ view from the outside can be revealing.
8
+
9
+ Please be nice and DON'T misuse those tests!
@@ -0,0 +1,102 @@
1
+ require 'spec/spec_helper'
2
+ require 'spec/resources_spec_helper'
3
+
4
+ unless sk_available?
5
+ puts "Sorry cannot connect to your SalesKing server, skipping real connections tests. Please check connection settings in spec_helper"
6
+ else
7
+
8
+ describe Client, "with real connection" do
9
+
10
+ before :all do
11
+ @client = Client.new(:organisation=>'from testing API2')
12
+ @client.save
13
+ end
14
+
15
+ after :all do
16
+ #delete test client
17
+ @client.destroy
18
+ lambda {
19
+ client = Client.find(@client.id)
20
+ }.should raise_error(ActiveResource::ResourceNotFound)
21
+ end
22
+
23
+ it "should save" do
24
+ c = Client.new :organisation=>"Rack'n Roll"
25
+ c.save.should be_true
26
+ c.id.should_not be_empty
27
+ c.number.should_not be_empty
28
+ end
29
+
30
+ it "should fail create a client" do
31
+ client = Client.new(:organisation=>'from testing API2')
32
+ client.bank_iban = 'safasf'
33
+ client.save.should == false
34
+ client.errors.count.should == 1
35
+ client.errors.full_messages.should == ["Bank iban is invalid"]
36
+ end
37
+
38
+ it "should find a single client" do
39
+ client = Client.find(@client.id)
40
+ client.organisation.should == @client.organisation
41
+ end
42
+
43
+ it "should find clients" do
44
+ clients = Client.find(:all)
45
+ clients.should_not be_empty
46
+ end
47
+ end
48
+
49
+
50
+ describe Client, "with addresses" do
51
+
52
+ before :all do
53
+ #setup test client to work with
54
+ @client = Client.new(:organisation=>'Second from testing API2',
55
+ :addresses => [{ :zip => '50374', :city => 'Cologne' }] )
56
+
57
+ @client.save
58
+ end
59
+
60
+ after :all do
61
+ @client.destroy
62
+ lambda {
63
+ client = Client.find(@client.id)
64
+ }.should raise_error(ActiveResource::ResourceNotFound)
65
+ end
66
+
67
+ it "should create an address" do
68
+ @client.addresses.length.should == 1
69
+ @client.addresses.first.zip.should == '50374'
70
+ end
71
+
72
+ it "should edit an address" do
73
+ @client.addresses.length.should == 1
74
+ # puts @client.addresses.inspect
75
+ @client.addresses[0].zip = '40001'
76
+ @client.save
77
+ @client.addresses.length.should == 1
78
+ @client.addresses.first.zip.should == '40001'
79
+ end
80
+
81
+ it "should add an address" do
82
+ cnt_before = @client.addresses.length
83
+ adr = Address.new( { :zip => '37700', :city => 'Cologne' } )
84
+ @client.addresses << adr
85
+ @client.save
86
+ @client.addresses.length.should == cnt_before+1
87
+ end
88
+
89
+ it "should destroy an address" do
90
+ cnt_before = @client.addresses.length
91
+ # adr = Address.new( { :zip => '696969', :city => 'Go eat It' } )
92
+ # @client.addresses << adr
93
+ # @client.save
94
+ @client.addresses.last._delete = 1
95
+ @client.save
96
+ @client.reload
97
+ @client.addresses.length.should == cnt_before-1
98
+ end
99
+ end
100
+
101
+
102
+ end
@@ -0,0 +1,113 @@
1
+ require 'spec/spec_helper'
2
+ require 'spec/resources_spec_helper'
3
+
4
+ unless sk_available?
5
+ puts "Sorry cannot connect to your SalesKing server, skipping real connections tests. Please check connection settings in spec_helper"
6
+ else
7
+
8
+ describe CreditNote, "in general" do
9
+
10
+ before :all do
11
+ #setup test doc to work with
12
+ # create client
13
+ @client = Client.new(:organisation=>'Credit Note API-Tester')
14
+ @client.save.should be_true
15
+ @doc = CreditNote.new()
16
+ @doc.title = 'A Document from the API'
17
+ @doc.client_id = @client.id
18
+ @doc.save.should be_true
19
+ end
20
+
21
+ after :all do
22
+ #delete test doc
23
+ @doc.destroy
24
+ @client.destroy
25
+ lambda {
26
+ doc = CreditNote.find(@doc.id)
27
+ }.should raise_error(ActiveResource::ResourceNotFound)
28
+ lambda {
29
+ client = Client.find(@client.id)
30
+ }.should raise_error(ActiveResource::ResourceNotFound)
31
+ end
32
+
33
+ it "should create a doc and use default before after text" do
34
+ @doc.errors.should be_empty
35
+ @doc.notes_before.should_not be_empty
36
+ @doc.new?.should be_false
37
+ end
38
+
39
+ it "should fail create a doc" do
40
+ doc = CreditNote.new()
41
+ doc.save.should == false
42
+ doc.errors.count.should == 1
43
+ doc.errors.on(:client_id).should == "can't be blank"
44
+ end
45
+
46
+ it "should find a doc" do
47
+ doc = CreditNote.find(@doc.id)
48
+ doc.title.should == @doc.title
49
+ end
50
+
51
+ it "should edit a doc" do
52
+ old_lock_version = @doc.lock_version
53
+ @doc.notes_before = 'You will recieve the amout of:'
54
+ @doc.notes_before = 'Payment made to you bank Account'
55
+ @doc.title = 'Changed doc title'
56
+
57
+ @doc.save.should be_true
58
+ @doc.lock_version.should > old_lock_version # because save returns the data
59
+ end
60
+
61
+ it "should fail edit a doc" do
62
+ @doc.client_id = ''
63
+ @doc.save.should == false
64
+ @doc.errors.count.should == 1
65
+ @doc.errors.on(:client_id).should == "can't be blank"
66
+ end
67
+ end
68
+
69
+ describe CreditNote, "with line items" do
70
+
71
+ before :all do
72
+ @client = Client.new(:organisation=>'Credit Note API-Tester')
73
+ @client.save.should be_true
74
+ #setup test doc to work with
75
+ @doc = CreditNote.new :client_id => @client.id,
76
+ :line_items =>[{ :position=>1, :description => 'Pork Chops',
77
+ :quantity => 12, :price_single =>'10.00'}]
78
+ @doc.save.should be_true
79
+ end
80
+
81
+ after :all do
82
+ @client.destroy #also destroys all docs
83
+ # @doc.destroy
84
+ lambda {
85
+ doc = CreditNote.find(@doc.id)
86
+ }.should raise_error(ActiveResource::ResourceNotFound)
87
+ end
88
+
89
+ it "should create a line item" do
90
+ @doc.line_items.length.should == 1
91
+ @doc.line_items.first.description.should == 'Pork Chops'
92
+ @doc.price_total.should == 120.0
93
+ end
94
+
95
+ it "should edit line item" do
96
+ @doc.line_items[0].description = 'Egg Sandwich'
97
+ @doc.save
98
+ @doc.line_items.length.should == 1
99
+ @doc.line_items.first.description.should == 'Egg Sandwich'
100
+ end
101
+
102
+ it "should add line item" do
103
+ item = LineItem.new :position=>2, :description => 'Goat-Pie',
104
+ :price_single => 10, :quantity=>10
105
+ @doc.line_items << item
106
+ @doc.save
107
+ @doc.line_items.length.should == 2
108
+ @doc.price_total.should == 220.0
109
+ # @doc.line_items[0].zip = '40001'
110
+ # @doc.line_items.[1].zip.should == '40001'
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,152 @@
1
+ require 'spec/spec_helper'
2
+ require 'spec/resources_spec_helper'
3
+
4
+ unless sk_available?
5
+ puts "Sorry cannot connect to your SalesKing server, skipping real connections tests. Please check connection settings in spec_helper"
6
+ else
7
+
8
+ describe Invoice, "in general" do
9
+
10
+ before :all do
11
+ @client = Client.new(:organisation=>'Invoice API-Tester')
12
+ @client.save.should be_true
13
+ @doc = Invoice.new()
14
+ @doc.title = 'A Document from the API'
15
+ @doc.client_id = @client.id
16
+ @doc.save.should be_true
17
+ end
18
+
19
+ after :all do
20
+ delete_test_data(@doc, @client)
21
+ end
22
+
23
+ it "should find a doc" do
24
+ doc = Invoice.find(@doc.id)
25
+ doc.title.should == @doc.title
26
+ end
27
+ end
28
+
29
+ describe Invoice, "a new invoice" do
30
+
31
+ before :all do
32
+ @client = Client.new(:organisation=>'Invoice API-Tester')
33
+ @client.save.should be_true
34
+ end
35
+ after :all do
36
+ @client.destroy
37
+ end
38
+
39
+ it "should create a doc" do
40
+ doc = Invoice.new()
41
+ doc.title = 'A Document from the API'
42
+ doc.notes_before = 'Your shiny new invoice [number]'
43
+ doc.notes_after = 'Please pay me'
44
+ doc.client_id = @client.id
45
+ doc.save
46
+ doc.errors.should be_empty
47
+ doc.new?.should be_false
48
+ doc.notes_before.should == 'Your shiny new invoice [number]'
49
+ doc.destroy
50
+ end
51
+
52
+ it "should create a doc with default before after texts" do
53
+ doc = Invoice.new()
54
+ doc.title = 'A Document from the API'
55
+ doc.client_id = @client.id
56
+ doc.save
57
+ doc.errors.should be_empty
58
+ doc.new?.should be_false
59
+ doc.notes_before.should_not be_empty
60
+ doc.destroy
61
+ end
62
+
63
+ it "should fail create a doc" do
64
+ doc = Invoice.new()
65
+ doc.save.should == false
66
+ doc.errors.count.should == 1
67
+ doc.errors.on(:client_id).should == "can't be blank"
68
+ end
69
+
70
+ end
71
+
72
+ describe Invoice, "Edit an invoice" do
73
+
74
+ before :all do
75
+ #setup test doc to work with
76
+ # create client
77
+ @client = Client.new(:organisation=>'Invoice API-Tester')
78
+ @client.save.should be_true
79
+ @doc = Invoice.new()
80
+ @doc.title = 'A Document from the API'
81
+ @doc.notes_before = 'Your invoice [number]'
82
+ @doc.client_id = @client.id
83
+ @doc.save.should be_true
84
+ end
85
+
86
+ after :all do
87
+ delete_test_data(@doc, @client)
88
+ end
89
+
90
+ it "should edit a doc" do
91
+ old_lock_version = @doc.lock_version
92
+ @doc.notes_before.should == 'Your invoice [number]'
93
+ @doc.notes_before = 'You will recieve the amout of:'
94
+ @doc.notes_after = 'Payment made to you bank Account'
95
+ @doc.title = 'Changed doc title'
96
+
97
+ @doc.save.should be_true
98
+ @doc.lock_version.should > old_lock_version # because save returns the data
99
+ @doc.notes_before.should == 'You will recieve the amout of:'
100
+ end
101
+
102
+ it "should fail edit without a client" do
103
+ @doc.client_id = ''
104
+ @doc.save.should == false
105
+ @doc.errors.count.should == 1
106
+ @doc.errors.on(:client_id).should == "can't be blank"
107
+ end
108
+ end
109
+
110
+ describe Invoice, "with line items" do
111
+
112
+ before :all do
113
+ @client = Client.new(:organisation=>'Credit Note API-Tester')
114
+ @client.save.should be_true
115
+ #setup test doc to work with
116
+ @doc = Invoice.new(:client_id => @client.id,
117
+ :line_items => [{ :position=>1, :description => 'Pork Chops',
118
+ :quantity => 12, :price_single =>'10.00' }] )
119
+ @doc.save.should be_true
120
+ end
121
+
122
+ after :all do
123
+ delete_test_data(@doc, @client)
124
+ end
125
+
126
+ it "should create a line item" do
127
+ @doc.line_items.length.should == 1
128
+ @doc.line_items.first.description.should == 'Pork Chops'
129
+ @doc.price_total.should == 120.0
130
+ end
131
+
132
+ it "should edit line item" do
133
+ @doc.line_items[0].description = 'Egg Sandwich'
134
+ @doc.save
135
+ @doc.line_items.length.should == 1
136
+ @doc.line_items.first.description.should == 'Egg Sandwich'
137
+ end
138
+
139
+ it "should add line item" do
140
+ item = LineItem.new( { :position=>2, :description => 'Goat-Pie', :price_single => 10, :quantity=>10} )
141
+ product = Product.new(:name=>'Eis am Stiel', :price => 1.50, :tax=>19, :description => 'Mmmhh lecker Eis')
142
+ product.save.should be_true
143
+ item1 = LineItem.new( { :position=>3, :use_product => 1, :product_id=> product.id, :quantity => 10 } )
144
+ @doc.line_items << item
145
+ @doc.line_items << item1
146
+ @doc.save
147
+ @doc.line_items.length.should == 3
148
+ @doc.price_total.should == 235.0
149
+ end
150
+
151
+ end
152
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec/spec_helper'
2
+ require 'spec/resources_spec_helper'
3
+
4
+ unless sk_available?
5
+ puts "Sorry cannot connect to your SalesKing server, skipping real connections tests. Please check connection settings in spec_helper"
6
+ else
7
+
8
+ describe Product, "in general" do
9
+
10
+ before :all do
11
+ #setup test product to work with
12
+ @product = Product.new(:name=>'Eis am Stiel', :price => 1.50)
13
+ @product.save.should be_true
14
+ end
15
+
16
+ after :all do
17
+ #delete test product
18
+ @product.destroy
19
+ lambda {
20
+ product = Product.find(@product.id)
21
+ }.should raise_error(ActiveResource::ResourceNotFound)
22
+ end
23
+
24
+ it "should create a product" do
25
+ @product.number.should_not be_nil
26
+ @product.price.should == 1.50
27
+ @product.new?.should be_false
28
+ end
29
+
30
+ it "should fail create a product without name" do
31
+ product = Product.new(:price => 2.50)
32
+ product.save.should == false
33
+ product.errors.count.should == 1
34
+ product.errors.full_messages.should == ["Name can't be blank"]
35
+ end
36
+
37
+ it "should fail create a product with empty price" do
38
+ product = Product.new(:name => 'No brain', :price =>' ')
39
+ product.save.should be_false
40
+ product.errors.full_messages.should == ["Price can't be blank", "Price is not a number"]
41
+ end
42
+
43
+ it "should find a product by id" do
44
+ product = Product.find(@product.id)
45
+ product.name.should == @product.name
46
+ end
47
+
48
+ it "should edit a product" do
49
+ @product.name = 'A new product name'
50
+ @product.lock_version.should == 0
51
+ @product.save
52
+ @product.lock_version.should == 1 # because save returns the data
53
+ end
54
+
55
+ it "should fail edit a product" do
56
+ @product.name = ''
57
+ @product.save.should == false
58
+ @product.errors.count.should == 1
59
+ @product.errors.on(:name).should == "can't be blank"
60
+ end
61
+
62
+ end
63
+ end
data/spec/spec_helper.rb CHANGED
@@ -15,21 +15,3 @@ puts "Testing with ActiveResource v: #{ActiveResource::VERSION::STRING}."
15
15
  def load_settings
16
16
  @set ||= YAML.load_file(File.join(File.dirname(__FILE__), 'settings.yml'))
17
17
  end
18
-
19
- CONNECTION = {
20
- :site => "http://demo.salesking.local:3000/api/",
21
- :user => "demo@salesking.eu",
22
- :password => "demo",
23
- :format => :json
24
- } unless defined?(CONNECTION)
25
-
26
- def sk_available?
27
- SK::SDK::ArCli.make(:user) unless Object.const_defined?('User')
28
- User.set_connection( CONNECTION )
29
- begin
30
- User.get(:current)
31
- rescue Errno::ECONNREFUSED #ActiveResource::ResourceNotFound => e
32
- return false
33
- end
34
-
35
- end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sk_sdk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Georg Leciejewski
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-28 00:00:00 +02:00
18
+ date: 2011-05-01 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -97,9 +97,15 @@ files:
97
97
  - lib/sk_sdk/oauth.rb
98
98
  - lib/sk_sdk/signed_request.rb
99
99
  - sk_sdk.gemspec
100
+ - spec/resources_spec_helper.rb
100
101
  - spec/settings.yml
101
102
  - spec/sk_sdk/ar_cli_spec.rb
102
103
  - spec/sk_sdk/oauth_spec.rb
104
+ - spec/sk_sdk/resources/README.rdoc
105
+ - spec/sk_sdk/resources/clients_spec.rb
106
+ - spec/sk_sdk/resources/credit_note_spec.rb
107
+ - spec/sk_sdk/resources/invoice_spec.rb
108
+ - spec/sk_sdk/resources/product_spec.rb
103
109
  - spec/sk_sdk/signed_request_spec.rb
104
110
  - spec/spec_helper.rb
105
111
  has_rdoc: true
@@ -137,7 +143,12 @@ signing_key:
137
143
  specification_version: 3
138
144
  summary: SalesKing SDK Ruby
139
145
  test_files:
146
+ - spec/resources_spec_helper.rb
140
147
  - spec/sk_sdk/ar_cli_spec.rb
141
148
  - spec/sk_sdk/oauth_spec.rb
149
+ - spec/sk_sdk/resources/clients_spec.rb
150
+ - spec/sk_sdk/resources/credit_note_spec.rb
151
+ - spec/sk_sdk/resources/invoice_spec.rb
152
+ - spec/sk_sdk/resources/product_spec.rb
142
153
  - spec/sk_sdk/signed_request_spec.rb
143
154
  - spec/spec_helper.rb