quandl_client 2.7.11 → 2.7.12

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.
Files changed (57) hide show
  1. data/.gitignore +7 -7
  2. data/.rspec +1 -1
  3. data/.travis.yml +20 -20
  4. data/.yardopts +2 -2
  5. data/Gemfile +12 -12
  6. data/Guardfile +8 -8
  7. data/LICENSE +7 -7
  8. data/README.md +303 -303
  9. data/Rakefile +31 -31
  10. data/UPGRADE.md +220 -214
  11. data/VERSION +1 -1
  12. data/examples/create.rb +32 -32
  13. data/examples/find.rb +17 -17
  14. data/examples/login.rb +12 -12
  15. data/examples/search.rb +12 -12
  16. data/examples/trims.rb +15 -15
  17. data/lib/quandl/client/base/attributes.rb +15 -15
  18. data/lib/quandl/client/base/model.rb +40 -40
  19. data/lib/quandl/client/base/search.rb +74 -74
  20. data/lib/quandl/client/base/validation.rb +103 -101
  21. data/lib/quandl/client/base.rb +91 -91
  22. data/lib/quandl/client/middleware/parse_json.rb +87 -85
  23. data/lib/quandl/client/middleware.rb +9 -9
  24. data/lib/quandl/client/models/dataset/data.rb +57 -57
  25. data/lib/quandl/client/models/dataset.rb +269 -269
  26. data/lib/quandl/client/models/location.rb +10 -10
  27. data/lib/quandl/client/models/report.rb +14 -14
  28. data/lib/quandl/client/models/scraper.rb +16 -16
  29. data/lib/quandl/client/models/sheet.rb +50 -50
  30. data/lib/quandl/client/models/source.rb +48 -48
  31. data/lib/quandl/client/models/superset.rb +65 -65
  32. data/lib/quandl/client/models/user.rb +7 -7
  33. data/lib/quandl/client/version.rb +14 -14
  34. data/lib/quandl/client.rb +54 -53
  35. data/lib/quandl/her/collection.rb +18 -0
  36. data/lib/quandl/her/remove_method_data.rb +8 -8
  37. data/lib/quandl/pattern/client.rb +8 -8
  38. data/lib/quandl/pattern.rb +37 -37
  39. data/quandl_client.gemspec +33 -33
  40. data/spec/factories/dataset.rb +10 -10
  41. data/spec/factories/sheet.rb +7 -7
  42. data/spec/factories/source.rb +9 -9
  43. data/spec/fixtures/scraper.rb +5 -5
  44. data/spec/lib/quandl/client/dataset/attributes_spec.rb +63 -63
  45. data/spec/lib/quandl/client/dataset/data_spec.rb +92 -92
  46. data/spec/lib/quandl/client/dataset/location_spec.rb +65 -65
  47. data/spec/lib/quandl/client/dataset/persistence_spec.rb +104 -104
  48. data/spec/lib/quandl/client/dataset/search_spec.rb +19 -19
  49. data/spec/lib/quandl/client/dataset/source_spec.rb +47 -47
  50. data/spec/lib/quandl/client/dataset/trim_spec.rb +35 -35
  51. data/spec/lib/quandl/client/dataset/validation_spec.rb +68 -68
  52. data/spec/lib/quandl/client/dataset_spec.rb +57 -57
  53. data/spec/lib/quandl/client/scraper_spec.rb +71 -71
  54. data/spec/lib/quandl/client/sheet_spec.rb +37 -37
  55. data/spec/lib/quandl/client/source_spec.rb +51 -51
  56. data/spec/spec_helper.rb +30 -30
  57. metadata +28 -4
@@ -1,34 +1,34 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "quandl/client/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "quandl_client"
7
- s.version = Quandl::Client::VERSION
8
- s.authors = ["Blake Hilscher"]
9
- s.email = ["blake@hilscher.ca"]
10
- s.homepage = "http://blake.hilscher.ca/"
11
- s.license = "MIT"
12
- s.summary = "Client rest orm."
13
- s.description = "An orm for the cassinatra rest interface."
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
19
-
20
- s.add_runtime_dependency "quandl_data", "~> 1.4"
21
- s.add_runtime_dependency "activesupport", ">= 3.0.0"
22
- s.add_runtime_dependency "her", "~> 0.6"
23
- s.add_runtime_dependency 'json', '~> 1.7.7'
24
- s.add_runtime_dependency "scope_composer", "~> 0.3"
25
-
26
- s.add_development_dependency "rake", "~> 10.0"
27
- s.add_development_dependency "rspec", "~> 2.13"
28
- s.add_development_dependency "factory_girl_rails"
29
- s.add_development_dependency "fivemat", "~> 1.2"
30
- s.add_development_dependency "pry"
31
- s.add_development_dependency "guard"
32
- s.add_development_dependency "guard-rspec"
33
- s.add_development_dependency "quandl_utility"
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "quandl/client/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "quandl_client"
7
+ s.version = Quandl::Client::VERSION
8
+ s.authors = ["Blake Hilscher"]
9
+ s.email = ["blake@hilscher.ca"]
10
+ s.homepage = "http://blake.hilscher.ca/"
11
+ s.license = "MIT"
12
+ s.summary = "Client rest orm."
13
+ s.description = "An orm for the cassinatra rest interface."
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_runtime_dependency "quandl_data", "~> 1.4"
21
+ s.add_runtime_dependency "activesupport", ">= 3.0.0"
22
+ s.add_runtime_dependency "her", "~> 0.6"
23
+ s.add_runtime_dependency 'json', '~> 1.7.7'
24
+ s.add_runtime_dependency "scope_composer", "~> 0.3"
25
+
26
+ s.add_development_dependency "rake", "~> 10.0"
27
+ s.add_development_dependency "rspec", "~> 2.13"
28
+ s.add_development_dependency "factory_girl_rails"
29
+ s.add_development_dependency "fivemat", "~> 1.2"
30
+ s.add_development_dependency "pry"
31
+ s.add_development_dependency "guard"
32
+ s.add_development_dependency "guard-rspec"
33
+ s.add_development_dependency "quandl_utility"
34
34
  end
@@ -1,11 +1,11 @@
1
- FactoryGirl.define do
2
-
3
- factory :dataset do
4
- source_code "QUANDL_CLIENT_TEST_SOURCE"
5
- sequence(:code) { |n| "QUANDL_CLIENT_#{(Time.now.to_f * 1000).to_i}_#{n}" }
6
- name "Quandl Client Dataset"
7
- description "Quandl Client Dataset Spec"
8
- # column_names ['Date', "Column 1", "Column 2"]
9
- end
10
-
1
+ FactoryGirl.define do
2
+
3
+ factory :dataset do
4
+ source_code "QUANDL_CLIENT_TEST_SOURCE"
5
+ sequence(:code) { |n| "QUANDL_CLIENT_#{(Time.now.to_f * 1000).to_i}_#{n}" }
6
+ name "Quandl Client Dataset"
7
+ description "Quandl Client Dataset Spec"
8
+ # column_names ['Date', "Column 1", "Column 2"]
9
+ end
10
+
11
11
  end
@@ -1,8 +1,8 @@
1
- FactoryGirl.define do
2
-
3
- factory :sheet do
4
- sequence(:title) { |n| "Test sheet #{n} #{(Time.now.to_f * 1000).to_i}" }
5
- description{ "Test sheet description."}
6
- end
7
-
1
+ FactoryGirl.define do
2
+
3
+ factory :sheet do
4
+ sequence(:title) { |n| "Test sheet #{n} #{(Time.now.to_f * 1000).to_i}" }
5
+ description{ "Test sheet description."}
6
+ end
7
+
8
8
  end
@@ -1,10 +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
-
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
10
  end
@@ -1,6 +1,6 @@
1
- puts %Q{
2
- code: SCRAPE_SOME_DATA
3
- -
4
- Date,Value
5
- #{Time.now.strftime("%Y-%m-%d")},10
1
+ puts %Q{
2
+ code: SCRAPE_SOME_DATA
3
+ -
4
+ Date,Value
5
+ #{Time.now.strftime("%Y-%m-%d")},10
6
6
  }
@@ -1,64 +1,64 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Dataset do
5
-
6
- let(:source){
7
- s = Source.find("QUANDL_CLIENT_TEST_SOURCE")
8
- s = create(:source, code: "QUANDL_CLIENT_TEST_SOURCE") unless s.exists?
9
- s
10
- }
11
- subject{ create(:dataset, source_code: source.code, private: true ) }
12
-
13
- describe "#code" do
14
- subject{ build(:dataset, source_code: source.code.downcase ) }
15
- before(:each){}
16
- it "lowercase code should be valid" do
17
- subject.code = subject.code.downcase
18
- subject.save
19
- subject.saved?.should be_true
20
- end
21
-
22
- end
23
-
24
- describe "#name" do
25
- subject{ create(:dataset, source_code: source.code, private: true, name: '' ) }
26
-
27
- its(:name){ should match /Untitled Dataset #{Date.today}/ }
28
- end
29
-
30
- describe "#reference_url" do
31
- let(:url){ "http://website.com/path/to/reference" }
32
- let(:dataset){ Dataset.new( reference_url: url, code: "VALID" ) }
33
- subject{ dataset }
34
-
35
- its(:reference_url){ should eq url }
36
- its(:valid?){ should be_true }
37
-
38
- context "partial url" do
39
- let(:url){ "website.com/path/to/reference" }
40
- its(:reference_url){ should eq "http://website.com/path/to/reference" }
41
- its(:valid?){ should be_true }
42
- end
43
-
44
- end
45
-
46
- describe "#private" do
47
-
48
- it "should update to false" do
49
- subject.private = false
50
- subject.save
51
- Dataset.find(subject.id).private.should be_false
52
- end
53
-
54
- it "should update to true" do
55
- subject.private = false
56
- subject.save
57
- subject.private = true
58
- subject.save
59
- Dataset.find(subject.id).private.should be_true
60
- end
61
-
62
- end
63
-
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Dataset do
5
+
6
+ let(:source){
7
+ s = Source.find("QUANDL_CLIENT_TEST_SOURCE")
8
+ s = create(:source, code: "QUANDL_CLIENT_TEST_SOURCE") unless s.exists?
9
+ s
10
+ }
11
+ subject{ create(:dataset, source_code: source.code, private: true ) }
12
+
13
+ describe "#code" do
14
+ subject{ build(:dataset, source_code: source.code.downcase ) }
15
+ before(:each){}
16
+ it "lowercase code should be valid" do
17
+ subject.code = subject.code.downcase
18
+ subject.save
19
+ subject.saved?.should be_true
20
+ end
21
+
22
+ end
23
+
24
+ describe "#name" do
25
+ subject{ create(:dataset, source_code: source.code, private: true, name: '' ) }
26
+
27
+ its(:name){ should match /Untitled Dataset #{Date.today}/ }
28
+ end
29
+
30
+ describe "#reference_url" do
31
+ let(:url){ "http://website.com/path/to/reference" }
32
+ let(:dataset){ Dataset.new( reference_url: url, code: "VALID" ) }
33
+ subject{ dataset }
34
+
35
+ its(:reference_url){ should eq url }
36
+ its(:valid?){ should be_true }
37
+
38
+ context "partial url" do
39
+ let(:url){ "website.com/path/to/reference" }
40
+ its(:reference_url){ should eq "http://website.com/path/to/reference" }
41
+ its(:valid?){ should be_true }
42
+ end
43
+
44
+ end
45
+
46
+ describe "#private" do
47
+
48
+ it "should update to false" do
49
+ subject.private = false
50
+ subject.save
51
+ Dataset.find(subject.id).private.should be_false
52
+ end
53
+
54
+ it "should update to true" do
55
+ subject.private = false
56
+ subject.save
57
+ subject.private = true
58
+ subject.save
59
+ Dataset.find(subject.id).private.should be_true
60
+ end
61
+
62
+ end
63
+
64
64
  end
@@ -1,93 +1,93 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Quandl::Client::Dataset::Data do
5
-
6
- let(:dataset){
7
- create(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE", data: Quandl::Fabricate::Data.rand( rows: 10, columns: 4 ), column_names: ["Date", "C1", 'c2', 'c3', 'c4'] )
8
- }
9
- subject{ dataset }
10
-
11
- its(:valid?){ should be_true }
12
-
13
- describe ".with_id('NSE/OIL')" do
14
- let(:id){ Dataset.find("NSE/OIL").id }
15
- subject{ Quandl::Client::Dataset::Data.with_id(id) }
16
- let(:data){ Quandl::Client::Dataset::Data.with_id(id).to_table }
17
-
18
- let(:beginning_of_last_week){ Date.today.jd - Date.today.beginning_of_week.jd }
19
-
20
- it("data"){ data.count.should > 100 }
21
- it(".rows(5)"){ subject.rows(5).to_table.count.should eq 5 }
22
- it(".limit(2)"){ subject.limit(2).to_table.count.should eq 2 }
23
- it(".column(2)"){ subject.column(2).to_table.first.count.should eq 2 }
24
- it(".order('asc')"){ subject.order('asc').to_table.first.first.should eq data.sort_ascending!.first.first }
25
- it(".order('desc')"){ subject.order('desc').to_table.first.first.should eq data.sort_descending!.first.first }
26
- it(".trim_start().trim_end()"){ subject.trim_start( data[11].first ).trim_end(data[10].first).to_table.first.first.should eq data[10].first }
27
- it(".collapse('monthly')"){ subject.collapse('monthly').to_table.frequency.should eq :monthly }
28
- it(".transform('rdiff')"){ subject.transform('rdiff').to_table[0][1].should_not eq data[0][1] }
29
- end
30
-
31
- describe "#data" do
32
- subject{ Dataset.find( dataset.id ).data }
33
-
34
- its(:count){ should eq 10 }
35
- its(:to_h){ should be_a Hash }
36
- end
37
-
38
- context "updated" do
39
-
40
- subject{
41
- dataset.updated_at
42
- sleep(0.75)
43
- Dataset.find( dataset.id )
44
- }
45
-
46
- describe "#data" do
47
- before(:each){ subject.data = Quandl::Fabricate::Data.rand( rows: 12, columns: 4 ); sleep(1); subject.save }
48
- its(:updated_at){ should_not eq dataset.updated_at }
49
- its(:data){ should_not eq dataset.data }
50
- its(:refreshed_at){ should_not eq dataset.refreshed_at }
51
- end
52
-
53
- context "#column_spec" do
54
- before(:each){ subject.column_spec = "[0,[\"Date\",{}],[\"c1 \",{}],[\"c2 \",{}],[\"c3 \",{}],[\"c234 \",{}]]"; sleep(1); subject.save }
55
- its(:updated_at){ should_not eq dataset.updated_at }
56
- its(:column_spec){ should_not eq dataset.column_spec }
57
- end
58
-
59
- end
60
-
61
- describe "#delete_data" do
62
- subject{ Dataset.find( dataset.id ) }
63
- before(:each){ subject.delete_data }
64
- its(:data){ should be_blank }
65
- end
66
-
67
- describe "#delete_rows" do
68
- subject{ Dataset.find( dataset.id ) }
69
-
70
- let(:dates_slice){ dataset.data.to_date.to_h.keys[5..8] }
71
-
72
- it "should have the dates" do
73
- dates = Dataset.find( dataset.id ).data.to_date.to_h.keys
74
- dates_slice.each{|date| dates.include?(date).should be_true }
75
- end
76
-
77
- context "after deleting rows" do
78
-
79
- before(:each){ subject.delete_rows(dates_slice) }
80
-
81
- it "data count should be 6" do
82
- Dataset.find( dataset.id ).data.count.should eq 6
83
- end
84
-
85
- it "data should have dates" do
86
- dates = Dataset.find( dataset.id ).data.to_h
87
- dates.each{|date| dates_slice.include?(date).should be_false }
88
- end
89
-
90
- end
91
- end
92
-
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Quandl::Client::Dataset::Data do
5
+
6
+ let(:dataset){
7
+ create(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE", data: Quandl::Fabricate::Data.rand( rows: 10, columns: 4 ), column_names: ["Date", "C1", 'c2', 'c3', 'c4'] )
8
+ }
9
+ subject{ dataset }
10
+
11
+ its(:valid?){ should be_true }
12
+
13
+ describe ".with_id('NSE/OIL')" do
14
+ let(:id){ Dataset.find("NSE/OIL").id }
15
+ subject{ Quandl::Client::Dataset::Data.with_id(id) }
16
+ let(:data){ Quandl::Client::Dataset::Data.with_id(id).to_table }
17
+
18
+ let(:beginning_of_last_week){ Date.today.jd - Date.today.beginning_of_week.jd }
19
+
20
+ it("data"){ data.count.should > 100 }
21
+ it(".rows(5)"){ subject.rows(5).to_table.count.should eq 5 }
22
+ it(".limit(2)"){ subject.limit(2).to_table.count.should eq 2 }
23
+ it(".column(2)"){ subject.column(2).to_table.first.count.should eq 2 }
24
+ it(".order('asc')"){ subject.order('asc').to_table.first.first.should eq data.sort_ascending!.first.first }
25
+ it(".order('desc')"){ subject.order('desc').to_table.first.first.should eq data.sort_descending!.first.first }
26
+ it(".trim_start().trim_end()"){ subject.trim_start( data[11].first ).trim_end(data[10].first).to_table.first.first.should eq data[10].first }
27
+ it(".collapse('monthly')"){ subject.collapse('monthly').to_table.frequency.should eq :monthly }
28
+ it(".transform('rdiff')"){ subject.transform('rdiff').to_table[0][1].should_not eq data[0][1] }
29
+ end
30
+
31
+ describe "#data" do
32
+ subject{ Dataset.find( dataset.id ).data }
33
+
34
+ its(:count){ should eq 10 }
35
+ its(:to_h){ should be_a Hash }
36
+ end
37
+
38
+ context "updated" do
39
+
40
+ subject{
41
+ dataset.updated_at
42
+ sleep(0.75)
43
+ Dataset.find( dataset.id )
44
+ }
45
+
46
+ describe "#data" do
47
+ before(:each){ subject.data = Quandl::Fabricate::Data.rand( rows: 12, columns: 4 ); sleep(1); subject.save }
48
+ its(:updated_at){ should_not eq dataset.updated_at }
49
+ its(:data){ should_not eq dataset.data }
50
+ its(:refreshed_at){ should_not eq dataset.refreshed_at }
51
+ end
52
+
53
+ context "#column_spec" do
54
+ before(:each){ subject.column_spec = "[0,[\"Date\",{}],[\"c1 \",{}],[\"c2 \",{}],[\"c3 \",{}],[\"c234 \",{}]]"; sleep(1); subject.save }
55
+ its(:updated_at){ should_not eq dataset.updated_at }
56
+ its(:column_spec){ should_not eq dataset.column_spec }
57
+ end
58
+
59
+ end
60
+
61
+ describe "#delete_data" do
62
+ subject{ Dataset.find( dataset.id ) }
63
+ before(:each){ subject.delete_data }
64
+ its(:data){ should be_blank }
65
+ end
66
+
67
+ describe "#delete_rows" do
68
+ subject{ Dataset.find( dataset.id ) }
69
+
70
+ let(:dates_slice){ dataset.data.to_date.to_h.keys[5..8] }
71
+
72
+ it "should have the dates" do
73
+ dates = Dataset.find( dataset.id ).data.to_date.to_h.keys
74
+ dates_slice.each{|date| dates.include?(date).should be_true }
75
+ end
76
+
77
+ context "after deleting rows" do
78
+
79
+ before(:each){ subject.delete_rows(dates_slice) }
80
+
81
+ it "data count should be 6" do
82
+ Dataset.find( dataset.id ).data.count.should eq 6
83
+ end
84
+
85
+ it "data should have dates" do
86
+ dates = Dataset.find( dataset.id ).data.to_h
87
+ dates.each{|date| dates_slice.include?(date).should be_false }
88
+ end
89
+
90
+ end
91
+ end
92
+
93
93
  end
@@ -1,66 +1,66 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Dataset do
5
-
6
- subject{
7
- build(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE" )
8
- }
9
-
10
- describe "#availability_delay" do
11
- context "given valid input" do
12
- it "saves the delay" do
13
- delay = '02:00:10'
14
- subject.availability_delay = delay
15
- subject.save
16
- Dataset.find(subject.id).availability_delay.should eq delay
17
- end
18
-
19
- end
20
- end
21
-
22
- describe "#locations" do
23
- context "with navigation" do
24
- it "should return the data in the right order" do
25
- locations = [
26
- {
27
- category: 'js_http',
28
- url: "http://test-#{(Time.now.to_f * 1000).to_i}.com/data",
29
- navigation: [
30
- {:id => 'id303', :type => 'link'},
31
- {:name => 'selectionname', :type => 'text', :value => 'cd' },
32
- {:name => 'auswaehlen', :type => 'button'},
33
- {:id => "id#cd", :type => 'link'},
34
- {:name => 'werteabruf', :type => 'button'}
35
- ]
36
- }
37
- ]
38
- subject.locations = locations
39
- subject.save
40
- dataset = Dataset.find(subject.id)
41
- dataset.locations[0][:category].should eq locations[0][:category]
42
- dataset.locations[0][:url].should eq locations[0][:url]
43
- dataset.locations[0][:navigation].should eq locations[0][:navigation]
44
- end
45
- end
46
- context "datasets sharing location" do
47
-
48
- let(:location){ [{ category: "http", url: "http://www.bankofcanada.ca/rates/price-indexes/cpi/"}] }
49
- let(:dataset1){ create(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE", locations: location ) }
50
- let(:dataset2){ create(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE", locations: location ) }
51
-
52
- it "should share the location" do
53
- Dataset.find(dataset1.id).locations.should eq Dataset.find(dataset2.id).locations
54
- end
55
-
56
- it "should update the dataset" do
57
- d = Dataset.find(dataset1.id)
58
- d.data = [[ Date.today, 42, 68 ]]
59
- d.save
60
- d.status.should eq 200
61
- end
62
-
63
- end
64
- end
65
-
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Dataset do
5
+
6
+ subject{
7
+ build(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE" )
8
+ }
9
+
10
+ describe "#availability_delay" do
11
+ context "given valid input" do
12
+ it "saves the delay" do
13
+ delay = '02:00:10'
14
+ subject.availability_delay = delay
15
+ subject.save
16
+ Dataset.find(subject.id).availability_delay.should eq delay
17
+ end
18
+
19
+ end
20
+ end
21
+
22
+ describe "#locations" do
23
+ context "with navigation" do
24
+ it "should return the data in the right order" do
25
+ locations = [
26
+ {
27
+ category: 'js_http',
28
+ url: "http://test-#{(Time.now.to_f * 1000).to_i}.com/data",
29
+ navigation: [
30
+ {:id => 'id303', :type => 'link'},
31
+ {:name => 'selectionname', :type => 'text', :value => 'cd' },
32
+ {:name => 'auswaehlen', :type => 'button'},
33
+ {:id => "id#cd", :type => 'link'},
34
+ {:name => 'werteabruf', :type => 'button'}
35
+ ]
36
+ }
37
+ ]
38
+ subject.locations = locations
39
+ subject.save
40
+ dataset = Dataset.find(subject.id)
41
+ dataset.locations[0][:category].should eq locations[0][:category]
42
+ dataset.locations[0][:url].should eq locations[0][:url]
43
+ dataset.locations[0][:navigation].should eq locations[0][:navigation]
44
+ end
45
+ end
46
+ context "datasets sharing location" do
47
+
48
+ let(:location){ [{ category: "http", url: "http://www.bankofcanada.ca/rates/price-indexes/cpi/"}] }
49
+ let(:dataset1){ create(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE", locations: location ) }
50
+ let(:dataset2){ create(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE", locations: location ) }
51
+
52
+ it "should share the location" do
53
+ Dataset.find(dataset1.id).locations.should eq Dataset.find(dataset2.id).locations
54
+ end
55
+
56
+ it "should update the dataset" do
57
+ d = Dataset.find(dataset1.id)
58
+ d.data = [[ Date.today, 42, 68 ]]
59
+ d.save
60
+ d.status.should eq 200
61
+ end
62
+
63
+ end
64
+ end
65
+
66
66
  end