taxjar-ruby 1.1.3 → 1.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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +32 -14
- data/lib/taxjar/api/api.rb +1 -1
- data/lib/taxjar/api/order.rb +1 -0
- data/lib/taxjar/api/refund.rb +1 -0
- data/lib/taxjar/api/request.rb +25 -28
- data/lib/taxjar/api/utils.rb +0 -1
- data/lib/taxjar/base.rb +3 -12
- data/lib/taxjar/breakdown.rb +10 -3
- data/lib/taxjar/breakdown_line_item.rb +16 -4
- data/lib/taxjar/category.rb +5 -1
- data/lib/taxjar/client.rb +1 -0
- data/lib/taxjar/error.rb +0 -1
- data/lib/taxjar/line_item.rb +9 -3
- data/lib/taxjar/order.rb +13 -3
- data/lib/taxjar/rate.rb +10 -2
- data/lib/taxjar/refund.rb +14 -3
- data/lib/taxjar/shipping.rb +12 -4
- data/lib/taxjar/tax.rb +10 -3
- data/lib/taxjar/version.rb +2 -3
- data/spec/helper.rb +0 -2
- data/spec/taxjar/api/api_spec.rb +46 -1
- data/spec/taxjar/api/order_spec.rb +85 -9
- data/spec/taxjar/api/refund_spec.rb +90 -8
- data/spec/taxjar/api/request_spec.rb +0 -2
- data/spec/taxjar/client_spec.rb +0 -1
- data/spec/taxjar/error_spec.rb +0 -1
- data/taxjar-ruby.gemspec +1 -0
- metadata +16 -4
- data/spec/taxjar/base_spec.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 638c573bdfd19c15d48c1cc87d79fb2292a8f031
|
4
|
+
data.tar.gz: b3382222c75bc4b8299d8d8aee75ae3ba919b40b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bdbf7a23361f1caa03825f8561e95dd88495bd29d4627a21e6049b4fcdf436430bb3578db00a88a6c05caa5a89a91ac4bfbc7bef24697546448d1df37e35127
|
7
|
+
data.tar.gz: 2271da6641e398fbb4f7e16b87cd563503f07e4be5f9d347d1ec6e3760bd3bd0da121300732938f416e5eccc5fba9a9eaf08e46174a20538c0e591998677ba75
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -103,14 +103,32 @@ client.rates_for_location
|
|
103
103
|
require 'taxjar'
|
104
104
|
client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')
|
105
105
|
|
106
|
-
|
106
|
+
# United States (ZIP+4)
|
107
|
+
rates = client.rates_for_location('90404-3370')
|
108
|
+
|
109
|
+
# United States (ZIP w/ Optional Params)
|
110
|
+
rates = client.rates_for_location('90404', {
|
111
|
+
:city => 'SANTA MONICA',
|
112
|
+
:country => 'US'
|
113
|
+
})
|
114
|
+
|
115
|
+
# International Examples (Requires City and Country)
|
116
|
+
rates = client.rates_for_location('V5K0A1', {
|
117
|
+
:city => 'VANCOUVER',
|
118
|
+
:country => 'CA'
|
119
|
+
})
|
120
|
+
|
121
|
+
rates = client.rates_for_location('00150', {
|
122
|
+
:city => 'HELSINKI',
|
123
|
+
:country => 'FI'
|
124
|
+
})
|
107
125
|
```
|
108
126
|
|
109
127
|
#### Example Response
|
110
128
|
|
111
129
|
```ruby
|
112
130
|
#<Taxjar::Rate:0x007fc47056a928 @attrs={
|
113
|
-
:zip => 90002,
|
131
|
+
:zip => "90002",
|
114
132
|
:state => "CA",
|
115
133
|
:state_rate => 0.065,
|
116
134
|
:county => "LOS ANGELES",
|
@@ -178,7 +196,7 @@ client.tax_for_order({
|
|
178
196
|
:special_district_tax_collectable => 0.22,
|
179
197
|
:line_items => [
|
180
198
|
{
|
181
|
-
:id =>
|
199
|
+
:id => 1,
|
182
200
|
:state_taxable_amount => 15.0,
|
183
201
|
:state_sales_tax_rate => 0.065,
|
184
202
|
:county_taxable_amount => 15.0,
|
@@ -238,7 +256,7 @@ client.show_order('123')
|
|
238
256
|
|
239
257
|
```ruby
|
240
258
|
#<Taxjar::Order:0x007fd3e514a940 @attrs={
|
241
|
-
:transaction_id => 123,
|
259
|
+
:transaction_id => "123",
|
242
260
|
:user_id => 11836,
|
243
261
|
:transaction_date => "2015-05-14T00:00:00Z",
|
244
262
|
:transaction_reference_id => nil,
|
@@ -312,7 +330,7 @@ client.create_order({
|
|
312
330
|
|
313
331
|
```ruby
|
314
332
|
#<Taxjar::Order:0x007f6d65b252d0 @attrs={
|
315
|
-
:transaction_id => 20,
|
333
|
+
:transaction_id => "20",
|
316
334
|
:user_id => 11836,
|
317
335
|
:transaction_date => "2015-05-14T00:00:00Z",
|
318
336
|
:transaction_reference_id => nil,
|
@@ -372,7 +390,7 @@ client.update_order({
|
|
372
390
|
|
373
391
|
```ruby
|
374
392
|
#<Taxjar::Order:0x007f6d65b252d0 @attrs={
|
375
|
-
:transaction_id => 123,
|
393
|
+
:transaction_id => "123",
|
376
394
|
:user_id => 11836,
|
377
395
|
:transaction_date => "2015-05-14T00:00:00Z",
|
378
396
|
:transaction_reference_id => nil,
|
@@ -425,7 +443,7 @@ client.delete_order(123)
|
|
425
443
|
|
426
444
|
```ruby
|
427
445
|
#<Taxjar::Order:0x007f6d65b252d0 @attrs={
|
428
|
-
:transaction_id => 123,
|
446
|
+
:transaction_id => "123",
|
429
447
|
:user_id => 11836,
|
430
448
|
:transaction_date => "2015-05-14T00:00:00Z",
|
431
449
|
:transaction_reference_id => nil,
|
@@ -502,7 +520,7 @@ client.show_refund('321')
|
|
502
520
|
|
503
521
|
```ruby
|
504
522
|
#<Taxjar::Refund:0x007f6da40e33a0 @attrs={
|
505
|
-
:transaction_id => 321,
|
523
|
+
:transaction_id => "321",
|
506
524
|
:user_id => 11836,
|
507
525
|
:transaction_date => "2015-06-14T00:00:00Z",
|
508
526
|
:transaction_reference_id => 123,
|
@@ -577,10 +595,10 @@ refund = client.create_refund({
|
|
577
595
|
|
578
596
|
```ruby
|
579
597
|
#<Taxjar::Refund:0x007f6da40e33a0 @attrs={
|
580
|
-
:transaction_id => 321,
|
598
|
+
:transaction_id => "321",
|
581
599
|
:user_id => 11836,
|
582
600
|
:transaction_date => "2015-06-14T00:00:00Z",
|
583
|
-
:transaction_reference_id => 123,
|
601
|
+
:transaction_reference_id => "123",
|
584
602
|
:from_country => "US",
|
585
603
|
:from_zip => 93107,
|
586
604
|
:from_state => "CA",
|
@@ -637,10 +655,10 @@ refund = client.update_refund{
|
|
637
655
|
|
638
656
|
```ruby
|
639
657
|
#<Taxjar::Refund:0x007f6da40e33a0 @attrs={
|
640
|
-
:transaction_id => 321,
|
658
|
+
:transaction_id => "321",
|
641
659
|
:user_id => 11836,
|
642
660
|
:transaction_date => "2015-06-14T00:00:00Z",
|
643
|
-
:transaction_reference_id => 123,
|
661
|
+
:transaction_reference_id => "123",
|
644
662
|
:from_country => "US",
|
645
663
|
:from_zip => 93107,
|
646
664
|
:from_state => "CA",
|
@@ -687,10 +705,10 @@ client.delete_refund(321)
|
|
687
705
|
|
688
706
|
```ruby
|
689
707
|
#<Taxjar::Refund:0x007f6da40e33a0 @attrs={
|
690
|
-
:transaction_id => 321,
|
708
|
+
:transaction_id => "321",
|
691
709
|
:user_id => 11836,
|
692
710
|
:transaction_date => "2015-06-14T00:00:00Z",
|
693
|
-
:transaction_reference_id => 123,
|
711
|
+
:transaction_reference_id => "123",
|
694
712
|
:from_country => "US",
|
695
713
|
:from_zip => 93107,
|
696
714
|
:from_state => "CA",
|
data/lib/taxjar/api/api.rb
CHANGED
data/lib/taxjar/api/order.rb
CHANGED
data/lib/taxjar/api/refund.rb
CHANGED
data/lib/taxjar/api/request.rb
CHANGED
@@ -31,40 +31,37 @@ module Taxjar
|
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
+
def set_request_headers
|
35
|
+
@headers = {}
|
36
|
+
@headers[:user_agent] = client.user_agent
|
37
|
+
@headers[:authorization] = "Bearer #{client.api_key}"
|
38
|
+
end
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
object[index] = symbolize_keys!(val)
|
45
|
-
end
|
46
|
-
elsif object.is_a?(Hash)
|
47
|
-
object.keys.each do |key|
|
48
|
-
object[key.to_sym] = symbolize_keys!(object.delete(key))
|
40
|
+
def symbolize_keys!(object)
|
41
|
+
if object.is_a?(Array)
|
42
|
+
object.each_with_index do |val, index|
|
43
|
+
object[index] = symbolize_keys!(val)
|
44
|
+
end
|
45
|
+
elsif object.is_a?(Hash)
|
46
|
+
object.keys.each do |key|
|
47
|
+
object[key.to_sym] = symbolize_keys!(object.delete(key))
|
48
|
+
end
|
49
49
|
end
|
50
|
+
object
|
50
51
|
end
|
51
|
-
object
|
52
|
-
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
def extract_error(code, body)
|
61
|
-
klass = Taxjar::Error::ERRORS[code]
|
62
|
-
if !klass.nil?
|
63
|
-
klass.from_response(body)
|
53
|
+
def fail_or_return_response_body(code, body)
|
54
|
+
e = extract_error(code, body)
|
55
|
+
fail(e) if e
|
56
|
+
body[object_key.to_sym]
|
64
57
|
end
|
65
|
-
end
|
66
|
-
|
67
58
|
|
59
|
+
def extract_error(code, body)
|
60
|
+
klass = Taxjar::Error::ERRORS[code]
|
61
|
+
if !klass.nil?
|
62
|
+
klass.from_response(body)
|
63
|
+
end
|
64
|
+
end
|
68
65
|
end
|
69
66
|
end
|
70
67
|
end
|
data/lib/taxjar/api/utils.rb
CHANGED
data/lib/taxjar/base.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'addressable/uri'
|
2
2
|
require 'forwardable'
|
3
3
|
require 'memoizable'
|
4
|
+
require 'model_attribute'
|
4
5
|
|
5
6
|
if !Array.new.respond_to?(:to_h)
|
6
7
|
module Enumerable
|
@@ -70,9 +71,8 @@ module Taxjar
|
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
73
|
-
def initialize(
|
74
|
-
attrs =
|
75
|
-
@attrs = attrs || {}
|
74
|
+
def initialize(attributes = {})
|
75
|
+
@attrs = set_attributes(attributes)
|
76
76
|
end
|
77
77
|
|
78
78
|
def [](method)
|
@@ -96,14 +96,5 @@ module Taxjar
|
|
96
96
|
attrs.delete(key1).merge(key2 => attrs)
|
97
97
|
end
|
98
98
|
end
|
99
|
-
|
100
|
-
def values_as_floats_where_possible(attrs)
|
101
|
-
attrs.map{|k, v| [k, to_f_or_i_or_s(v)]}.to_h
|
102
|
-
end
|
103
|
-
|
104
|
-
def to_f_or_i_or_s(v)
|
105
|
-
((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v
|
106
|
-
end
|
107
|
-
|
108
99
|
end
|
109
100
|
end
|
data/lib/taxjar/breakdown.rb
CHANGED
@@ -3,9 +3,16 @@ require 'taxjar/shipping'
|
|
3
3
|
|
4
4
|
module Taxjar
|
5
5
|
class Breakdown < Taxjar::Base
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
extend ModelAttribute
|
7
|
+
|
8
|
+
attribute :state_taxable_amount, :float
|
9
|
+
attribute :state_tax_collectable, :float
|
10
|
+
attribute :county_taxable_amount, :float
|
11
|
+
attribute :county_tax_collectable, :float
|
12
|
+
attribute :city_taxable_amount, :float
|
13
|
+
attribute :city_tax_collectable, :float
|
14
|
+
attribute :special_district_taxable_amount, :float
|
15
|
+
attribute :special_district_tax_collectable, :float
|
9
16
|
|
10
17
|
object_attr_reader Taxjar::Shipping, :shipping
|
11
18
|
|
@@ -2,9 +2,21 @@ require 'taxjar/base'
|
|
2
2
|
|
3
3
|
module Taxjar
|
4
4
|
class BreakdownLineItem < Taxjar::Base
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
extend ModelAttribute
|
6
|
+
|
7
|
+
attribute :id, :integer
|
8
|
+
attribute :tax_collectable, :float
|
9
|
+
attribute :state_taxable_amount, :float
|
10
|
+
attribute :state_sales_tax_rate, :float
|
11
|
+
attribute :state_amount, :float
|
12
|
+
attribute :county_taxable_amount, :float
|
13
|
+
attribute :county_tax_rate, :float
|
14
|
+
attribute :county_amount, :float
|
15
|
+
attribute :city_taxable_amount, :float
|
16
|
+
attribute :city_tax_rate, :float
|
17
|
+
attribute :city_amount, :float
|
18
|
+
attribute :special_district_taxable_amount, :float
|
19
|
+
attribute :special_tax_rate, :float
|
20
|
+
attribute :special_district_amount, :float
|
9
21
|
end
|
10
22
|
end
|
data/lib/taxjar/category.rb
CHANGED
@@ -2,6 +2,10 @@ require 'taxjar/base'
|
|
2
2
|
|
3
3
|
module Taxjar
|
4
4
|
class Category < Taxjar::Base
|
5
|
-
|
5
|
+
extend ModelAttribute
|
6
|
+
|
7
|
+
attribute :name, :string
|
8
|
+
attribute :product_tax_code, :string
|
9
|
+
attribute :description, :string
|
6
10
|
end
|
7
11
|
end
|
data/lib/taxjar/client.rb
CHANGED
data/lib/taxjar/error.rb
CHANGED
data/lib/taxjar/line_item.rb
CHANGED
@@ -2,8 +2,14 @@ require 'taxjar/base'
|
|
2
2
|
|
3
3
|
module Taxjar
|
4
4
|
class LineItem < Taxjar::Base
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
extend ModelAttribute
|
6
|
+
|
7
|
+
attribute :id, :integer
|
8
|
+
attribute :quantity, :integer
|
9
|
+
attribute :product_identifier, :string
|
10
|
+
attribute :description, :string
|
11
|
+
attribute :unit_price, :float
|
12
|
+
attribute :discount, :float
|
13
|
+
attribute :sales_tax, :float
|
8
14
|
end
|
9
15
|
end
|
data/lib/taxjar/order.rb
CHANGED
@@ -2,12 +2,22 @@ require 'taxjar/base'
|
|
2
2
|
|
3
3
|
module Taxjar
|
4
4
|
class Order < Taxjar::Base
|
5
|
-
|
6
|
-
|
5
|
+
extend ModelAttribute
|
6
|
+
|
7
|
+
attribute :transaction_id, :string
|
8
|
+
attribute :user_id, :integer
|
9
|
+
attribute :transaction_date, :string
|
10
|
+
attribute :to_country, :string
|
11
|
+
attribute :to_zip, :string
|
12
|
+
attribute :to_state, :string
|
13
|
+
attribute :to_city, :string
|
14
|
+
attribute :to_street, :string
|
15
|
+
attribute :amount, :float
|
16
|
+
attribute :shipping, :float
|
17
|
+
attribute :sales_tax, :float
|
7
18
|
|
8
19
|
def line_items
|
9
20
|
map_collection(Taxjar::LineItem, :line_items)
|
10
21
|
end
|
11
|
-
|
12
22
|
end
|
13
23
|
end
|
data/lib/taxjar/rate.rb
CHANGED
@@ -2,8 +2,16 @@ require 'taxjar/base'
|
|
2
2
|
|
3
3
|
module Taxjar
|
4
4
|
class Rate < Taxjar::Base
|
5
|
-
|
6
|
-
:combined_district_rate, :combined_rate
|
5
|
+
extend ModelAttribute
|
7
6
|
|
7
|
+
attribute :zip, :string
|
8
|
+
attribute :state, :string
|
9
|
+
attribute :state_rate, :float
|
10
|
+
attribute :county, :string
|
11
|
+
attribute :county_rate, :float
|
12
|
+
attribute :city, :string
|
13
|
+
attribute :city_rate, :float
|
14
|
+
attribute :combined_district_rate, :float
|
15
|
+
attribute :combined_rate, :float
|
8
16
|
end
|
9
17
|
end
|
data/lib/taxjar/refund.rb
CHANGED
@@ -2,9 +2,20 @@ require 'taxjar/base'
|
|
2
2
|
|
3
3
|
module Taxjar
|
4
4
|
class Refund < Taxjar::Base
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
extend ModelAttribute
|
6
|
+
|
7
|
+
attribute :transaction_id, :string
|
8
|
+
attribute :user_id, :integer
|
9
|
+
attribute :transaction_date, :string
|
10
|
+
attribute :transaction_reference_id, :string
|
11
|
+
attribute :to_country, :string
|
12
|
+
attribute :to_zip, :string
|
13
|
+
attribute :to_state, :string
|
14
|
+
attribute :to_city, :string
|
15
|
+
attribute :to_street, :string
|
16
|
+
attribute :amount, :float
|
17
|
+
attribute :shipping, :float
|
18
|
+
attribute :sales_tax, :float
|
8
19
|
|
9
20
|
def line_items
|
10
21
|
map_collection(Taxjar::LineItem, :line_items)
|
data/lib/taxjar/shipping.rb
CHANGED
@@ -2,9 +2,17 @@ require 'taxjar/base'
|
|
2
2
|
|
3
3
|
module Taxjar
|
4
4
|
class Shipping < Taxjar::Base
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
extend ModelAttribute
|
6
|
+
|
7
|
+
attribute :taxable_amount, :float
|
8
|
+
attribute :tax_collectable, :float
|
9
|
+
attribute :state_amount, :float
|
10
|
+
attribute :state_sales_tax_rate, :float
|
11
|
+
attribute :county_amount, :float
|
12
|
+
attribute :county_tax_rate, :float
|
13
|
+
attribute :city_amount, :float
|
14
|
+
attribute :city_tax_rate, :float
|
15
|
+
attribute :special_district_amount, :float
|
16
|
+
attribute :special_tax_rate, :float
|
9
17
|
end
|
10
18
|
end
|
data/lib/taxjar/tax.rb
CHANGED
@@ -2,10 +2,17 @@ require 'taxjar/base'
|
|
2
2
|
|
3
3
|
module Taxjar
|
4
4
|
class Tax < Taxjar::Base
|
5
|
-
|
6
|
-
|
5
|
+
extend ModelAttribute
|
6
|
+
|
7
|
+
attribute :order_total_amount, :float
|
8
|
+
attribute :shipping, :float
|
9
|
+
attribute :taxable_amount, :float
|
10
|
+
attribute :amount_to_collect, :float
|
11
|
+
attribute :rate, :float
|
12
|
+
attribute :has_nexus, :boolean
|
13
|
+
attribute :freight_taxable, :boolean
|
14
|
+
attribute :tax_source, :string
|
7
15
|
|
8
16
|
object_attr_reader Taxjar::Breakdown, :breakdown
|
9
|
-
|
10
17
|
end
|
11
18
|
end
|
data/lib/taxjar/version.rb
CHANGED
data/spec/helper.rb
CHANGED
data/spec/taxjar/api/api_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
describe Taxjar::API do
|
4
|
-
|
5
4
|
before do
|
6
5
|
@client = Taxjar::Client.new(api_key: 'AK')
|
7
6
|
end
|
@@ -23,6 +22,8 @@ describe Taxjar::API do
|
|
23
22
|
expect(categories).to be_an Array
|
24
23
|
expect(categories.first).to be_a Taxjar::Category
|
25
24
|
expect(categories.first.name).to eq('Digital Goods')
|
25
|
+
expect(categories.first.product_tax_code).to eq('31000')
|
26
|
+
expect(categories.first.description).to eq('Digital products transferred electronically, meaning obtained by the purchaser by means other than tangible storage media.')
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -42,7 +43,15 @@ describe Taxjar::API do
|
|
42
43
|
it 'returns the requested rates' do
|
43
44
|
rates = @client.rates_for_location(@postal_code)
|
44
45
|
expect(rates).to be_a Taxjar::Rate
|
46
|
+
expect(rates.zip).to eq('90002')
|
47
|
+
expect(rates.state).to eq('CA')
|
48
|
+
expect(rates.state_rate).to eq(0.065)
|
45
49
|
expect(rates.county).to eq('LOS ANGELES')
|
50
|
+
expect(rates.county_rate).to eq(0.01)
|
51
|
+
expect(rates.city).to eq('WATTS')
|
52
|
+
expect(rates.city_rate).to eq(0.0)
|
53
|
+
expect(rates.combined_district_rate).to eq(0.015)
|
54
|
+
expect(rates.combined_rate).to eq(0.09)
|
46
55
|
end
|
47
56
|
end
|
48
57
|
|
@@ -71,12 +80,48 @@ describe Taxjar::API do
|
|
71
80
|
it 'returns the requested taxes' do
|
72
81
|
tax = @client.tax_for_order(@order)
|
73
82
|
expect(tax).to be_a Taxjar::Tax
|
83
|
+
expect(tax.order_total_amount).to eq(16.5)
|
84
|
+
expect(tax.amount_to_collect).to eq(1.16)
|
85
|
+
expect(tax.has_nexus).to eq(true)
|
86
|
+
expect(tax.freight_taxable).to eq(true)
|
74
87
|
expect(tax.tax_source).to eq('destination')
|
75
88
|
end
|
89
|
+
|
90
|
+
it 'allows access to breakdown' do
|
91
|
+
tax = @client.tax_for_order(@order)
|
92
|
+
expect(tax.breakdown.state_taxable_amount).to eq(16.5)
|
93
|
+
expect(tax.breakdown.state_tax_collectable).to eq(1.16)
|
94
|
+
expect(tax.breakdown.county_taxable_amount).to eq(0)
|
95
|
+
expect(tax.breakdown.county_tax_collectable).to eq(0)
|
96
|
+
expect(tax.breakdown.city_taxable_amount).to eq(0)
|
97
|
+
expect(tax.breakdown.city_tax_collectable).to eq(0)
|
98
|
+
expect(tax.breakdown.special_district_taxable_amount).to eq(0)
|
99
|
+
expect(tax.breakdown.special_district_tax_collectable).to eq(0)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'allows access to breakdown.shipping' do
|
103
|
+
tax = @client.tax_for_order(@order)
|
104
|
+
expect(tax.breakdown.shipping.state_amount).to eq(0.11)
|
105
|
+
expect(tax.breakdown.shipping.state_sales_tax_rate).to eq(0.07)
|
106
|
+
expect(tax.breakdown.shipping.county_amount).to eq(0)
|
107
|
+
expect(tax.breakdown.shipping.county_tax_rate).to eq(0)
|
108
|
+
expect(tax.breakdown.shipping.city_amount).to eq(0)
|
109
|
+
expect(tax.breakdown.shipping.city_tax_rate).to eq(0)
|
110
|
+
expect(tax.breakdown.shipping.special_district_amount).to eq(0)
|
111
|
+
expect(tax.breakdown.shipping.special_tax_rate).to eq(0)
|
112
|
+
end
|
76
113
|
|
77
114
|
it 'allows access to breakdown.line_items' do
|
78
115
|
tax = @client.tax_for_order(@order)
|
79
116
|
expect(tax.breakdown.line_items[0].id).to eq(1)
|
117
|
+
expect(tax.breakdown.line_items[0].state_taxable_amount).to eq(15)
|
118
|
+
expect(tax.breakdown.line_items[0].state_sales_tax_rate).to eq(0.07)
|
119
|
+
expect(tax.breakdown.line_items[0].county_taxable_amount).to eq(0)
|
120
|
+
expect(tax.breakdown.line_items[0].county_tax_rate).to eq(0)
|
121
|
+
expect(tax.breakdown.line_items[0].city_taxable_amount).to eq(0)
|
122
|
+
expect(tax.breakdown.line_items[0].city_tax_rate).to eq(0)
|
123
|
+
expect(tax.breakdown.line_items[0].special_district_taxable_amount).to eq(0)
|
124
|
+
expect(tax.breakdown.line_items[0].special_tax_rate).to eq(0)
|
80
125
|
end
|
81
126
|
end
|
82
127
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
describe Taxjar::API::Order do
|
4
|
-
|
5
4
|
before do
|
6
5
|
@client = Taxjar::Client.new(api_key: 'AK')
|
7
6
|
end
|
@@ -66,12 +65,27 @@ describe Taxjar::API::Order do
|
|
66
65
|
it 'returns the requested order' do
|
67
66
|
order = @client.show_order('123')
|
68
67
|
expect(order).to be_an Taxjar::Order
|
69
|
-
expect(order.transaction_id).to eq(123)
|
68
|
+
expect(order.transaction_id).to eq('123')
|
69
|
+
expect(order.user_id).to eq(10649)
|
70
|
+
expect(order.transaction_date).to eq('2015-05-14T00:00:00Z')
|
71
|
+
expect(order.to_country).to eq('US')
|
72
|
+
expect(order.to_zip).to eq('90002')
|
73
|
+
expect(order.to_state).to eq('CA')
|
74
|
+
expect(order.to_city).to eq('LOS ANGELES')
|
75
|
+
expect(order.to_street).to eq('123 Palm Grove Ln')
|
76
|
+
expect(order.amount).to eq(17.45)
|
77
|
+
expect(order.shipping).to eq(1.5)
|
78
|
+
expect(order.sales_tax).to eq(0.95)
|
70
79
|
end
|
71
80
|
|
72
81
|
it 'allows access to line_items' do
|
73
82
|
order = @client.show_order('123')
|
83
|
+
expect(order.line_items[0].id).to eq(1)
|
74
84
|
expect(order.line_items[0].quantity).to eq(1)
|
85
|
+
expect(order.line_items[0].product_identifier).to eq('12-34243-9')
|
86
|
+
expect(order.line_items[0].description).to eq('Fuzzy Widget')
|
87
|
+
expect(order.line_items[0].unit_price).to eq(15.0)
|
88
|
+
expect(order.line_items[0].sales_tax).to eq(0.95)
|
75
89
|
end
|
76
90
|
end
|
77
91
|
|
@@ -89,9 +103,10 @@ describe Taxjar::API::Order do
|
|
89
103
|
:amount => 17.45,
|
90
104
|
:shipping => 1.5,
|
91
105
|
:sales_tax => 0.95,
|
92
|
-
:line_items => [{:
|
106
|
+
:line_items => [{:id => 1,
|
107
|
+
:quantity => 1,
|
93
108
|
:product_identifier => '12-34243-9',
|
94
|
-
:
|
109
|
+
:description => 'Fuzzy Widget',
|
95
110
|
:unit_price => 15.0,
|
96
111
|
:sales_tax => 0.95}]
|
97
112
|
}
|
@@ -105,7 +120,27 @@ describe Taxjar::API::Order do
|
|
105
120
|
it 'returns the created order' do
|
106
121
|
order = @client.create_order(@order)
|
107
122
|
expect(order).to be_a Taxjar::Order
|
108
|
-
expect(order.transaction_id).to eq(123)
|
123
|
+
expect(order.transaction_id).to eq('123')
|
124
|
+
expect(order.user_id).to eq(10649)
|
125
|
+
expect(order.transaction_date).to eq("2015-05-14T00:00:00Z")
|
126
|
+
expect(order.to_country).to eq('US')
|
127
|
+
expect(order.to_zip).to eq('90002')
|
128
|
+
expect(order.to_state).to eq('CA')
|
129
|
+
expect(order.to_city).to eq('LOS ANGELES')
|
130
|
+
expect(order.to_street).to eq('123 Palm Grove Ln')
|
131
|
+
expect(order.amount).to eq(17.45)
|
132
|
+
expect(order.shipping).to eq(1.5)
|
133
|
+
expect(order.sales_tax).to eq(0.95)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'allows access to line_items' do
|
137
|
+
order = @client.create_order(@order)
|
138
|
+
expect(order.line_items[0].id).to eq(1)
|
139
|
+
expect(order.line_items[0].quantity).to eq(1)
|
140
|
+
expect(order.line_items[0].product_identifier).to eq('12-34243-9')
|
141
|
+
expect(order.line_items[0].description).to eq('Fuzzy Widget')
|
142
|
+
expect(order.line_items[0].unit_price).to eq(15.0)
|
143
|
+
expect(order.line_items[0].sales_tax).to eq(0.95)
|
109
144
|
end
|
110
145
|
end
|
111
146
|
|
@@ -118,9 +153,10 @@ describe Taxjar::API::Order do
|
|
118
153
|
@order = {:transaction_id => '123',
|
119
154
|
:amount => 17.95,
|
120
155
|
:shipping => 2.0,
|
121
|
-
:line_items => [{:
|
156
|
+
:line_items => [{:id => 1,
|
157
|
+
:quantity => 1,
|
122
158
|
:product_identifier => '12-34243-0',
|
123
|
-
:
|
159
|
+
:description => 'Heavy Widget',
|
124
160
|
:unit_price => 15.0,
|
125
161
|
:discount => 0.0,
|
126
162
|
:sales_tax => 0.95}]
|
@@ -135,7 +171,27 @@ describe Taxjar::API::Order do
|
|
135
171
|
it 'returns the updated order' do
|
136
172
|
order = @client.update_order(@order)
|
137
173
|
expect(order).to be_a Taxjar::Order
|
138
|
-
expect(order.transaction_id).to eq(123)
|
174
|
+
expect(order.transaction_id).to eq('123')
|
175
|
+
expect(order.user_id).to eq(10649)
|
176
|
+
expect(order.transaction_date).to eq("2015-05-14T00:00:00Z")
|
177
|
+
expect(order.to_country).to eq('US')
|
178
|
+
expect(order.to_zip).to eq('90002')
|
179
|
+
expect(order.to_state).to eq('CA')
|
180
|
+
expect(order.to_city).to eq('LOS ANGELES')
|
181
|
+
expect(order.to_street).to eq('123 Palm Grove Ln')
|
182
|
+
expect(order.amount).to eq(17.45)
|
183
|
+
expect(order.shipping).to eq(1.5)
|
184
|
+
expect(order.sales_tax).to eq(0.95)
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'allows access to line_items' do
|
188
|
+
order = @client.update_order(@order)
|
189
|
+
expect(order.line_items[0].id).to eq(1)
|
190
|
+
expect(order.line_items[0].quantity).to eq(1)
|
191
|
+
expect(order.line_items[0].product_identifier).to eq('12-34243-9')
|
192
|
+
expect(order.line_items[0].description).to eq('Fuzzy Widget')
|
193
|
+
expect(order.line_items[0].unit_price).to eq(15.0)
|
194
|
+
expect(order.line_items[0].sales_tax).to eq(0.95)
|
139
195
|
end
|
140
196
|
end
|
141
197
|
|
@@ -154,7 +210,27 @@ describe Taxjar::API::Order do
|
|
154
210
|
it 'returns the deleted order' do
|
155
211
|
order = @client.delete_order('123')
|
156
212
|
expect(order).to be_an Taxjar::Order
|
157
|
-
expect(order.transaction_id).to eq(123)
|
213
|
+
expect(order.transaction_id).to eq('123')
|
214
|
+
expect(order.user_id).to eq(10649)
|
215
|
+
expect(order.transaction_date).to eq("2015-05-14T00:00:00Z")
|
216
|
+
expect(order.to_country).to eq('US')
|
217
|
+
expect(order.to_zip).to eq('90002')
|
218
|
+
expect(order.to_state).to eq('CA')
|
219
|
+
expect(order.to_city).to eq('LOS ANGELES')
|
220
|
+
expect(order.to_street).to eq('123 Palm Grove Ln')
|
221
|
+
expect(order.amount).to eq(17.45)
|
222
|
+
expect(order.shipping).to eq(1.5)
|
223
|
+
expect(order.sales_tax).to eq(0.95)
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'allows access to line items' do
|
227
|
+
order = @client.delete_order('123')
|
228
|
+
expect(order.line_items[0].id).to eq(1)
|
229
|
+
expect(order.line_items[0].quantity).to eq(1)
|
230
|
+
expect(order.line_items[0].product_identifier).to eq('12-34243-9')
|
231
|
+
expect(order.line_items[0].description).to eq('Fuzzy Widget')
|
232
|
+
expect(order.line_items[0].unit_price).to eq(15.0)
|
233
|
+
expect(order.line_items[0].sales_tax).to eq(0.95)
|
158
234
|
end
|
159
235
|
end
|
160
236
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
describe Taxjar::API::Refund do
|
4
|
-
|
5
4
|
before do
|
6
5
|
@client = Taxjar::Client.new(api_key: 'AK')
|
7
6
|
end
|
@@ -66,12 +65,29 @@ describe Taxjar::API::Refund do
|
|
66
65
|
it 'returns the requested refund' do
|
67
66
|
refund = @client.show_refund('321')
|
68
67
|
expect(refund).to be_an Taxjar::Refund
|
69
|
-
expect(refund.transaction_id).to eq(321)
|
68
|
+
expect(refund.transaction_id).to eq('321')
|
69
|
+
expect(refund.user_id).to eq(10649)
|
70
|
+
expect(refund.transaction_date).to eq("2015-05-14T00:00:00Z")
|
71
|
+
expect(refund.transaction_reference_id).to eq("123")
|
72
|
+
expect(refund.to_country).to eq('US')
|
73
|
+
expect(refund.to_zip).to eq('90002')
|
74
|
+
expect(refund.to_state).to eq('CA')
|
75
|
+
expect(refund.to_city).to eq('LOS ANGELES')
|
76
|
+
expect(refund.to_street).to eq('123 Palm Grove Ln')
|
77
|
+
expect(refund.amount).to eq(17.45)
|
78
|
+
expect(refund.shipping).to eq(1.5)
|
79
|
+
expect(refund.sales_tax).to eq(0.95)
|
70
80
|
end
|
71
81
|
|
72
82
|
it 'allows access to line_items' do
|
73
83
|
refund = @client.show_refund('321')
|
84
|
+
expect(refund.line_items[0].id).to eq(1)
|
74
85
|
expect(refund.line_items[0].quantity).to eq(1)
|
86
|
+
expect(refund.line_items[0].product_identifier).to eq('12-34243-9')
|
87
|
+
expect(refund.line_items[0].description).to eq('Fuzzy Widget')
|
88
|
+
expect(refund.line_items[0].unit_price).to eq(15.0)
|
89
|
+
expect(refund.line_items[0].discount).to eq(0.0)
|
90
|
+
expect(refund.line_items[0].sales_tax).to eq(0.95)
|
75
91
|
end
|
76
92
|
end
|
77
93
|
|
@@ -93,7 +109,7 @@ describe Taxjar::API::Refund do
|
|
93
109
|
:sales_tax => 0.95,
|
94
110
|
:line_items => [{:quantity => 1,
|
95
111
|
:product_identifier => '12-34243-9',
|
96
|
-
:
|
112
|
+
:description => 'Fuzzy Widget',
|
97
113
|
:unit_price => 15.0,
|
98
114
|
:sales_tax => 0.95}]
|
99
115
|
}
|
@@ -105,9 +121,31 @@ describe Taxjar::API::Refund do
|
|
105
121
|
end
|
106
122
|
|
107
123
|
it 'returns the created refund' do
|
108
|
-
refund
|
124
|
+
refund = @client.create_refund(@refund)
|
109
125
|
expect(refund).to be_a Taxjar::Refund
|
110
|
-
expect(refund.transaction_id).to eq(321)
|
126
|
+
expect(refund.transaction_id).to eq('321')
|
127
|
+
expect(refund.user_id).to eq(10649)
|
128
|
+
expect(refund.transaction_date).to eq("2015-05-14T00:00:00Z")
|
129
|
+
expect(refund.transaction_reference_id).to eq("123")
|
130
|
+
expect(refund.to_country).to eq('US')
|
131
|
+
expect(refund.to_zip).to eq('90002')
|
132
|
+
expect(refund.to_state).to eq('CA')
|
133
|
+
expect(refund.to_city).to eq('LOS ANGELES')
|
134
|
+
expect(refund.to_street).to eq('123 Palm Grove Ln')
|
135
|
+
expect(refund.amount).to eq(17.45)
|
136
|
+
expect(refund.shipping).to eq(1.5)
|
137
|
+
expect(refund.sales_tax).to eq(0.95)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'allows access to line_items' do
|
141
|
+
refund = @client.create_refund(@refund)
|
142
|
+
expect(refund.line_items[0].id).to eq(1)
|
143
|
+
expect(refund.line_items[0].quantity).to eq(1)
|
144
|
+
expect(refund.line_items[0].product_identifier).to eq('12-34243-9')
|
145
|
+
expect(refund.line_items[0].description).to eq('Fuzzy Widget')
|
146
|
+
expect(refund.line_items[0].unit_price).to eq(15.0)
|
147
|
+
expect(refund.line_items[0].discount).to eq(0.0)
|
148
|
+
expect(refund.line_items[0].sales_tax).to eq(0.95)
|
111
149
|
end
|
112
150
|
end
|
113
151
|
|
@@ -123,7 +161,7 @@ describe Taxjar::API::Refund do
|
|
123
161
|
:sales_tax => 0.95,
|
124
162
|
:line_items => [{:quantity => 1,
|
125
163
|
:product_identifier => '12-34243-9',
|
126
|
-
:
|
164
|
+
:description => 'Heavy Widget',
|
127
165
|
:unit_price => 15.0,
|
128
166
|
:sales_tax => 0.95}]
|
129
167
|
}
|
@@ -137,7 +175,29 @@ describe Taxjar::API::Refund do
|
|
137
175
|
it 'returns the updated refund' do
|
138
176
|
refund = @client.update_refund(@refund)
|
139
177
|
expect(refund).to be_a Taxjar::Refund
|
140
|
-
expect(refund.transaction_id).to eq(321)
|
178
|
+
expect(refund.transaction_id).to eq('321')
|
179
|
+
expect(refund.user_id).to eq(10649)
|
180
|
+
expect(refund.transaction_date).to eq("2015-05-14T00:00:00Z")
|
181
|
+
expect(refund.transaction_reference_id).to eq("123")
|
182
|
+
expect(refund.to_country).to eq('US')
|
183
|
+
expect(refund.to_zip).to eq('90002')
|
184
|
+
expect(refund.to_state).to eq('CA')
|
185
|
+
expect(refund.to_city).to eq('LOS ANGELES')
|
186
|
+
expect(refund.to_street).to eq('123 Palm Grove Ln')
|
187
|
+
expect(refund.amount).to eq(17.45)
|
188
|
+
expect(refund.shipping).to eq(1.5)
|
189
|
+
expect(refund.sales_tax).to eq(0.95)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'allows access to line_items' do
|
193
|
+
refund = @client.update_refund(@refund)
|
194
|
+
expect(refund.line_items[0].id).to eq(1)
|
195
|
+
expect(refund.line_items[0].quantity).to eq(1)
|
196
|
+
expect(refund.line_items[0].product_identifier).to eq('12-34243-9')
|
197
|
+
expect(refund.line_items[0].description).to eq('Fuzzy Widget')
|
198
|
+
expect(refund.line_items[0].unit_price).to eq(15.0)
|
199
|
+
expect(refund.line_items[0].discount).to eq(0.0)
|
200
|
+
expect(refund.line_items[0].sales_tax).to eq(0.95)
|
141
201
|
end
|
142
202
|
end
|
143
203
|
|
@@ -156,7 +216,29 @@ describe Taxjar::API::Refund do
|
|
156
216
|
it 'returns the delete refund' do
|
157
217
|
refund = @client.delete_refund('321')
|
158
218
|
expect(refund).to be_an Taxjar::Refund
|
159
|
-
expect(refund.transaction_id).to eq(321)
|
219
|
+
expect(refund.transaction_id).to eq('321')
|
220
|
+
expect(refund.user_id).to eq(10649)
|
221
|
+
expect(refund.transaction_date).to eq("2015-05-14T00:00:00Z")
|
222
|
+
expect(refund.transaction_reference_id).to eq("123")
|
223
|
+
expect(refund.to_country).to eq('US')
|
224
|
+
expect(refund.to_zip).to eq('90002')
|
225
|
+
expect(refund.to_state).to eq('CA')
|
226
|
+
expect(refund.to_city).to eq('LOS ANGELES')
|
227
|
+
expect(refund.to_street).to eq('123 Palm Grove Ln')
|
228
|
+
expect(refund.amount).to eq(17.45)
|
229
|
+
expect(refund.shipping).to eq(1.5)
|
230
|
+
expect(refund.sales_tax).to eq(0.95)
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'allows access to line_items' do
|
234
|
+
refund = @client.delete_refund('321')
|
235
|
+
expect(refund.line_items[0].id).to eq(1)
|
236
|
+
expect(refund.line_items[0].quantity).to eq(1)
|
237
|
+
expect(refund.line_items[0].product_identifier).to eq('12-34243-9')
|
238
|
+
expect(refund.line_items[0].description).to eq('Fuzzy Widget')
|
239
|
+
expect(refund.line_items[0].unit_price).to eq(15.0)
|
240
|
+
expect(refund.line_items[0].discount).to eq(0.0)
|
241
|
+
expect(refund.line_items[0].sales_tax).to eq(0.95)
|
160
242
|
end
|
161
243
|
end
|
162
244
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
describe Taxjar::API::Request do
|
4
|
-
|
5
4
|
describe "#BASE_URL" do
|
6
5
|
it 'should have taxjar api url' do
|
7
6
|
expect(Taxjar::API::Request::BASE_URL).to eq('https://api.taxjar.com')
|
@@ -130,5 +129,4 @@ describe Taxjar::API::Request do
|
|
130
129
|
end
|
131
130
|
end
|
132
131
|
end
|
133
|
-
|
134
132
|
end
|
data/spec/taxjar/client_spec.rb
CHANGED
data/spec/taxjar/error_spec.rb
CHANGED
data/taxjar-ruby.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'addressable', '~>2.3'
|
22
22
|
spec.add_dependency 'http', '~>0.8.12'
|
23
23
|
spec.add_dependency 'memoizable', '~>0.4.0'
|
24
|
+
spec.add_dependency 'taxjar-model_attribute', '~> 3.1'
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taxjar-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TaxJar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.4.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: taxjar-model_attribute
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,7 +140,6 @@ files:
|
|
126
140
|
- spec/taxjar/api/order_spec.rb
|
127
141
|
- spec/taxjar/api/refund_spec.rb
|
128
142
|
- spec/taxjar/api/request_spec.rb
|
129
|
-
- spec/taxjar/base_spec.rb
|
130
143
|
- spec/taxjar/client_spec.rb
|
131
144
|
- spec/taxjar/error_spec.rb
|
132
145
|
- spec/taxjar/version_spec.rb
|
@@ -168,7 +181,6 @@ test_files:
|
|
168
181
|
- spec/taxjar/api/order_spec.rb
|
169
182
|
- spec/taxjar/api/refund_spec.rb
|
170
183
|
- spec/taxjar/api/request_spec.rb
|
171
|
-
- spec/taxjar/base_spec.rb
|
172
184
|
- spec/taxjar/client_spec.rb
|
173
185
|
- spec/taxjar/error_spec.rb
|
174
186
|
- spec/taxjar/version_spec.rb
|
data/spec/taxjar/base_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
describe Taxjar::Base do
|
6
|
-
|
7
|
-
describe "#initialize" do
|
8
|
-
before do
|
9
|
-
@klass = Class.new(Taxjar::Base)
|
10
|
-
@klass.attr_reader(:field)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should convert string fields to floats if it can be done' do
|
14
|
-
b = @klass.new(:field => '3.0')
|
15
|
-
expect(b.field).to eq(3.0)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should convert string fields to integers if it can be done' do
|
19
|
-
b = @klass.new(:field => '3')
|
20
|
-
expect(b.field).to eq(3)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'it should leave string as strings' do
|
24
|
-
b = @klass.new(:field => 'a')
|
25
|
-
expect(b.field).to eq('a')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|