betfair_api_ng_rails 0.0.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -28
  3. data/Rakefile +10 -1
  4. data/betfair_api_ng_rails.gemspec +3 -0
  5. data/lib/betfair_api_ng_rails.rb +92 -73
  6. data/lib/betfair_api_ng_rails/api/concerns/errorable.rb +19 -0
  7. data/lib/betfair_api_ng_rails/api/config.rb +27 -0
  8. data/lib/betfair_api_ng_rails/api/connection.rb +34 -0
  9. data/lib/betfair_api_ng_rails/api/connection_ext/formatting.rb +34 -0
  10. data/lib/betfair_api_ng_rails/api/connection_ext/parsing.rb +29 -0
  11. data/lib/betfair_api_ng_rails/api/constants.rb +51 -0
  12. data/lib/betfair_api_ng_rails/api/data/attributes.rb +50 -0
  13. data/lib/betfair_api_ng_rails/api/data/base.rb +16 -0
  14. data/lib/betfair_api_ng_rails/api/data/competition.rb +20 -0
  15. data/lib/betfair_api_ng_rails/api/data/competition_result.rb +21 -0
  16. data/lib/betfair_api_ng_rails/api/data/concerns/hashable.rb +29 -0
  17. data/lib/betfair_api_ng_rails/api/data/constants.rb +11 -0
  18. data/lib/betfair_api_ng_rails/api/data/country_code_result.rb +19 -0
  19. data/lib/betfair_api_ng_rails/api/data/event.rb +20 -0
  20. data/lib/betfair_api_ng_rails/api/data/event_result.rb +19 -0
  21. data/lib/betfair_api_ng_rails/api/data/event_type.rb +20 -0
  22. data/lib/betfair_api_ng_rails/api/data/event_type_result.rb +19 -0
  23. data/lib/betfair_api_ng_rails/api/data/market_filter.rb +16 -0
  24. data/lib/betfair_api_ng_rails/api/data/market_type_result.rb +19 -0
  25. data/lib/betfair_api_ng_rails/api/data/time_range.rb +20 -0
  26. data/lib/betfair_api_ng_rails/api/data/time_range_result.rb +19 -0
  27. data/lib/betfair_api_ng_rails/api/data/venue_result.rb +19 -0
  28. data/lib/betfair_api_ng_rails/api/enums/bet_status.rb +15 -0
  29. data/lib/betfair_api_ng_rails/api/enums/concerns/enumable.rb +15 -0
  30. data/lib/betfair_api_ng_rails/api/enums/execution_report_error_code.rb +28 -0
  31. data/lib/betfair_api_ng_rails/api/enums/execution_report_status.rb +15 -0
  32. data/lib/betfair_api_ng_rails/api/enums/group_by.rb +17 -0
  33. data/lib/betfair_api_ng_rails/api/enums/instruction_report_error_code.rb +31 -0
  34. data/lib/betfair_api_ng_rails/api/enums/instruction_report_status.rb +14 -0
  35. data/lib/betfair_api_ng_rails/api/enums/market_betting_type.rb +17 -0
  36. data/lib/betfair_api_ng_rails/api/enums/market_projection.rb +18 -0
  37. data/lib/betfair_api_ng_rails/api/enums/market_sort.rb +17 -0
  38. data/lib/betfair_api_ng_rails/api/enums/market_status.rb +15 -0
  39. data/lib/betfair_api_ng_rails/api/enums/match_projection.rb +14 -0
  40. data/lib/betfair_api_ng_rails/api/enums/order_by.rb +14 -0
  41. data/lib/betfair_api_ng_rails/api/enums/order_projection.rb +14 -0
  42. data/lib/betfair_api_ng_rails/api/enums/order_status.rb +13 -0
  43. data/lib/betfair_api_ng_rails/api/enums/order_type.rb +14 -0
  44. data/lib/betfair_api_ng_rails/api/enums/persistence_type.rb +14 -0
  45. data/lib/betfair_api_ng_rails/api/enums/price_data.rb +16 -0
  46. data/lib/betfair_api_ng_rails/api/enums/rollup_model.rb +15 -0
  47. data/lib/betfair_api_ng_rails/api/enums/runner_status.rb +17 -0
  48. data/lib/betfair_api_ng_rails/api/enums/side.rb +13 -0
  49. data/lib/betfair_api_ng_rails/api/enums/sort_dir.rb +13 -0
  50. data/lib/betfair_api_ng_rails/api/enums/time_granularity.rb +14 -0
  51. data/lib/betfair_api_ng_rails/api/formatter_factory.rb +1 -1
  52. data/lib/betfair_api_ng_rails/api/formatters/js_tree_formatter.rb +38 -0
  53. data/lib/betfair_api_ng_rails/api/hashalator.rb +39 -0
  54. data/lib/betfair_api_ng_rails/api/helper.rb +29 -0
  55. data/lib/betfair_api_ng_rails/api/http/factory.rb +41 -0
  56. data/lib/betfair_api_ng_rails/api/http/helpers/information_response.rb +35 -0
  57. data/lib/betfair_api_ng_rails/api/http/helpers/keep_alive_response.rb +32 -0
  58. data/lib/betfair_api_ng_rails/api/http/helpers/session_response.rb +36 -0
  59. data/lib/betfair_api_ng_rails/api/http/requester.rb +75 -0
  60. data/lib/betfair_api_ng_rails/api/http/responser.rb +47 -0
  61. data/lib/betfair_api_ng_rails/api/parsers/base.rb +31 -0
  62. data/lib/betfair_api_ng_rails/api/parsers/list_competitions.rb +15 -0
  63. data/lib/betfair_api_ng_rails/api/parsers/list_countries.rb +15 -0
  64. data/lib/betfair_api_ng_rails/api/parsers/list_event_types.rb +15 -0
  65. data/lib/betfair_api_ng_rails/api/parsers/list_events.rb +15 -0
  66. data/lib/betfair_api_ng_rails/api/parsers/list_market_types.rb +15 -0
  67. data/lib/betfair_api_ng_rails/api/parsers/list_time_ranges.rb +15 -0
  68. data/lib/betfair_api_ng_rails/api/parsers/list_venues.rb +15 -0
  69. data/lib/betfair_api_ng_rails/api/provider.rb +38 -0
  70. data/lib/betfair_api_ng_rails/api/request_methods.rb +33 -0
  71. data/lib/betfair_api_ng_rails/api/session_manager.rb +54 -0
  72. data/lib/betfair_api_ng_rails/errors.rb +6 -0
  73. data/lib/betfair_api_ng_rails/railtie.rb +7 -0
  74. data/lib/betfair_api_ng_rails/version.rb +1 -1
  75. data/lib/generators/betfair_api_ng_rails/install/templates/betfair_api_ng_rails.rb +11 -9
  76. data/lib/generators/betfair_api_ng_rails/install/templates/betfair_api_ng_rails.yml +2 -0
  77. data/spec/betfair_api_ng_rails/api/connection_spec.rb +74 -0
  78. data/spec/betfair_api_ng_rails/api/data/concerns/hashable_spec.rb +81 -0
  79. data/spec/betfair_api_ng_rails/api/formatters/js_tree_formatter_spec.rb +70 -0
  80. data/spec/betfair_api_ng_rails/api/hashalator_spec.rb +146 -0
  81. data/spec/betfair_api_ng_rails/api/provider_spec.rb +91 -0
  82. data/spec/betfair_api_ng_rails/api/request_methods_spec.rb +60 -0
  83. data/spec/betfair_api_ng_rails/api/session_manager_spec.rb +59 -0
  84. data/spec/betfair_api_ng_rails/integration/list_competitions_spec.rb +18 -0
  85. data/spec/betfair_api_ng_rails/integration/list_countries_spec.rb +18 -0
  86. data/spec/betfair_api_ng_rails/integration/list_event_types_spec.rb +18 -0
  87. data/spec/betfair_api_ng_rails/integration/list_events_spec.rb +18 -0
  88. data/spec/betfair_api_ng_rails/integration/list_market_types_spec.rb +18 -0
  89. data/spec/betfair_api_ng_rails/integration/list_time_ranges_spec.rb +18 -0
  90. data/spec/betfair_api_ng_rails/integration/list_venues_spec.rb +18 -0
  91. data/spec/spec_helper.rb +16 -0
  92. data/spec/support/shared_examples/request_method.rb +18 -0
  93. data/spec/support/shared_examples/simple_list_filtering_request.rb +51 -0
  94. metadata +156 -66
  95. data/lib/betfair_api_ng_rails/api/base_provider.rb +0 -15
  96. data/lib/betfair_api_ng_rails/api/bf/concerns/errorable.rb +0 -21
  97. data/lib/betfair_api_ng_rails/api/bf/config.rb +0 -27
  98. data/lib/betfair_api_ng_rails/api/bf/constants.rb +0 -37
  99. data/lib/betfair_api_ng_rails/api/bf/data/attributes.rb +0 -52
  100. data/lib/betfair_api_ng_rails/api/bf/data/base.rb +0 -17
  101. data/lib/betfair_api_ng_rails/api/bf/data/competition.rb +0 -26
  102. data/lib/betfair_api_ng_rails/api/bf/data/competition_result.rb +0 -23
  103. data/lib/betfair_api_ng_rails/api/bf/data/concerns/hashable.rb +0 -40
  104. data/lib/betfair_api_ng_rails/api/bf/data/concerns/querable.rb +0 -46
  105. data/lib/betfair_api_ng_rails/api/bf/data/constants.rb +0 -13
  106. data/lib/betfair_api_ng_rails/api/bf/data/event.rb +0 -26
  107. data/lib/betfair_api_ng_rails/api/bf/data/event_result.rb +0 -21
  108. data/lib/betfair_api_ng_rails/api/bf/data/event_type.rb +0 -26
  109. data/lib/betfair_api_ng_rails/api/bf/data/event_type_result.rb +0 -21
  110. data/lib/betfair_api_ng_rails/api/bf/data/market_filter.rb +0 -19
  111. data/lib/betfair_api_ng_rails/api/bf/data/time_range.rb +0 -18
  112. data/lib/betfair_api_ng_rails/api/bf/data/time_range_result.rb +0 -21
  113. data/lib/betfair_api_ng_rails/api/bf/enums/bet_status.rb +0 -17
  114. data/lib/betfair_api_ng_rails/api/bf/enums/concerns/enumable.rb +0 -17
  115. data/lib/betfair_api_ng_rails/api/bf/enums/execution_report_error_code.rb +0 -30
  116. data/lib/betfair_api_ng_rails/api/bf/enums/execution_report_status.rb +0 -17
  117. data/lib/betfair_api_ng_rails/api/bf/enums/group_by.rb +0 -19
  118. data/lib/betfair_api_ng_rails/api/bf/enums/instruction_report_error_code.rb +0 -33
  119. data/lib/betfair_api_ng_rails/api/bf/enums/instruction_report_status.rb +0 -16
  120. data/lib/betfair_api_ng_rails/api/bf/enums/market_betting_type.rb +0 -19
  121. data/lib/betfair_api_ng_rails/api/bf/enums/market_projection.rb +0 -20
  122. data/lib/betfair_api_ng_rails/api/bf/enums/market_sort.rb +0 -19
  123. data/lib/betfair_api_ng_rails/api/bf/enums/market_status.rb +0 -17
  124. data/lib/betfair_api_ng_rails/api/bf/enums/match_projection.rb +0 -16
  125. data/lib/betfair_api_ng_rails/api/bf/enums/order_by.rb +0 -16
  126. data/lib/betfair_api_ng_rails/api/bf/enums/order_projection.rb +0 -16
  127. data/lib/betfair_api_ng_rails/api/bf/enums/order_status.rb +0 -15
  128. data/lib/betfair_api_ng_rails/api/bf/enums/order_type.rb +0 -16
  129. data/lib/betfair_api_ng_rails/api/bf/enums/persistence_type.rb +0 -16
  130. data/lib/betfair_api_ng_rails/api/bf/enums/price_data.rb +0 -18
  131. data/lib/betfair_api_ng_rails/api/bf/enums/rollup_model.rb +0 -17
  132. data/lib/betfair_api_ng_rails/api/bf/enums/runner_status.rb +0 -19
  133. data/lib/betfair_api_ng_rails/api/bf/enums/side.rb +0 -15
  134. data/lib/betfair_api_ng_rails/api/bf/enums/sort_dir.rb +0 -15
  135. data/lib/betfair_api_ng_rails/api/bf/enums/time_granularity.rb +0 -16
  136. data/lib/betfair_api_ng_rails/api/bf/formatters/js_tree_formatter.rb +0 -30
  137. data/lib/betfair_api_ng_rails/api/bf/helper.rb +0 -33
  138. data/lib/betfair_api_ng_rails/api/bf/http/factory.rb +0 -37
  139. data/lib/betfair_api_ng_rails/api/bf/http/requester.rb +0 -69
  140. data/lib/betfair_api_ng_rails/api/bf/http/responser.rb +0 -58
  141. data/lib/betfair_api_ng_rails/api/bf/orm/parsers/base.rb +0 -33
  142. data/lib/betfair_api_ng_rails/api/bf/orm/parsers/list_competitions.rb +0 -19
  143. data/lib/betfair_api_ng_rails/api/bf/orm/parsers/list_event_types.rb +0 -19
  144. data/lib/betfair_api_ng_rails/api/bf/orm/parsers/list_events.rb +0 -19
  145. data/lib/betfair_api_ng_rails/api/bf/orm/requester.rb +0 -52
  146. data/lib/betfair_api_ng_rails/api/bf/provider.rb +0 -38
  147. data/lib/betfair_api_ng_rails/api/bf/session_manager.rb +0 -46
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::Api::Provider do
4
+
5
+ let(:ssoid) { double(:ssoid) }
6
+
7
+ subject { described_class.new(ssoid) }
8
+
9
+ its(:ssoid) { is_expected.to eq ssoid }
10
+
11
+ describe "#fetch" do
12
+
13
+ before { expect(subject).to receive(:is_method_allowed?).with(:some_method).and_return(method_allowed) }
14
+
15
+ context 'when method isn\'t allowed' do
16
+
17
+ let(:method_allowed) { false }
18
+
19
+ it "raises error" do
20
+ expect{ subject.fetch(method: :some_method) }.to raise_error
21
+ end
22
+
23
+ end
24
+
25
+ context 'when requested method is allowed' do
26
+
27
+ let(:method_allowed) { true }
28
+
29
+ it "calls run_request" do
30
+ expect(subject).to receive(:run_request).with(for_method: :some_method, params: {})
31
+ subject.fetch method: :some_method
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ describe "private method" do
39
+
40
+ describe "#run_request" do
41
+
42
+ let(:http_requester) { double(:http_requester) }
43
+
44
+ before { expect(subject).to receive(:http_requester).at_least(:once).and_return(http_requester) }
45
+
46
+ it "runs http requster" do
47
+ expect(http_requester).to receive(:set_api_req_body).with(:some_method, {})
48
+ expect(http_requester).to receive(:do_request)
49
+ subject.send :run_request, for_method: :some_method, params: {}
50
+ end
51
+
52
+ end
53
+
54
+ describe "#is_method_allowed?" do
55
+
56
+ before { stub_const("BetfairApiNgRails::Api::Constants::ALLOWED_RESOURCES", allowed_methods) }
57
+
58
+ context 'when requested method marked as allowed' do
59
+
60
+ let(:allowed_methods) { ['some_method'] }
61
+
62
+ it "returns true" do
63
+ expect(subject.send(:is_method_allowed?, :some_method)).to eq true
64
+ end
65
+
66
+ end
67
+
68
+ context 'when requested method isn\'t allowed' do
69
+
70
+ let(:allowed_methods) { ['some_another_method'] }
71
+
72
+ it "returns false" do
73
+ expect(subject.send(:is_method_allowed?, :some_method)).to eq false
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+
80
+ describe "#http_requester" do
81
+
82
+ it "initalizes provider http request" do
83
+ expect(BetfairApiNgRails::Api::Http::Factory).to receive(:provider_requester).with ssoid
84
+ subject.send :http_requester
85
+ end
86
+
87
+ end
88
+
89
+ end
90
+
91
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'betfair_api_ng_rails/api/constants'
3
+
4
+ module TestModule
5
+ extend BetfairApiNgRails::Api::RequestMethods
6
+ end
7
+
8
+ describe BetfairApiNgRails::Api::RequestMethods do
9
+
10
+ BetfairApiNgRails::Api::Constants::SIMPLE_LISTING_FILTERED.each do |method|
11
+
12
+ describe "##{method}" do
13
+
14
+ it "calls run_request with proper params" do
15
+ expect(TestModule).to receive(:run_request).with(method.underscore.to_sym, {filter: :filter}, {locale: :en})
16
+ TestModule.send method.underscore.to_sym, filter: :filter
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+
23
+ describe "#place_orders" do
24
+
25
+ it "calls run_request with proper params" do
26
+ expect(TestModule).to receive(:run_request).with(:place_orders, {market_id: "", instructions: [], customer_ref: ""})
27
+ TestModule.place_orders
28
+ end
29
+
30
+ end
31
+
32
+ describe "private method" do
33
+
34
+ describe "#build_request_type" do
35
+
36
+ it "returns proper api method name" do
37
+ expect(TestModule.send(:build_request_type, 'some_value')).to eq 'someValue'
38
+ end
39
+
40
+ end
41
+
42
+ describe "#run_request" do
43
+
44
+ let(:params) { {key1: 'value'} }
45
+ let(:data) { {key2: 'value'} }
46
+ let(:connection) { double(:connection) }
47
+
48
+ before(:each) { BetfairApiNgRails.connection = connection }
49
+
50
+ after(:each) { TestModule.send(:run_request, 'some_method', params, data) }
51
+
52
+ it "calls request method with proper params" do
53
+ expect(connection).to receive(:request).with('someMethod', params.merge(data))
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe BetfairApiNgRails::Api::SessionManager do
4
+
5
+ subject { described_class }
6
+
7
+ describe "#ssoid" do
8
+
9
+ it "calls fetching ssoid" do
10
+ expect(subject).to receive(:fetch_ssoid)
11
+ subject.ssoid
12
+ end
13
+
14
+ end
15
+
16
+ describe "#request_ssoid" do
17
+
18
+ before(:each) { expect(subject).to receive(:ssoid) }
19
+
20
+ context 'when no error occured' do
21
+
22
+ before(:each) { expect(subject).to receive(:has_errors?).and_return false }
23
+
24
+ its(:request_ssoid) { is_expected.to eq true }
25
+
26
+ end
27
+
28
+ context 'when at least one error occured' do
29
+
30
+ before(:each) { expect(subject).to receive(:has_errors?).and_return true }
31
+
32
+ its(:request_ssoid) { is_expected.to eq false }
33
+
34
+ end
35
+
36
+ end
37
+
38
+ describe "#expire_ssoid" do
39
+
40
+ it "sets instance var ssoid to nil" do
41
+ subject.instance_variable_set :@ssoid, :value
42
+ expect(subject.ssoid).to eq :value
43
+ subject.expire_ssoid
44
+ expect(subject.instance_variable_get(:@ssoid)).to eq nil
45
+ end
46
+
47
+ end
48
+
49
+ describe "#new_ssoid" do
50
+
51
+ it "expires ssoid and calls fetching new one" do
52
+ expect(subject).to receive(:expire_ssoid)
53
+ expect(subject).to receive(:ssoid)
54
+ subject.new_ssoid
55
+ end
56
+
57
+ end
58
+
59
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ extend BetfairApiNgRails::Api::RequestMethods
5
+ end
6
+
7
+ describe "listCompetitions request method" do
8
+
9
+ it_behaves_like 'simple list filtering request', 'listCompetitions' do
10
+
11
+ let(:method_name) { "list_competitions" }
12
+ let(:result_class) { BetfairApiNgRails::CompetitionResult }
13
+ let(:result_hash) { "{\"result\": [{\"marketCount\": 1, \"competition\": { \"id\": 1, \"name\": \"World Cup 2014\" }, \"competitionRegion\": \"BR\"}]}" }
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ extend BetfairApiNgRails::Api::RequestMethods
5
+ end
6
+
7
+ describe "listCountries request method" do
8
+
9
+ it_behaves_like 'simple list filtering request', 'listCountries' do
10
+
11
+ let(:method_name) { "list_countries" }
12
+ let(:result_class) { BetfairApiNgRails::CountryCodeResult }
13
+ let(:result_hash) { "{\"result\": [{\"marketCount\": 1, \"event\": \"UA\"}]}" }
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ extend BetfairApiNgRails::Api::RequestMethods
5
+ end
6
+
7
+ describe "listEventTypes request method" do
8
+
9
+ it_behaves_like 'simple list filtering request', 'listEventTypes' do
10
+
11
+ let(:method_name) { "list_event_types" }
12
+ let(:result_class) { BetfairApiNgRails::EventTypeResult }
13
+ let(:result_hash) { "{\"result\": [{\"marketCount\": 1, \"eventType\": { \"id\": 1, \"name\": \"Soccer\" }}]}" }
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ extend BetfairApiNgRails::Api::RequestMethods
5
+ end
6
+
7
+ describe "listEvents request method" do
8
+
9
+ it_behaves_like 'simple list filtering request', 'listEvents' do
10
+
11
+ let(:method_name) { "list_events" }
12
+ let(:result_class) { BetfairApiNgRails::EventResult }
13
+ let(:result_hash) { "{\"result\": [{\"marketCount\": 1, \"event\": { \"id\": 1, \"name\": \"Chelsea - PSG\" }}]}" }
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ extend BetfairApiNgRails::Api::RequestMethods
5
+ end
6
+
7
+ describe "listMarketTypes request method" do
8
+
9
+ it_behaves_like 'simple list filtering request', 'listMarketTypes' do
10
+
11
+ let(:method_name) { "list_market_types" }
12
+ let(:result_class) { BetfairApiNgRails::MarketTypeResult }
13
+ let(:result_hash) { "{\"result\": [{\"marketCount\": 1, \"marketType\": \"MATCH_ODDS\"}]}" }
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ extend BetfairApiNgRails::Api::RequestMethods
5
+ end
6
+
7
+ describe "listTimeRanges request method" do
8
+
9
+ it_behaves_like 'simple list filtering request', 'listTimeRanges' do
10
+
11
+ let(:method_name) { "list_time_ranges" }
12
+ let(:result_class) { BetfairApiNgRails::TimeRangeResult }
13
+ let(:result_hash) { "{\"result\": [{\"marketCount\": 1, \"timeRange\": { \"to\": \"18-04-2014\", \"from\": \"18-04-2014\" }}]}" }
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ extend BetfairApiNgRails::Api::RequestMethods
5
+ end
6
+
7
+ describe "listVenues request method" do
8
+
9
+ it_behaves_like 'simple list filtering request', 'listVenues' do
10
+
11
+ let(:method_name) { "list_venues" }
12
+ let(:result_class) { BetfairApiNgRails::VenueResult }
13
+ let(:result_hash) { "{\"result\": [{\"marketCount\": 1, \"venue\": \"Madrid\"}]}" }
14
+
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,16 @@
1
+ $TESTING=true
2
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+
4
+ require 'rspec/its'
5
+ require 'betfair_api_ng_rails'
6
+
7
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
8
+
9
+ RSpec.configure do |config|
10
+ config.mock_with :rspec
11
+
12
+ config.filter_run focus: true
13
+ config.run_all_when_everything_filtered = true
14
+
15
+ config.order = "random"
16
+ end
@@ -0,0 +1,18 @@
1
+ shared_examples 'request method' do
2
+
3
+ let(:ssoid) { 'vnboeirubvyebvuekrybobvuiberlvbre' }
4
+ let(:connection) { BetfairApiNgRails::Api::Connection.new }
5
+ let(:http_response) { double(:http_response, code: '200', body: result_hash) }
6
+ let(:result) { BetfairApiNgRails::Api::Http::Responser.new(http_response) }
7
+ let(:filter) { BetfairApiNgRails::MarketFilter.new }
8
+ let(:api_http_requester) { double(:api_http_requester, do_request: result, set_api_req_body: true) }
9
+
10
+ before(:each) do
11
+ expect(BetfairApiNgRails::Api::SessionManager).to receive(:new_ssoid).and_return ssoid
12
+ expect(BetfairApiNgRails::Api::Http::Factory).to receive(:provider_requester).with(ssoid).and_return api_http_requester
13
+ BetfairApiNgRails.connection = connection
14
+ end
15
+
16
+ subject { TestModule.send(method_name, parameters) }
17
+
18
+ end
@@ -0,0 +1,51 @@
1
+ shared_examples 'simple list filtering request' do |method|
2
+
3
+ let(:parameters) { {filter: filter} }
4
+
5
+ before(:each) { BetfairApiNgRails.config.formatter = nil }
6
+
7
+ context 'when no error occured' do
8
+
9
+ it_behaves_like 'request method' do
10
+
11
+ it { is_expected.not_to be_empty }
12
+
13
+ its(:first) { is_expected.to be_kind_of result_class }
14
+
15
+ end
16
+
17
+ end
18
+
19
+ context 'when api error occured' do
20
+
21
+ it_behaves_like 'request method' do
22
+
23
+ let(:result_hash) { "{\"error\":{\"code\":-32700,\"message\":\"DSC-3000\"}}" }
24
+
25
+ it { is_expected.to be_empty }
26
+
27
+ end
28
+
29
+ end
30
+
31
+ if BetfairApiNgRails::Api::Constants::ALLOWED_FORMATTING.include?(method)
32
+
33
+ context 'when enabled formatting' do
34
+
35
+ before(:each) { BetfairApiNgRails.config.formatter = :js_tree }
36
+
37
+ it_behaves_like 'request method' do
38
+
39
+ it { is_expected.not_to be_empty }
40
+
41
+ its(:first) { is_expected.to be_kind_of Hash }
42
+
43
+ its('first.keys') { is_expected.to include(:id, :text, :children, :data) }
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+
51
+ end
metadata CHANGED
@@ -1,57 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betfair_api_ng_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sergio1990
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-24 00:00:00.000000000 Z
11
+ date: 2014-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 3.1.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0.beta
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0.beta
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-nav
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  description: Betfair API-NG for Rails
56
98
  email:
57
99
  - sergeg1990@gmail.com
@@ -59,71 +101,102 @@ executables: []
59
101
  extensions: []
60
102
  extra_rdoc_files: []
61
103
  files:
62
- - .gitignore
104
+ - ".gitignore"
63
105
  - Gemfile
64
106
  - LICENSE.txt
65
107
  - README.md
66
108
  - Rakefile
67
109
  - betfair_api_ng_rails.gemspec
68
110
  - lib/betfair_api_ng_rails.rb
69
- - lib/betfair_api_ng_rails/api/base_provider.rb
70
- - lib/betfair_api_ng_rails/api/bf/concerns/errorable.rb
71
- - lib/betfair_api_ng_rails/api/bf/config.rb
72
- - lib/betfair_api_ng_rails/api/bf/constants.rb
73
- - lib/betfair_api_ng_rails/api/bf/data/attributes.rb
74
- - lib/betfair_api_ng_rails/api/bf/data/base.rb
75
- - lib/betfair_api_ng_rails/api/bf/data/competition.rb
76
- - lib/betfair_api_ng_rails/api/bf/data/competition_result.rb
77
- - lib/betfair_api_ng_rails/api/bf/data/concerns/hashable.rb
78
- - lib/betfair_api_ng_rails/api/bf/data/concerns/querable.rb
79
- - lib/betfair_api_ng_rails/api/bf/data/constants.rb
80
- - lib/betfair_api_ng_rails/api/bf/data/event.rb
81
- - lib/betfair_api_ng_rails/api/bf/data/event_result.rb
82
- - lib/betfair_api_ng_rails/api/bf/data/event_type.rb
83
- - lib/betfair_api_ng_rails/api/bf/data/event_type_result.rb
84
- - lib/betfair_api_ng_rails/api/bf/data/market_filter.rb
85
- - lib/betfair_api_ng_rails/api/bf/data/time_range.rb
86
- - lib/betfair_api_ng_rails/api/bf/data/time_range_result.rb
87
- - lib/betfair_api_ng_rails/api/bf/enums/bet_status.rb
88
- - lib/betfair_api_ng_rails/api/bf/enums/concerns/enumable.rb
89
- - lib/betfair_api_ng_rails/api/bf/enums/execution_report_error_code.rb
90
- - lib/betfair_api_ng_rails/api/bf/enums/execution_report_status.rb
91
- - lib/betfair_api_ng_rails/api/bf/enums/group_by.rb
92
- - lib/betfair_api_ng_rails/api/bf/enums/instruction_report_error_code.rb
93
- - lib/betfair_api_ng_rails/api/bf/enums/instruction_report_status.rb
94
- - lib/betfair_api_ng_rails/api/bf/enums/market_betting_type.rb
95
- - lib/betfair_api_ng_rails/api/bf/enums/market_projection.rb
96
- - lib/betfair_api_ng_rails/api/bf/enums/market_sort.rb
97
- - lib/betfair_api_ng_rails/api/bf/enums/market_status.rb
98
- - lib/betfair_api_ng_rails/api/bf/enums/match_projection.rb
99
- - lib/betfair_api_ng_rails/api/bf/enums/order_by.rb
100
- - lib/betfair_api_ng_rails/api/bf/enums/order_projection.rb
101
- - lib/betfair_api_ng_rails/api/bf/enums/order_status.rb
102
- - lib/betfair_api_ng_rails/api/bf/enums/order_type.rb
103
- - lib/betfair_api_ng_rails/api/bf/enums/persistence_type.rb
104
- - lib/betfair_api_ng_rails/api/bf/enums/price_data.rb
105
- - lib/betfair_api_ng_rails/api/bf/enums/rollup_model.rb
106
- - lib/betfair_api_ng_rails/api/bf/enums/runner_status.rb
107
- - lib/betfair_api_ng_rails/api/bf/enums/side.rb
108
- - lib/betfair_api_ng_rails/api/bf/enums/sort_dir.rb
109
- - lib/betfair_api_ng_rails/api/bf/enums/time_granularity.rb
110
- - lib/betfair_api_ng_rails/api/bf/formatters/js_tree_formatter.rb
111
- - lib/betfair_api_ng_rails/api/bf/helper.rb
112
- - lib/betfair_api_ng_rails/api/bf/http/factory.rb
113
- - lib/betfair_api_ng_rails/api/bf/http/requester.rb
114
- - lib/betfair_api_ng_rails/api/bf/http/responser.rb
115
- - lib/betfair_api_ng_rails/api/bf/orm/parsers/base.rb
116
- - lib/betfair_api_ng_rails/api/bf/orm/parsers/list_competitions.rb
117
- - lib/betfair_api_ng_rails/api/bf/orm/parsers/list_event_types.rb
118
- - lib/betfair_api_ng_rails/api/bf/orm/parsers/list_events.rb
119
- - lib/betfair_api_ng_rails/api/bf/orm/requester.rb
120
- - lib/betfair_api_ng_rails/api/bf/provider.rb
121
- - lib/betfair_api_ng_rails/api/bf/session_manager.rb
111
+ - lib/betfair_api_ng_rails/api/concerns/errorable.rb
112
+ - lib/betfair_api_ng_rails/api/config.rb
113
+ - lib/betfair_api_ng_rails/api/connection.rb
114
+ - lib/betfair_api_ng_rails/api/connection_ext/formatting.rb
115
+ - lib/betfair_api_ng_rails/api/connection_ext/parsing.rb
116
+ - lib/betfair_api_ng_rails/api/constants.rb
117
+ - lib/betfair_api_ng_rails/api/data/attributes.rb
118
+ - lib/betfair_api_ng_rails/api/data/base.rb
119
+ - lib/betfair_api_ng_rails/api/data/competition.rb
120
+ - lib/betfair_api_ng_rails/api/data/competition_result.rb
121
+ - lib/betfair_api_ng_rails/api/data/concerns/hashable.rb
122
+ - lib/betfair_api_ng_rails/api/data/constants.rb
123
+ - lib/betfair_api_ng_rails/api/data/country_code_result.rb
124
+ - lib/betfair_api_ng_rails/api/data/event.rb
125
+ - lib/betfair_api_ng_rails/api/data/event_result.rb
126
+ - lib/betfair_api_ng_rails/api/data/event_type.rb
127
+ - lib/betfair_api_ng_rails/api/data/event_type_result.rb
128
+ - lib/betfair_api_ng_rails/api/data/market_filter.rb
129
+ - lib/betfair_api_ng_rails/api/data/market_type_result.rb
130
+ - lib/betfair_api_ng_rails/api/data/time_range.rb
131
+ - lib/betfair_api_ng_rails/api/data/time_range_result.rb
132
+ - lib/betfair_api_ng_rails/api/data/venue_result.rb
133
+ - lib/betfair_api_ng_rails/api/enums/bet_status.rb
134
+ - lib/betfair_api_ng_rails/api/enums/concerns/enumable.rb
135
+ - lib/betfair_api_ng_rails/api/enums/execution_report_error_code.rb
136
+ - lib/betfair_api_ng_rails/api/enums/execution_report_status.rb
137
+ - lib/betfair_api_ng_rails/api/enums/group_by.rb
138
+ - lib/betfair_api_ng_rails/api/enums/instruction_report_error_code.rb
139
+ - lib/betfair_api_ng_rails/api/enums/instruction_report_status.rb
140
+ - lib/betfair_api_ng_rails/api/enums/market_betting_type.rb
141
+ - lib/betfair_api_ng_rails/api/enums/market_projection.rb
142
+ - lib/betfair_api_ng_rails/api/enums/market_sort.rb
143
+ - lib/betfair_api_ng_rails/api/enums/market_status.rb
144
+ - lib/betfair_api_ng_rails/api/enums/match_projection.rb
145
+ - lib/betfair_api_ng_rails/api/enums/order_by.rb
146
+ - lib/betfair_api_ng_rails/api/enums/order_projection.rb
147
+ - lib/betfair_api_ng_rails/api/enums/order_status.rb
148
+ - lib/betfair_api_ng_rails/api/enums/order_type.rb
149
+ - lib/betfair_api_ng_rails/api/enums/persistence_type.rb
150
+ - lib/betfair_api_ng_rails/api/enums/price_data.rb
151
+ - lib/betfair_api_ng_rails/api/enums/rollup_model.rb
152
+ - lib/betfair_api_ng_rails/api/enums/runner_status.rb
153
+ - lib/betfair_api_ng_rails/api/enums/side.rb
154
+ - lib/betfair_api_ng_rails/api/enums/sort_dir.rb
155
+ - lib/betfair_api_ng_rails/api/enums/time_granularity.rb
122
156
  - lib/betfair_api_ng_rails/api/formatter_factory.rb
157
+ - lib/betfair_api_ng_rails/api/formatters/js_tree_formatter.rb
158
+ - lib/betfair_api_ng_rails/api/hashalator.rb
159
+ - lib/betfair_api_ng_rails/api/helper.rb
160
+ - lib/betfair_api_ng_rails/api/http/factory.rb
161
+ - lib/betfair_api_ng_rails/api/http/helpers/information_response.rb
162
+ - lib/betfair_api_ng_rails/api/http/helpers/keep_alive_response.rb
163
+ - lib/betfair_api_ng_rails/api/http/helpers/session_response.rb
164
+ - lib/betfair_api_ng_rails/api/http/requester.rb
165
+ - lib/betfair_api_ng_rails/api/http/responser.rb
166
+ - lib/betfair_api_ng_rails/api/parsers/base.rb
167
+ - lib/betfair_api_ng_rails/api/parsers/list_competitions.rb
168
+ - lib/betfair_api_ng_rails/api/parsers/list_countries.rb
169
+ - lib/betfair_api_ng_rails/api/parsers/list_event_types.rb
170
+ - lib/betfair_api_ng_rails/api/parsers/list_events.rb
171
+ - lib/betfair_api_ng_rails/api/parsers/list_market_types.rb
172
+ - lib/betfair_api_ng_rails/api/parsers/list_time_ranges.rb
173
+ - lib/betfair_api_ng_rails/api/parsers/list_venues.rb
174
+ - lib/betfair_api_ng_rails/api/provider.rb
175
+ - lib/betfair_api_ng_rails/api/request_methods.rb
176
+ - lib/betfair_api_ng_rails/api/session_manager.rb
177
+ - lib/betfair_api_ng_rails/errors.rb
178
+ - lib/betfair_api_ng_rails/railtie.rb
123
179
  - lib/betfair_api_ng_rails/version.rb
124
180
  - lib/generators/betfair_api_ng_rails/install/install_generator.rb
125
181
  - lib/generators/betfair_api_ng_rails/install/templates/betfair_api_ng_rails.rb
126
182
  - lib/generators/betfair_api_ng_rails/install/templates/betfair_api_ng_rails.yml
183
+ - spec/betfair_api_ng_rails/api/connection_spec.rb
184
+ - spec/betfair_api_ng_rails/api/data/concerns/hashable_spec.rb
185
+ - spec/betfair_api_ng_rails/api/formatters/js_tree_formatter_spec.rb
186
+ - spec/betfair_api_ng_rails/api/hashalator_spec.rb
187
+ - spec/betfair_api_ng_rails/api/provider_spec.rb
188
+ - spec/betfair_api_ng_rails/api/request_methods_spec.rb
189
+ - spec/betfair_api_ng_rails/api/session_manager_spec.rb
190
+ - spec/betfair_api_ng_rails/integration/list_competitions_spec.rb
191
+ - spec/betfair_api_ng_rails/integration/list_countries_spec.rb
192
+ - spec/betfair_api_ng_rails/integration/list_event_types_spec.rb
193
+ - spec/betfair_api_ng_rails/integration/list_events_spec.rb
194
+ - spec/betfair_api_ng_rails/integration/list_market_types_spec.rb
195
+ - spec/betfair_api_ng_rails/integration/list_time_ranges_spec.rb
196
+ - spec/betfair_api_ng_rails/integration/list_venues_spec.rb
197
+ - spec/spec_helper.rb
198
+ - spec/support/shared_examples/request_method.rb
199
+ - spec/support/shared_examples/simple_list_filtering_request.rb
127
200
  homepage: ''
128
201
  licenses:
129
202
  - MIT
@@ -134,18 +207,35 @@ require_paths:
134
207
  - lib
135
208
  required_ruby_version: !ruby/object:Gem::Requirement
136
209
  requirements:
137
- - - '>='
210
+ - - ">="
138
211
  - !ruby/object:Gem::Version
139
212
  version: '0'
140
213
  required_rubygems_version: !ruby/object:Gem::Requirement
141
214
  requirements:
142
- - - '>='
215
+ - - ">="
143
216
  - !ruby/object:Gem::Version
144
217
  version: '0'
145
218
  requirements: []
146
219
  rubyforge_project:
147
- rubygems_version: 2.0.14
220
+ rubygems_version: 2.2.2
148
221
  signing_key:
149
222
  specification_version: 4
150
223
  summary: Provides accessing betfair.com api-ng using non-interactive login
151
- test_files: []
224
+ test_files:
225
+ - spec/betfair_api_ng_rails/api/connection_spec.rb
226
+ - spec/betfair_api_ng_rails/api/data/concerns/hashable_spec.rb
227
+ - spec/betfair_api_ng_rails/api/formatters/js_tree_formatter_spec.rb
228
+ - spec/betfair_api_ng_rails/api/hashalator_spec.rb
229
+ - spec/betfair_api_ng_rails/api/provider_spec.rb
230
+ - spec/betfair_api_ng_rails/api/request_methods_spec.rb
231
+ - spec/betfair_api_ng_rails/api/session_manager_spec.rb
232
+ - spec/betfair_api_ng_rails/integration/list_competitions_spec.rb
233
+ - spec/betfair_api_ng_rails/integration/list_countries_spec.rb
234
+ - spec/betfair_api_ng_rails/integration/list_event_types_spec.rb
235
+ - spec/betfair_api_ng_rails/integration/list_events_spec.rb
236
+ - spec/betfair_api_ng_rails/integration/list_market_types_spec.rb
237
+ - spec/betfair_api_ng_rails/integration/list_time_ranges_spec.rb
238
+ - spec/betfair_api_ng_rails/integration/list_venues_spec.rb
239
+ - spec/spec_helper.rb
240
+ - spec/support/shared_examples/request_method.rb
241
+ - spec/support/shared_examples/simple_list_filtering_request.rb