quandl_client 0.0.15 → 0.0.16
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/lib/quandl/client/concerns/properties.rb +4 -0
- data/lib/quandl/client/version.rb +1 -1
- data/quandl_client.gemspec +1 -0
- data/spec/factories/dataset.rb +10 -0
- data/spec/factories/source.rb +10 -0
- data/spec/{quandl_client.rb → quandl/client/client_spec.rb} +0 -0
- data/spec/quandl/client/models/dataset_spec.rb +77 -0
- data/spec/quandl/client/models/source_spec.rb +51 -0
- data/spec/spec_helper.rb +12 -1
- metadata +27 -3
data/quandl_client.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_development_dependency "rake", "~> 10.0"
|
21
21
|
s.add_development_dependency "rspec", "~> 2.13"
|
22
|
+
s.add_development_dependency "factory_girl_rails"
|
22
23
|
s.add_development_dependency "fivemat", "~> 1.2"
|
23
24
|
s.add_development_dependency "pry"
|
24
25
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
|
3
|
+
factory :source do
|
4
|
+
sequence(:code) { |n| "QUANDL_CLIENT_#{(Time.now.to_f * 1000).to_i}_#{n}" }
|
5
|
+
name "Quandl Client Source"
|
6
|
+
description "Quandl Client Source Spec"
|
7
|
+
sequence(:host) { |n| "http://quandl.com/host/#{(Time.now.to_f * 1000).to_i}_#{n}" }
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
File without changes
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Dataset do
|
5
|
+
|
6
|
+
describe "#update" do
|
7
|
+
|
8
|
+
before(:all){ Quandl::Client.token = '93yzptKyhdkrqLhmezdi' }
|
9
|
+
|
10
|
+
let(:source){ create(:source) }
|
11
|
+
let(:dataset){ create(:dataset, source_code: source.code ) }
|
12
|
+
|
13
|
+
it "should update with data" do
|
14
|
+
rdataset = Dataset.find(dataset.id)
|
15
|
+
data = Quandl::Data::Random.table(rows: 100, columns: 4)
|
16
|
+
rdataset.data = data.to_csv
|
17
|
+
rdataset.save
|
18
|
+
Dataset.find(dataset.id).data_table.to_date.count.should eq data.to_date.count
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#find" do
|
24
|
+
|
25
|
+
before(:all){ Quandl::Client.token = '93yzptKyhdkrqLhmezdi' }
|
26
|
+
|
27
|
+
let(:source){ create(:source) }
|
28
|
+
let(:dataset){ create(:dataset, source_code: source.code ) }
|
29
|
+
|
30
|
+
it "should find the dataset by id" do
|
31
|
+
Dataset.find(dataset.id).id.should eq dataset.id
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should find the dataset by full code" do
|
35
|
+
Dataset.find(dataset.full_code).id.should eq dataset.id
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#new" do
|
41
|
+
|
42
|
+
subject{ build(:dataset) }
|
43
|
+
|
44
|
+
its(:valid?){ should be_true }
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#save" do
|
49
|
+
|
50
|
+
context "without token" do
|
51
|
+
|
52
|
+
before(:all){ Quandl::Client.token = '' }
|
53
|
+
|
54
|
+
let(:dataset){ create(:dataset) }
|
55
|
+
subject{ dataset }
|
56
|
+
|
57
|
+
its(:saved?){ should be_false }
|
58
|
+
its(:status){ should eq 401 }
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
context "with token" do
|
63
|
+
|
64
|
+
before(:all){ Quandl::Client.token = '93yzptKyhdkrqLhmezdi' }
|
65
|
+
|
66
|
+
let(:source){ create(:source) }
|
67
|
+
let(:dataset){ create(:dataset, source_code: source.code ) }
|
68
|
+
subject{ dataset }
|
69
|
+
|
70
|
+
its(:saved?){ should be_true }
|
71
|
+
its(:status){ should eq 201 }
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Source do
|
5
|
+
|
6
|
+
let(:source){ build(:source) }
|
7
|
+
|
8
|
+
context "without token" do
|
9
|
+
|
10
|
+
before(:all){ Quandl::Client.token = '' }
|
11
|
+
|
12
|
+
subject{ source }
|
13
|
+
its(:valid?){ should be_true }
|
14
|
+
|
15
|
+
describe "#save" do
|
16
|
+
|
17
|
+
it "should not be authorized to create a source" do
|
18
|
+
source.save
|
19
|
+
source.status.should eq 401
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with token" do
|
27
|
+
|
28
|
+
before(:all){ Quandl::Client.token = '93yzptKyhdkrqLhmezdi' }
|
29
|
+
|
30
|
+
describe "#save" do
|
31
|
+
|
32
|
+
it "should save the source" do
|
33
|
+
source.save
|
34
|
+
source.status.should eq 201
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should update the source" do
|
38
|
+
source.save
|
39
|
+
retrieved_source = Source.find(source.id)
|
40
|
+
retrieved_source.description = "something new #{Time.now}"
|
41
|
+
retrieved_source.save
|
42
|
+
Source.find(source.id).description.should eq retrieved_source.description
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
2
2
|
|
3
3
|
require "rspec"
|
4
|
-
require
|
4
|
+
require 'factory_girl'
|
5
|
+
|
6
|
+
factory_dir = File.join( File.dirname(__FILE__), 'factories/**/*.rb' )
|
7
|
+
Dir.glob( factory_dir ).each{|f| require(f); puts f }
|
8
|
+
|
9
|
+
require "quandl/client"
|
10
|
+
|
11
|
+
include Quandl::Client
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.include FactoryGirl::Syntax::Methods
|
15
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: quandl_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.16
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Blkae Hilscher
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
version: '2.13'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: factory_girl_rails
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: fivemat
|
48
64
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -202,7 +218,11 @@ files:
|
|
202
218
|
- lib/quandl/client/version.rb
|
203
219
|
- lib/quandl/her/patch.rb
|
204
220
|
- quandl_client.gemspec
|
205
|
-
- spec/
|
221
|
+
- spec/factories/dataset.rb
|
222
|
+
- spec/factories/source.rb
|
223
|
+
- spec/quandl/client/client_spec.rb
|
224
|
+
- spec/quandl/client/models/dataset_spec.rb
|
225
|
+
- spec/quandl/client/models/source_spec.rb
|
206
226
|
- spec/spec_helper.rb
|
207
227
|
homepage: http://blake.hilscher.ca/
|
208
228
|
licenses:
|
@@ -230,5 +250,9 @@ signing_key:
|
|
230
250
|
specification_version: 3
|
231
251
|
summary: Client rest orm.
|
232
252
|
test_files:
|
233
|
-
- spec/
|
253
|
+
- spec/factories/dataset.rb
|
254
|
+
- spec/factories/source.rb
|
255
|
+
- spec/quandl/client/client_spec.rb
|
256
|
+
- spec/quandl/client/models/dataset_spec.rb
|
257
|
+
- spec/quandl/client/models/source_spec.rb
|
234
258
|
- spec/spec_helper.rb
|