betfair_api_ng_rails 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -1
  3. data/Rakefile +8 -8
  4. data/lib/betfair_api_ng_rails/api/connection.rb +3 -0
  5. data/lib/betfair_api_ng_rails/api/connection_ext/error_handling.rb +31 -0
  6. data/lib/betfair_api_ng_rails/api/connection_ext/formatting.rb +0 -1
  7. data/lib/betfair_api_ng_rails/api/connection_ext/parsing.rb +0 -1
  8. data/lib/betfair_api_ng_rails/api/data/base.rb +2 -1
  9. data/lib/betfair_api_ng_rails/api/data/competition.rb +7 -6
  10. data/lib/betfair_api_ng_rails/api/data/competition_result.rb +6 -10
  11. data/lib/betfair_api_ng_rails/api/data/concerns/attributable.rb +51 -0
  12. data/lib/betfair_api_ng_rails/api/data/concerns/hashable.rb +7 -2
  13. data/lib/betfair_api_ng_rails/api/data/concerns/jsonable.rb +46 -0
  14. data/lib/betfair_api_ng_rails/api/data/constants.rb +1 -1
  15. data/lib/betfair_api_ng_rails/api/data/country_code_result.rb +5 -8
  16. data/lib/betfair_api_ng_rails/api/data/event.rb +9 -4
  17. data/lib/betfair_api_ng_rails/api/data/event_result.rb +5 -8
  18. data/lib/betfair_api_ng_rails/api/data/event_type.rb +5 -4
  19. data/lib/betfair_api_ng_rails/api/data/event_type_result.rb +5 -8
  20. data/lib/betfair_api_ng_rails/api/data/ex_best_offers_overrides.rb +24 -0
  21. data/lib/betfair_api_ng_rails/api/data/exchange_prices.rb +16 -0
  22. data/lib/betfair_api_ng_rails/api/data/market_book.rb +31 -0
  23. data/lib/betfair_api_ng_rails/api/data/market_catalogue.rb +23 -0
  24. data/lib/betfair_api_ng_rails/api/data/market_description.rb +29 -0
  25. data/lib/betfair_api_ng_rails/api/data/market_filter.rb +18 -1
  26. data/lib/betfair_api_ng_rails/api/data/market_type_result.rb +5 -8
  27. data/lib/betfair_api_ng_rails/api/data/match.rb +19 -0
  28. data/lib/betfair_api_ng_rails/api/data/order.rb +29 -0
  29. data/lib/betfair_api_ng_rails/api/data/price_projection.rb +23 -0
  30. data/lib/betfair_api_ng_rails/api/data/price_size.rb +15 -0
  31. data/lib/betfair_api_ng_rails/api/data/runner.rb +24 -0
  32. data/lib/betfair_api_ng_rails/api/data/runner_catalog.rb +19 -0
  33. data/lib/betfair_api_ng_rails/api/data/starting_prices.rb +18 -0
  34. data/lib/betfair_api_ng_rails/api/data/time_range.rb +5 -4
  35. data/lib/betfair_api_ng_rails/api/data/time_range_result.rb +5 -8
  36. data/lib/betfair_api_ng_rails/api/data/venue_result.rb +5 -8
  37. data/lib/betfair_api_ng_rails/api/hashalator.rb +2 -1
  38. data/lib/betfair_api_ng_rails/api/parsers/base.rb +0 -2
  39. data/lib/betfair_api_ng_rails/api/parsers/list_market_book.rb +15 -0
  40. data/lib/betfair_api_ng_rails/api/parsers/list_market_catalogue.rb +15 -0
  41. data/lib/betfair_api_ng_rails/api/request_methods.rb +9 -1
  42. data/lib/betfair_api_ng_rails/errors.rb +7 -0
  43. data/lib/betfair_api_ng_rails/version.rb +1 -1
  44. data/lib/betfair_api_ng_rails.rb +41 -25
  45. data/spec/betfair_api_ng_rails/api/connection_spec.rb +3 -1
  46. data/spec/betfair_api_ng_rails/api/data/competition_result_spec.rb +15 -0
  47. data/spec/betfair_api_ng_rails/api/data/competition_spec.rb +7 -0
  48. data/spec/betfair_api_ng_rails/api/data/concerns/attributable_spec.rb +156 -0
  49. data/spec/betfair_api_ng_rails/api/data/concerns/hashable_spec.rb +44 -0
  50. data/spec/betfair_api_ng_rails/api/data/concerns/jsonable_spec.rb +170 -0
  51. data/spec/betfair_api_ng_rails/api/data/country_code_result_spec.rb +7 -0
  52. data/spec/betfair_api_ng_rails/api/data/event_result_spec.rb +16 -0
  53. data/spec/betfair_api_ng_rails/api/data/event_spec.rb +7 -0
  54. data/spec/betfair_api_ng_rails/api/data/event_type_result_spec.rb +16 -0
  55. data/spec/betfair_api_ng_rails/api/data/event_type_spec.rb +7 -0
  56. data/spec/betfair_api_ng_rails/api/data/ex_best_offers_overrides_spec.rb +7 -0
  57. data/spec/betfair_api_ng_rails/api/data/exchange_prices_spec.rb +15 -0
  58. data/spec/betfair_api_ng_rails/api/data/market_book_spec.rb +15 -0
  59. data/spec/betfair_api_ng_rails/api/data/market_catalogue_spec.rb +39 -0
  60. data/spec/betfair_api_ng_rails/api/data/market_description_spec.rb +7 -0
  61. data/spec/betfair_api_ng_rails/api/data/market_filter_spec.rb +7 -0
  62. data/spec/betfair_api_ng_rails/api/data/market_type_result_spec.rb +7 -0
  63. data/spec/betfair_api_ng_rails/api/data/match_spec.rb +7 -0
  64. data/spec/betfair_api_ng_rails/api/data/order_spec.rb +7 -0
  65. data/spec/betfair_api_ng_rails/api/data/price_projection_spec.rb +15 -0
  66. data/spec/betfair_api_ng_rails/api/data/price_size_spec.rb +7 -0
  67. data/spec/betfair_api_ng_rails/api/data/runner_catalog_spec.rb +7 -0
  68. data/spec/betfair_api_ng_rails/api/data/runner_spec.rb +33 -0
  69. data/spec/betfair_api_ng_rails/api/data/starting_prices_spec.rb +7 -0
  70. data/spec/betfair_api_ng_rails/api/data/time_range_result_spec.rb +17 -0
  71. data/spec/betfair_api_ng_rails/api/data/time_range_spec.rb +7 -0
  72. data/spec/betfair_api_ng_rails/api/data/venue_result_spec.rb +7 -0
  73. data/spec/betfair_api_ng_rails/api/hashalator_spec.rb +34 -4
  74. data/spec/betfair_api_ng_rails/api/request_methods_spec.rb +20 -0
  75. data/spec/betfair_api_ng_rails/integration/list_market_book_spec.rb +19 -0
  76. data/spec/betfair_api_ng_rails/integration/list_market_catalogue_spec.rb +36 -0
  77. data/spec/support/base_yaml_loader.rb +21 -0
  78. data/spec/support/data/models.yml +205 -0
  79. data/spec/support/data_models_yaml_loader.rb +7 -0
  80. data/spec/support/helper.rb +9 -0
  81. data/spec/support/shared_examples/data_model.rb +35 -0
  82. data/spec/support/shared_examples/simple_list_filtering_request.rb +3 -1
  83. metadata +100 -18
  84. data/lib/betfair_api_ng_rails/api/data/attributes.rb +0 -50
@@ -0,0 +1,170 @@
1
+ require 'spec_helper'
2
+
3
+ class TestJsonable
4
+ include BetfairApiNgRails::Api::Data::Concerns::Jsonable
5
+
6
+ def initialize(args = {})
7
+ args.each { |attribute, value| self.send("#{attribute}=", value) }
8
+ end
9
+
10
+ attr_accessor :some_attr
11
+ end
12
+
13
+ describe BetfairApiNgRails::Api::Data::Concerns::Jsonable do
14
+
15
+ describe "class method" do
16
+
17
+ subject { TestJsonable }
18
+
19
+ describe ".from_json" do
20
+
21
+ context 'when not defined class attributes' do
22
+
23
+ its(:from_json) { is_expected.to eq nil }
24
+
25
+ end
26
+
27
+ context 'when class attributes defined' do
28
+
29
+ before { allow(subject).to receive(:class_attrs) }
30
+
31
+ let(:attributes) { {some_attr: :val1} }
32
+
33
+ it "returns new instance with fetched attributes" do
34
+ expect(subject).to receive(:set_attributes).and_return attributes
35
+ expect(subject).to receive(:new).with(attributes)
36
+ subject.from_json
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+
43
+ describe ".json_key" do
44
+
45
+ it 'changes passed value to camelize lowercase string' do
46
+ expect(subject.send(:json_key, :some_value)).to eq "someValue"
47
+ end
48
+
49
+ end
50
+
51
+ describe ".set_attributes" do
52
+
53
+ let(:data) { double(:data) }
54
+
55
+ before { allow(subject).to receive(:class_attrs).and_return({some_attr: {type: String}}) }
56
+
57
+ it "returns hash attributes" do
58
+ expect(subject).to receive(:get_attr_value).with data, :some_attr, {type: String}
59
+ subject.send :set_attributes, data
60
+ end
61
+
62
+ end
63
+
64
+ describe ".get_attr_value" do
65
+
66
+ let(:type) { String }
67
+
68
+ subject { TestJsonable.send(:get_attr_value, attribs, key, {type: type, array: is_array}) }
69
+
70
+ context 'when fetching data for single valued attr' do
71
+
72
+ let(:key) { :some_attr }
73
+ let(:attribs) { {'someAttr' => :value} }
74
+ let(:is_array) { false }
75
+
76
+ context 'and its type is String ' do
77
+
78
+ it { is_expected.to eq :value }
79
+
80
+ end
81
+
82
+ context 'and its type is custom' do
83
+
84
+ let(:type) { TestJsonable }
85
+
86
+ it "calls from_json on proper class" do
87
+ expect(type).to receive(:from_json).and_return :some_object
88
+ expect(subject).to eq :some_object
89
+ end
90
+
91
+ end
92
+
93
+ end
94
+
95
+ context 'when fetching data for array attr' do
96
+
97
+ let(:key) { :some_attr }
98
+ let(:attribs) { {'someAttr' => [:value]} }
99
+ let(:is_array) { false }
100
+
101
+ context 'and its type is custom' do
102
+
103
+ let(:type) { TestJsonable }
104
+
105
+ it "calls from_json on proper class" do
106
+ expect(type).to receive(:from_json).and_return [:some_object]
107
+ expect(subject).to include(:some_object)
108
+ end
109
+
110
+ end
111
+
112
+ end
113
+
114
+ context 'when trying fetch value for not existed key' do
115
+
116
+ let(:key) { :some_attr_1 }
117
+ let(:attribs) { {'someAttr' => :value} }
118
+ let(:is_array) { false }
119
+
120
+ it { is_expected.to be_nil }
121
+
122
+ end
123
+
124
+ end
125
+
126
+ describe ".prepare_value" do
127
+
128
+ let(:data) { double(:data) }
129
+
130
+ subject { TestJsonable.send(:prepare_value, type, data) }
131
+
132
+ context 'when called for String type' do
133
+
134
+ let(:type) { String }
135
+
136
+ it { is_expected.to eq data }
137
+
138
+ end
139
+
140
+ context 'when called for custom type' do
141
+
142
+ let(:type) { TestJsonable }
143
+
144
+ before { expect(TestJsonable).to receive(:from_json).and_return(:some_object) }
145
+
146
+ it { is_expected.to eq (:some_object) }
147
+
148
+ end
149
+
150
+ end
151
+
152
+ end
153
+
154
+ describe "integration tests" do
155
+
156
+ before do
157
+ allow(TestJsonable).to receive(:class_attrs).and_return({some_attr: {type: String, array: false}})
158
+ end
159
+
160
+ context 'success load object from hashable json' do
161
+
162
+ subject { TestJsonable.from_json({'someAttr' => :value}) }
163
+
164
+ its(:some_attr) { is_expected.to eq :value }
165
+
166
+ end
167
+
168
+ end
169
+
170
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::CountryCodeResult do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('countryCodeResult')
6
+
7
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::EventResult do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('eventResult') do
6
+
7
+ describe "event association" do
8
+
9
+ its('event.id') { is_expected.to eq '1' }
10
+ its('event.name') { is_expected.to eq 'Chelse - PSG' }
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::Event do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('event')
6
+
7
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::EventTypeResult do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('eventTypeResult') do
6
+
7
+ describe "event type association" do
8
+
9
+ its('event_type.id') { is_expected.to eq 1 }
10
+ its('event_type.name') { is_expected.to eq 'Soccer' }
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::EventType do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('eventType')
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::ExBestOffersOverrides do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('exBestOffersOverrides')
6
+
7
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::ExchangePrices do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('exchangePrices') do
6
+
7
+ its(:traded_volume) { is_expected.to be_kind_of Array }
8
+
9
+ its(:available_to_back) { is_expected.to be_kind_of Array }
10
+
11
+ its(:available_to_lay) { is_expected.to be_kind_of Array }
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::MarketBook do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('marketBook') do
6
+
7
+ describe "runners association" do
8
+
9
+ its(:runners) { is_expected.to be_kind_of Array }
10
+
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::MarketCatalogue do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('marketCatalogue') do
6
+
7
+ describe "description association" do
8
+
9
+ its(:description) { is_expected.to be_kind_of BetfairApiNgRails::MarketDescription }
10
+
11
+ end
12
+
13
+ describe "runners association" do
14
+
15
+ its(:runners) { is_expected.to be_kind_of Array }
16
+
17
+ end
18
+
19
+ describe "event type association" do
20
+
21
+ its(:event_type) { is_expected.to be_kind_of BetfairApiNgRails::EventType }
22
+
23
+ end
24
+
25
+ describe "competition association" do
26
+
27
+ its(:competition) { is_expected.to be_kind_of BetfairApiNgRails::Competition }
28
+
29
+ end
30
+
31
+ describe "event association" do
32
+
33
+ its(:event) { is_expected.to be_kind_of BetfairApiNgRails::Event }
34
+
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::MarketDescription do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('marketDescription')
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::MarketFilter do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('marketFilter')
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::MarketTypeResult do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('marketTypeResult')
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::Match do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('match')
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::Order do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('order')
6
+
7
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::PriceProjection do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('priceProjection') do
6
+
7
+ describe "exBestOffersOverrides" do
8
+
9
+ its(:ex_best_offers_overrides) { is_expected.to be_kind_of BetfairApiNgRails::ExBestOffersOverrides }
10
+
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::PriceSize do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('priceSize')
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::RunnerCatalog do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('runnerCatalog')
6
+
7
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::Runner do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('runner') do
6
+
7
+ describe "starting prices association" do
8
+
9
+ its(:sp) { is_expected.to be_kind_of BetfairApiNgRails::StartingPrices }
10
+
11
+ end
12
+
13
+ describe "exchange prices association" do
14
+
15
+ its(:ex) { is_expected.to be_kind_of BetfairApiNgRails::ExchangePrices }
16
+
17
+ end
18
+
19
+ describe "orders association" do
20
+
21
+ its(:orders) { is_expected.to be_kind_of Array }
22
+
23
+ end
24
+
25
+ describe "matches association" do
26
+
27
+ its(:matches) { is_expected.to be_kind_of Array }
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::StartingPrices do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('startingPrices')
6
+
7
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::TimeRangeResult do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('timeRangeResult') do
6
+
7
+ describe "time range association" do
8
+
9
+ its(:time_range) { is_expected.to be_kind_of BetfairApiNgRails::TimeRange }
10
+
11
+ its('time_range.from') { is_expected.to eq '23-04-2014' }
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::TimeRange do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('timeRange')
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::VenueResult do
4
+
5
+ include_examples 'data model', DataModelsYamlLoader.new.fetch('venueResult')
6
+
7
+ end
@@ -9,11 +9,25 @@ describe BetfairApiNgRails::Api::Hashalator do
9
9
  its(:hashable) { is_expected.to eq hashable }
10
10
 
11
11
  describe "#to_hash" do
12
+
13
+ context 'when value isn\'t blank or nil' do
12
14
 
13
- it "iterates though elements and process they" do
14
- expect(subject).to receive(:hash_key).at_least(:once)
15
- expect(subject).to receive(:hash_value).at_least(:once)
16
- subject.to_hash
15
+ it "iterates though elements and process they" do
16
+ expect(subject).to receive(:hash_key).at_least(:once)
17
+ expect(subject).to receive(:hash_value).at_least(:once).and_return double
18
+ subject.to_hash
19
+ end
20
+
21
+ end
22
+
23
+ context 'when else' do
24
+
25
+ it "does include it result hash" do
26
+ expect(subject).to receive(:hash_key).exactly(0).times
27
+ expect(subject).to receive(:hash_value).at_least(:once)
28
+ subject.to_hash
29
+ end
30
+
17
31
  end
18
32
 
19
33
  end
@@ -141,6 +155,22 @@ describe BetfairApiNgRails::Api::Hashalator do
141
155
 
142
156
  end
143
157
 
158
+ context 'when one of values is blank' do
159
+
160
+ let(:hashable) { {some_key: ""} }
161
+
162
+ it { is_expected.to eq({}) }
163
+
164
+ end
165
+
166
+ context 'when one of values is nil' do
167
+
168
+ let(:hashable) { {some_key: nil} }
169
+
170
+ it { is_expected.to eq({}) }
171
+
172
+ end
173
+
144
174
  end
145
175
 
146
176
  end
@@ -6,6 +6,8 @@ module TestModule
6
6
  end
7
7
 
8
8
  describe BetfairApiNgRails::Api::RequestMethods do
9
+
10
+ before { BetfairApiNgRails.config.locale = :en }
9
11
 
10
12
  BetfairApiNgRails::Api::Constants::SIMPLE_LISTING_FILTERED.each do |method|
11
13
 
@@ -20,6 +22,24 @@ describe BetfairApiNgRails::Api::RequestMethods do
20
22
 
21
23
  end
22
24
 
25
+ describe "#list_market_catalogue" do
26
+
27
+ it "calls run_request with proper params" do
28
+ expect(TestModule).to receive(:run_request).with(:list_market_catalogue, {filter: :filter, market_projection: [], sort: "", max_results: '1'}, {locale: :en})
29
+ TestModule.list_market_catalogue filter: :filter
30
+ end
31
+
32
+ end
33
+
34
+ describe "#list_market_book" do
35
+
36
+ it "calls run_request with proper params" do
37
+ expect(TestModule).to receive(:run_request).with(:list_market_book, {market_ids: ['1'], price_projection: :priceProjection, order_projection: '', match_projection: ''}, {currency_code: 'USD', locale: :en})
38
+ TestModule.list_market_book market_ids: ['1'], price_projection: :priceProjection
39
+ end
40
+
41
+ end
42
+
23
43
  describe "#place_orders" do
24
44
 
25
45
  it "calls run_request with proper params" do
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ extend BetfairApiNgRails::Api::RequestMethods
5
+ end
6
+
7
+ describe "listMarketBook request method" do
8
+
9
+ it_behaves_like 'simple list filtering request', 'listMarketBook' do
10
+
11
+ let(:parameters) { {market_ids: [1]} }
12
+ let(:method_name) { "list_market_book" }
13
+ let(:result_class) { BetfairApiNgRails::MarketBook }
14
+ let(:result_hash) { "{\"result\": [{\"marketId\": 1, \"isMarketDataDelayed\": \"true\"}]}" }
15
+
16
+ end
17
+
18
+ end
19
+
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ extend BetfairApiNgRails::Api::RequestMethods
5
+ end
6
+
7
+ describe "listMarketCatalogue request method" do
8
+
9
+ it_behaves_like 'simple list filtering request', 'listMarketCatalogue' do
10
+
11
+ let(:method_name) { "list_market_catalogue" }
12
+ let(:result_class) { BetfairApiNgRails::MarketCatalogue }
13
+ let(:result_hash) { "{\"result\": [{\"marketId\": 1, \"marketName\": \"Madrid\", \"marketStartTime\": \"23-04-2014\", \"description\": \"Madrid\", \"totalMatched\": \"1\", \"competition\": {\"id\": 1, \"name\": \"name\"}}]}" }
14
+
15
+ describe 'checking attribute' do
16
+
17
+ context 'competition' do
18
+
19
+ it_behaves_like 'request method' do
20
+
21
+ subject { TestModule.send(method_name, parameters).first }
22
+
23
+ its(:competition) { is_expected.not_to be_nil }
24
+
25
+ its('competition.name') { is_expected.to eq 'name' }
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
@@ -0,0 +1,21 @@
1
+ require 'yaml'
2
+
3
+ class BaseYamlLoader
4
+
5
+ attr_reader :data
6
+
7
+ def initialize(file_name)
8
+ @data = YAML.load_file(file_path(file_name))
9
+ end
10
+
11
+ def fetch(resource_name)
12
+ data.fetch resource_name, {}
13
+ end
14
+
15
+ private
16
+
17
+ def file_path(file_name)
18
+ File.join(File.dirname(__FILE__), "data/#{file_name}.yml")
19
+ end
20
+
21
+ end