eve-4 2.0.1 → 2.0.2

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 (182) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +0 -0
  4. data/.idea/.name +1 -0
  5. data/.idea/.rakeTasks +7 -0
  6. data/.idea/dictionaries/tylercollins.xml +3 -0
  7. data/.idea/encodings.xml +5 -0
  8. data/.idea/eve-updated.iml +58 -0
  9. data/.idea/misc.xml +5 -0
  10. data/.idea/modules.xml +9 -0
  11. data/.idea/scopes/scope_settings.xml +5 -0
  12. data/.idea/vcs.xml +7 -0
  13. data/.idea/workspace.xml +554 -0
  14. data/Gemfile +2 -0
  15. data/Gemfile.lock +108 -0
  16. data/History.txt +7 -0
  17. data/Rakefile +37 -0
  18. data/eve.gemspec +36 -0
  19. data/lib/eve.rb +26 -0
  20. data/lib/eve/api.rb +249 -0
  21. data/lib/eve/api/connectivity.rb +39 -0
  22. data/lib/eve/api/request.rb +80 -0
  23. data/lib/eve/api/response.rb +34 -0
  24. data/lib/eve/api/response/result.rb +87 -0
  25. data/lib/eve/api/response/row.rb +42 -0
  26. data/lib/eve/api/response/rowset.rb +18 -0
  27. data/lib/eve/api/services.rb +20 -0
  28. data/lib/eve/api/services/account.rb +12 -0
  29. data/lib/eve/api/services/character.rb +96 -0
  30. data/lib/eve/api/services/corporation.rb +150 -0
  31. data/lib/eve/api/services/eve.rb +76 -0
  32. data/lib/eve/api/services/map.rb +45 -0
  33. data/lib/eve/api/services/misc.rb +24 -0
  34. data/lib/eve/api/services/server.rb +20 -0
  35. data/lib/eve/dependencies.rb +48 -0
  36. data/lib/eve/deprecation.rb +3 -0
  37. data/lib/eve/errors.rb +129 -0
  38. data/lib/eve/errors/authentication_errors.rb +33 -0
  39. data/lib/eve/errors/internal_errors.rb +64 -0
  40. data/lib/eve/errors/miscellaneous_errors.rb +19 -0
  41. data/lib/eve/errors/user_input_errors.rb +62 -0
  42. data/lib/eve/javascript_helper.rb +196 -0
  43. data/lib/eve/trust.rb +87 -0
  44. data/lib/eve/trust/controller_helpers.rb +86 -0
  45. data/lib/eve/trust/igb_interface.rb +92 -0
  46. data/lib/eve/trust/mime_types.rb +4 -0
  47. data/lib/eve/version.rb +8 -0
  48. data/log/development.log +30 -0
  49. data/spec/controllers/controller_helpers_spec.rb +91 -0
  50. data/spec/helpers/javascript_helper_spec.rb +80 -0
  51. data/spec/helpers/view_helper_spec.rb +7 -0
  52. data/spec/lib/eve/api/calls/account/characters_spec.rb +22 -0
  53. data/spec/lib/eve/api/calls/character/account_balance_spec.rb +21 -0
  54. data/spec/lib/eve/api/calls/character/asset_list_spec.rb +23 -0
  55. data/spec/lib/eve/api/calls/character/character_sheet_spec.rb +51 -0
  56. data/spec/lib/eve/api/calls/character/fac_war_stats_spec.rb +31 -0
  57. data/spec/lib/eve/api/calls/character/industry_jobs_spec.rb +27 -0
  58. data/spec/lib/eve/api/calls/character/kill_log_spec.rb +27 -0
  59. data/spec/lib/eve/api/calls/character/mail_messages_spec.rb +21 -0
  60. data/spec/lib/eve/api/calls/character/mailing_lists_spec.rb +21 -0
  61. data/spec/lib/eve/api/calls/character/market_orders_spec.rb +21 -0
  62. data/spec/lib/eve/api/calls/character/medals_spec.rb +24 -0
  63. data/spec/lib/eve/api/calls/character/research_spec.rb +21 -0
  64. data/spec/lib/eve/api/calls/character/skill_in_training_spec.rb +44 -0
  65. data/spec/lib/eve/api/calls/character/skill_queue_spec.rb +21 -0
  66. data/spec/lib/eve/api/calls/character/standings_spec.rb +26 -0
  67. data/spec/lib/eve/api/calls/character/wallet_journal_spec.rb +21 -0
  68. data/spec/lib/eve/api/calls/character/wallet_transactions_spec.rb +21 -0
  69. data/spec/lib/eve/api/calls/character_portrait_spec.rb +17 -0
  70. data/spec/lib/eve/api/calls/corporation/account_balances_spec.rb +21 -0
  71. data/spec/lib/eve/api/calls/corporation/asset_list_spec.rb +25 -0
  72. data/spec/lib/eve/api/calls/corporation/container_log_spec.rb +23 -0
  73. data/spec/lib/eve/api/calls/corporation/corporation_sheet_spec.rb +36 -0
  74. data/spec/lib/eve/api/calls/corporation/fac_war_stats_spec.rb +23 -0
  75. data/spec/lib/eve/api/calls/corporation/industry_jobs_spec.rb +30 -0
  76. data/spec/lib/eve/api/calls/corporation/kill_log_spec.rb +27 -0
  77. data/spec/lib/eve/api/calls/corporation/market_orders_spec.rb +22 -0
  78. data/spec/lib/eve/api/calls/corporation/medals_spec.rb +21 -0
  79. data/spec/lib/eve/api/calls/corporation/member_medals_spec.rb +21 -0
  80. data/spec/lib/eve/api/calls/corporation/member_security_log_spec.rb +24 -0
  81. data/spec/lib/eve/api/calls/corporation/member_security_spec.rb +25 -0
  82. data/spec/lib/eve/api/calls/corporation/member_tracking_spec.rb +22 -0
  83. data/spec/lib/eve/api/calls/corporation/shareholders_spec.rb +23 -0
  84. data/spec/lib/eve/api/calls/corporation/standings_spec.rb +30 -0
  85. data/spec/lib/eve/api/calls/corporation/starbase_detail_spec.rb +32 -0
  86. data/spec/lib/eve/api/calls/corporation/starbase_list_spec.rb +22 -0
  87. data/spec/lib/eve/api/calls/corporation/titles_spec.rb +26 -0
  88. data/spec/lib/eve/api/calls/corporation/wallet_journal_spec.rb +22 -0
  89. data/spec/lib/eve/api/calls/corporation/wallet_transactions_spec.rb +22 -0
  90. data/spec/lib/eve/api/calls/empty_call_spec.rb +29 -0
  91. data/spec/lib/eve/api/calls/eve/alliance_list_spec.rb +26 -0
  92. data/spec/lib/eve/api/calls/eve/certificate_tree_spec.rb +18 -0
  93. data/spec/lib/eve/api/calls/eve/character_id_spec.rb +27 -0
  94. data/spec/lib/eve/api/calls/eve/conquerable_station_list_spec.rb +11 -0
  95. data/spec/lib/eve/api/calls/eve/error_list_spec.rb +21 -0
  96. data/spec/lib/eve/api/calls/eve/fac_war_stats_spec.rb +25 -0
  97. data/spec/lib/eve/api/calls/eve/fac_war_top_stats_spec.rb +54 -0
  98. data/spec/lib/eve/api/calls/eve/ref_types_spec.rb +11 -0
  99. data/spec/lib/eve/api/calls/eve/skill_tree_spec.rb +17 -0
  100. data/spec/lib/eve/api/calls/map/fac_war_systems_spec.rb +11 -0
  101. data/spec/lib/eve/api/calls/map/jumps_spec.rb +11 -0
  102. data/spec/lib/eve/api/calls/map/kills_spec.rb +11 -0
  103. data/spec/lib/eve/api/calls/map/sovereignty_spec.rb +11 -0
  104. data/spec/lib/eve/api/calls/server_status_spec.rb +28 -0
  105. data/spec/lib/eve/api/request_spec.rb +18 -0
  106. data/spec/lib/eve/api/response/error_spec.rb +13 -0
  107. data/spec/lib/eve/api/response_spec.rb +79 -0
  108. data/spec/lib/eve/api_spec.rb +13 -0
  109. data/spec/lib/eve/core_extensions/hash_spec.rb +23 -0
  110. data/spec/lib/eve/core_extensions/string_spec.rb +8 -0
  111. data/spec/lib/eve/trust/igb_interface_spec.rb +112 -0
  112. data/spec/log/development.log +0 -0
  113. data/spec/rcov.opts +2 -0
  114. data/spec/readme_spec.rb +36 -0
  115. data/spec/sample_api_key.yml +20 -0
  116. data/spec/spec.opts +4 -0
  117. data/spec/spec_helper.rb +63 -0
  118. data/spec/support/behaves_like_rowset.rb +50 -0
  119. data/spec/support/controllers/trust_controller.rb +24 -0
  120. data/spec/support/jpg/mock_portrait.jpg +0 -0
  121. data/spec/support/mock_api_helpers.rb +46 -0
  122. data/spec/support/views/trust/html_and_igb.html.erb +1 -0
  123. data/spec/support/views/trust/html_and_igb.igb.erb +1 -0
  124. data/spec/support/views/trust/html_only.html.erb +1 -0
  125. data/spec/support/views/trust/igb_only.igb.erb +1 -0
  126. data/spec/support/xml/account/characters.xml +15 -0
  127. data/spec/support/xml/character/account_balance.xml +10 -0
  128. data/spec/support/xml/character/asset_list.xml +50 -0
  129. data/spec/support/xml/character/character_sheet.xml +65 -0
  130. data/spec/support/xml/character/fac_war_stats.xml +20 -0
  131. data/spec/support/xml/character/industry_jobs.xml +70 -0
  132. data/spec/support/xml/character/kill_log.xml +51 -0
  133. data/spec/support/xml/character/mail_messages.xml +12 -0
  134. data/spec/support/xml/character/mailing_lists.xml +12 -0
  135. data/spec/support/xml/character/market_orders.xml +11 -0
  136. data/spec/support/xml/character/medals.xml +13 -0
  137. data/spec/support/xml/character/research.xml +13 -0
  138. data/spec/support/xml/character/skill_in_training.xml +14 -0
  139. data/spec/support/xml/character/skill_not_in_training.xml +7 -0
  140. data/spec/support/xml/character/skill_queue.xml +11 -0
  141. data/spec/support/xml/character/standings.xml +32 -0
  142. data/spec/support/xml/character/wallet_journal.xml +39 -0
  143. data/spec/support/xml/character/wallet_transactions.xml +44 -0
  144. data/spec/support/xml/corporation/account_balance.xml +15 -0
  145. data/spec/support/xml/corporation/asset_list.xml +50 -0
  146. data/spec/support/xml/corporation/container_log.xml +32 -0
  147. data/spec/support/xml/corporation/fac_war_stats.xml +19 -0
  148. data/spec/support/xml/corporation/industry_jobs.xml +70 -0
  149. data/spec/support/xml/corporation/kill_log.xml +51 -0
  150. data/spec/support/xml/corporation/market_orders.xml +37 -0
  151. data/spec/support/xml/corporation/medals.xml +8 -0
  152. data/spec/support/xml/corporation/member_corporation_sheet.xml +51 -0
  153. data/spec/support/xml/corporation/member_medals.xml +10 -0
  154. data/spec/support/xml/corporation/member_security.xml +21 -0
  155. data/spec/support/xml/corporation/member_security_log.xml +55 -0
  156. data/spec/support/xml/corporation/member_tracking.xml +18 -0
  157. data/spec/support/xml/corporation/non_member_corporation_sheet.xml +30 -0
  158. data/spec/support/xml/corporation/shareholders.xml +11 -0
  159. data/spec/support/xml/corporation/standings.xml +33 -0
  160. data/spec/support/xml/corporation/starbase_detail.xml +33 -0
  161. data/spec/support/xml/corporation/starbase_list.xml +17 -0
  162. data/spec/support/xml/corporation/titles.xml +34 -0
  163. data/spec/support/xml/corporation/wallet_journal.xml +40 -0
  164. data/spec/support/xml/corporation/wallet_transactions.xml +12 -0
  165. data/spec/support/xml/errors/106.xml +5 -0
  166. data/spec/support/xml/errors/516.xml +5 -0
  167. data/spec/support/xml/eve/alliance_list.xml +22 -0
  168. data/spec/support/xml/eve/certificate_tree.xml +49 -0
  169. data/spec/support/xml/eve/character_id.xml +15 -0
  170. data/spec/support/xml/eve/conquerable_station_list.xml +24 -0
  171. data/spec/support/xml/eve/error_list.xml +78 -0
  172. data/spec/support/xml/eve/fac_war_stats.xml +31 -0
  173. data/spec/support/xml/eve/fac_war_top_stats.xml +238 -0
  174. data/spec/support/xml/eve/ref_types.xml +105 -0
  175. data/spec/support/xml/eve/skill_tree.xml +52 -0
  176. data/spec/support/xml/map/fac_war_systems.xml +180 -0
  177. data/spec/support/xml/map/jumps.xml +166 -0
  178. data/spec/support/xml/map/kills.xml +191 -0
  179. data/spec/support/xml/map/sovereignty.xml +20 -0
  180. data/spec/support/xml/rowset_with_mismatched_attributes.xml +6 -0
  181. data/spec/support/xml/server/server_status.xml +9 -0
  182. metadata +310 -2
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe String do
4
+ it "#dehumanize" do
5
+ "say_hello_to_the_world".camelize.dehumanize.should == "sayHelloToTheWorld"
6
+ "Say hello to the world".dehumanize.should == "say_hello_to_the_world"
7
+ end
8
+ end
@@ -0,0 +1,112 @@
1
+ require 'spec_helper'
2
+
3
+ describe Eve::Trust::IgbInterface do
4
+ igb_headers = {
5
+ 'HTTP_USER_AGENT' => 'eve-minibrowser',
6
+ 'HTTP_EVE_TRUSTED' => 'yes',
7
+ 'HTTP_EVE_SERVERIP' => '1.2.3.4',
8
+ 'HTTP_EVE_CHARNAME' => 'Jolia Darkstrider',
9
+ 'HTTP_EVE_CHARID' => '1234567890',
10
+ 'HTTP_EVE_CORPNAME' => 'Frogs of Armageddon',
11
+ 'HTTP_EVE_CORPID' => '9876543210',
12
+ 'HTTP_EVE_ALLIANCENAME' => 'Afro Mexicans',
13
+ 'HTTP_EVE_ALLIANCEID' => '1928374',
14
+ 'HTTP_EVE_REGIONNAME' => 'Solitude',
15
+ 'HTTP_EVE_CONSTELLATIONNAME' => 'Morbault',
16
+ 'HTTP_EVE_SOLARSYSTEMNAME' => 'Elore',
17
+ 'HTTP_EVE_STATIONNAME' => 'Caldari Navy Assembly Plant',
18
+ 'HTTP_EVE_STATIONID' => '1234',
19
+ 'HTTP_EVE_CORPROLE' => '0'
20
+ }
21
+ igb_requested_headers = {
22
+ 'HTTP_EVE_MILITIANAME' => 'militia name',
23
+ 'HTTP_EVE_MILITIAID' => '1234567',
24
+ 'HTTP_EVE_REGIONID' => '1929',
25
+ 'HTTP_EVE_CONSTELLATIONID' => '100',
26
+ 'HTTP_EVE_SOLARSYSTEMID' => '101',
27
+ 'HTTP_EVE_SHIPID' => '102',
28
+ 'HTTP_EVE_SYSTEMSECURITY' => '0.9',
29
+ 'HTTP_EVE_VALIDATION_STRING' => 'abcdefghijklmnopqrstuvwxyz'
30
+ }
31
+
32
+ subject { Eve::Trust::IgbInterface.new(ActionDispatch::Request.new(@rack_env)) }
33
+
34
+ shared_examples_for "any igb with trust" do
35
+ it "should be trusted" do
36
+ subject.trusted?.should be_true
37
+ end
38
+
39
+ it "should convert strings to objects using YAML where possible" do
40
+ subject.char_id.should == 1234567890
41
+ subject.corp_id.should == 9876543210
42
+ subject.alliance_id.should == 1928374
43
+ subject.station_id.should == 1234
44
+ subject.corp_role.should == 0
45
+ end
46
+
47
+ it "should have all methods delegated properly" do
48
+ subject.server_ip.should == '1.2.3.4'
49
+ subject.char_name.should == 'Jolia Darkstrider'
50
+ subject.corp_name.should == 'Frogs of Armageddon'
51
+ subject.alliance_name.should == 'Afro Mexicans'
52
+ subject.region_name.should == 'Solitude'
53
+ subject.constellation_name.should == 'Morbault'
54
+ subject.solar_system_name.should == 'Elore'
55
+ subject.station_name.should == 'Caldari Navy Assembly Plant'
56
+ end
57
+ end
58
+
59
+ context "using new igb - moondoggie" do
60
+ before(:all) do
61
+ @rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0 EVE-IGB ')
62
+ end
63
+
64
+ it "should be considered an igb" do
65
+ subject.igb?.should be_true
66
+ end
67
+ end
68
+
69
+ context "without any IGB headers" do
70
+ before(:all) do
71
+ @rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '', 'HTTP_USER_AGENT' => 'eve-minibrowser')
72
+ end
73
+
74
+ it("should not be trusted") { subject.trusted?.should_not be_true }
75
+ end
76
+
77
+ context "without trust" do
78
+ before(:all) do
79
+ @rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '',
80
+ 'HTTP_USER_AGENT' => 'eve-minibrowser',
81
+ 'HTTP_EVE_TRUST' => 'no')
82
+ end
83
+
84
+ it("should not be trusted") { subject.trusted?.should_not be_true }
85
+ end
86
+
87
+ context "with trust" do
88
+ it_should_behave_like "any igb with trust"
89
+ before(:all) do
90
+ @rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '').merge(igb_headers)
91
+ end
92
+
93
+ context "after requests are implemented" do
94
+ it_should_behave_like "any igb with trust"
95
+
96
+ before(:all) do
97
+ @rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '').merge(igb_headers).merge(igb_requested_headers)
98
+ end
99
+
100
+ it "should load the additional data" do
101
+ subject.militia_name.should == 'militia name'
102
+ subject.militia_id.should == 1234567
103
+ subject.region_id.should == 1929
104
+ subject.constellation_id.should == 100
105
+ subject.solar_system_id.should == 101
106
+ subject.ship_id.should == 102
107
+ subject.system_security.should == 0.9
108
+ subject.validation_string.should == 'abcdefghijklmnopqrstuvwxyz'
109
+ end
110
+ end
111
+ end
112
+ end
File without changes
data/spec/rcov.opts ADDED
@@ -0,0 +1,2 @@
1
+ --exclude "spec/*,gems/*"
2
+ --aggregate coverage.data
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ # Runs the examples found in the synopsis of the README.rdoc file. We need to verify that they work because they should
4
+ # be copy-and-paste ready.
5
+
6
+ if !$mock_services # only run these if the credentials are (theoretically) valid
7
+ describe "Readme Examples" do
8
+ it "should be copy-and-paste ready" do
9
+ # Get the current server status
10
+ api = Eve::API.new()
11
+ server_status = api.server_status
12
+ puts "Server reports status #{server_status.server_open ? "ONLINE" : "OFFLINE"}"
13
+ puts "\tCurrent time is #{server_status.current_time}"
14
+ puts "\t#{server_status.online_players} players currently online"
15
+ puts
16
+
17
+ # Get a list of characters
18
+ api = Eve::API.new(:user_id => $user_id, :api_key => $limited_api_key)
19
+ result = api.account.characters
20
+ puts "Choose a character:"
21
+ result.characters.each_with_index { |char, index| puts "\t#{index}: #{char.name} (#{char.character_id})" }
22
+ choice = gets.chomp.to_i
23
+ puts
24
+
25
+ # Get the current training queue. Need a full API key and a character ID for that.
26
+ api.set(:api_key => $full_api_key, :character_id => result.characters[choice].character_id)
27
+ result = api.character.skill_queue
28
+ result.skillqueue.each do |skill|
29
+ result.skillqueue.columns.each do |column|
30
+ print column.ljust(20), ":\t", skill[column], "\n"
31
+ end
32
+ puts
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ # This information can be retrieved from http://www.eveonline.com/api/default.asp
2
+ #
3
+ # ! IMPORTANT !
4
+ # Copy this file to "api_key.yml" in the same directory. This file ("sample_api_key.yml")
5
+ # is not even used, and if you put your real API info into it there's a fair chance you'll
6
+ # wind up accidentally committing it. The "api_key.yml" file is already in .gitignore, so
7
+ # you won't do so if you remember to copy this file first.
8
+ #
9
+ # Note that it doesn't really matter what any of this stuff is if $mock_services is true,
10
+ # which it really always should be unless you need to test end-to-end connectivity.
11
+ #
12
+ # Note, also, that the tests were designed around mock data. They WILL fail if you use real
13
+ # data. However, you should be able to judge pretty easily by the error messages whether
14
+ # they're failing because of the data mismatch, or whether they're failing for some other
15
+ # (more catastrophic) reason.
16
+ #
17
+ User ID: your_user_id
18
+ Limited API Key: your_limited_api_key
19
+ Full API Key: your_full_api_key
20
+ Character ID: your_character_id
data/spec/spec.opts ADDED
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,63 @@
1
+ begin
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ Bundler.setup
5
+ rescue LoadError
6
+ puts " *** You don't seem to have Bundler installed. ***"
7
+ puts " Please run the following command:"
8
+ puts
9
+ puts " gem install bundler"
10
+ exit
11
+ end
12
+
13
+ require File.join(File.dirname(__FILE__), '../lib/eve')
14
+ require 'rails'
15
+ ##require "active_record/railtie"
16
+ require "action_controller/railtie"
17
+ ##require "action_mailer/railtie"
18
+ ##require "active_resource/railtie"
19
+ require "rails/test_unit/railtie"
20
+ #require 'rails/all'
21
+ require 'rspec/rails'
22
+
23
+ # set up Rails3 mock application
24
+ module Eve
25
+ class MockRailsApplication < Rails::Application
26
+ config.encoding = 'utf-8'
27
+ config.filter_parameters += [:password]
28
+ config.active_support.deprecation = :log
29
+ config.paths['app/views'] = "spec/support/views"
30
+ end
31
+ end
32
+
33
+ # Initialize Rails3 mock application
34
+ Eve::MockRailsApplication.initialize!
35
+
36
+ # Set up routing - this is necessary to match params hashes to their controllers/actions,
37
+ # and must come AFTER the app is initialized. If app is initialized, routes are cleared.
38
+ Eve::MockRailsApplication.routes.draw { match ':controller(/:action(/:id(.:format)))' }
39
+
40
+ RSpec.configure do |config|
41
+ config.before { FileUtils.rm_rf Rails.root.join('tmp') }
42
+ end
43
+
44
+ # Set to false to disable mock web service responses. Real requests will be used
45
+ # whenever Eve.cache does not suffice. The API information above must be real and
46
+ # valid in this case.
47
+ $mock_services = true
48
+
49
+ keyfile = File.join(File.dirname(__FILE__), 'api_key.yml')
50
+ cred_hash = !$mock_services && File.file?(keyfile) ? YAML::load(File.read(keyfile)) || {} : {}
51
+
52
+ # ! IMPORTANT !
53
+ # It's a lot safer to put this information in a file called "api_key.yml" in the same
54
+ # directory as spec_helper.rb. This file is in the .gitignore list and so you won't
55
+ # accidentally commit your API key that way. Leave the hash below for FAKE data (which
56
+ # is what you'll usually spec with anyways), unless $mock_services == false.
57
+ #
58
+ $user_id = cred_hash['User ID'] || '01234567890'
59
+ $limited_api_key = cred_hash['Limited API Key'] || 'a_valid_limited_api_key'
60
+ $full_api_key = cred_hash['Full API Key'] || 'a_valid_full_api_key'
61
+ $character_id = cred_hash['Character ID'] || '0123456789'
62
+
63
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each { |f| require f }
@@ -0,0 +1,50 @@
1
+ class BehavesLikeRowset
2
+ attr_reader :failure_message, :negative_failure_message
3
+
4
+ def initialize(columns, &block)
5
+ @expected_columns = (columns.kind_of?(Array) ? columns : columns.split(/,/)).collect { |c| c.strip }
6
+ @block = block if block_given?
7
+ @missing = []
8
+ end
9
+
10
+ def matches?(target)
11
+ @target = target
12
+ check_for_column_mismatches
13
+
14
+ @target.each_with_index do |row, index|
15
+ @expected_columns.each do |column|
16
+ check_column(row, column)
17
+ end
18
+ return false if !check_for_missing(index)
19
+ @block.call(row) if @block
20
+ end
21
+ true
22
+ end
23
+
24
+ private
25
+ def check_for_missing(id)
26
+ if !@missing.empty?
27
+ @failure_message = "expected row #{id} in #{@target.inspect} to respond_to each of #{@missing.inspect}"
28
+ @negative_failure_message = "expected row in #{@target.inspect} not to respond_to each of #{@missing.inspect}"
29
+ return false
30
+ end
31
+ true
32
+ end
33
+
34
+ def check_for_column_mismatches
35
+ @target.columns.should == @expected_columns
36
+ end
37
+
38
+ def check_column(row, column)
39
+ check_for_response(row, column)
40
+ check_for_response(row, column.underscore)
41
+ end
42
+
43
+ def check_for_response(row, method_name)
44
+ @missing << method_name if !row.respond_to?(method_name)
45
+ end
46
+ end
47
+
48
+ def behave_like_rowset(expected_columns, &block)
49
+ BehavesLikeRowset.new(expected_columns, &block)
50
+ end
@@ -0,0 +1,24 @@
1
+ class TrustController < ActionController::Base
2
+ prefers_trust
3
+ #requires_trust
4
+
5
+ def index
6
+ render :nothing => true
7
+ end
8
+
9
+ def no_templates
10
+
11
+ end
12
+
13
+ def igb_only
14
+
15
+ end
16
+
17
+ def html_only
18
+
19
+ end
20
+
21
+ def html_and_igb
22
+
23
+ end
24
+ end
Binary file
@@ -0,0 +1,46 @@
1
+ module MockAPIHelpers
2
+ def eve_api(options = {})
3
+ @eve_api ||= {}
4
+ @eve_api[ActiveSupport::Cache.expand_cache_key(options)] ||= ::Eve::API.new(options)
5
+ end
6
+ alias api eve_api
7
+
8
+ def mock_response_body(base, service = nil)
9
+ if service.nil?
10
+ fi = File.expand_path File.join("spec/support", base)
11
+ else
12
+ namespace = base
13
+ service = service.to_s.underscore
14
+ fi = File.expand_path File.join("spec/support/xml", namespace.to_s, "#{service}.xml")
15
+ end
16
+ raise "Cannot find mock request for (#{base}, #{service}) - expected it in #{fi}" unless File.file?(fi)
17
+ return File.read(fi)
18
+ end
19
+
20
+ def mock_http_response(base, service = nil)
21
+ mock = mock('Net::HTTPOK', :body => mock_response_body(base, service))
22
+ end
23
+
24
+ def mock_service(base, options = {}, more_options = {})
25
+ options = { :service => options } unless options.kind_of?(Hash)
26
+ options.merge! more_options
27
+ if $mock_services
28
+ Net::HTTP.should_receive(:post_form).any_number_of_times.and_return(mock_http_response(base,
29
+ options[:service]))
30
+ end
31
+ if options[:service] && eve_api(options).respond_to?(base)
32
+ eve_api(options).send(base).send(options[:service], *(options[:args] || []))
33
+ # If having trouble with mock services, this may be of some help, but it alters how the API can be
34
+ # interacted with (most notably for spec/lib/eve/api/calls/server_status_spec.rb) so it should be
35
+ # disabled when no issues are showing up.
36
+ # elsif options[:service]
37
+ # raise "Service '#{options[:service]}' specified but API doesn't respond to '#{base}'"
38
+ else
39
+ eve_api(options)
40
+ end
41
+ end
42
+ end
43
+
44
+ RSpec.configure do |config|
45
+ config.include(MockAPIHelpers)
46
+ end
@@ -0,0 +1 @@
1
+ HTML and IGB (HTML)
@@ -0,0 +1 @@
1
+ HTML and IGB (IGB)
@@ -0,0 +1 @@
1
+ HTML Only
@@ -0,0 +1 @@
1
+ IGB Only
@@ -0,0 +1,15 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="1">
3
+ <currentTime>2007-12-12 11:48:50</currentTime>
4
+ <result>
5
+ <rowset name="characters" key="characterID" columns="name,characterID,corporationName,corporationID">
6
+ <row name="Mary" characterID="150267069"
7
+ corporationName="Starbase Anchoring Corp" corporationID="150279367" />
8
+ <row name="Marcus" characterID="150302299"
9
+ corporationName="Marcus Corp" corporationID="150333466" />
10
+ <row name="Dieinafire" characterID="150340823"
11
+ corporationName="Center for Advanced Studies" corporationID="1000169" />
12
+ </rowset>
13
+ </result>
14
+ <cachedUntil>2007-12-12 12:48:50</cachedUntil>
15
+ </eveapi>
@@ -0,0 +1,10 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="2">
3
+ <currentTime>2007-12-16 11:55:31</currentTime>
4
+ <result>
5
+ <rowset name="accounts" key="accountID" columns="accountID,accountKey,balance">
6
+ <row accountID="4807144" accountKey="1000" balance="209127823.31" />
7
+ </rowset>
8
+ </result>
9
+ <cachedUntil>2007-12-16 12:10:31</cachedUntil>
10
+ </eveapi>
@@ -0,0 +1,50 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="1">
3
+ <currentTime>2007-12-01 17:55:07</currentTime>
4
+ <result>
5
+ <rowset name="assets" key="itemID" columns="itemID,locationID,typeID,quantity,flag,singleton">
6
+ <row itemID="150354641" locationID="30000380" typeID="11019" quantity="1" flag="0" singleton="1">
7
+ <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
8
+ <row itemID="150354709" typeID="16275" quantity="200000" flag="5" singleton="0" />
9
+ <row itemID="150354710" typeID="16272" quantity="150000" flag="5" singleton="0" />
10
+ <row itemID="150354711" typeID="16273" quantity="150000" flag="5" singleton="0" />
11
+ <row itemID="150354712" typeID="24597" quantity="1000" flag="5" singleton="0" />
12
+ <row itemID="150354713" typeID="24596" quantity="1000" flag="5" singleton="0" />
13
+ <row itemID="150354714" typeID="24595" quantity="1000" flag="5" singleton="0" />
14
+ <row itemID="150354715" typeID="24594" quantity="1000" flag="5" singleton="0" />
15
+ <row itemID="150354716" typeID="24593" quantity="1000" flag="5" singleton="0" />
16
+ <row itemID="150354717" typeID="24592" quantity="1000" flag="5" singleton="0" />
17
+ <row itemID="150354718" typeID="16274" quantity="450000" flag="5" singleton="0" />
18
+ <row itemID="150354719" typeID="9848" quantity="1000" flag="5" singleton="0" />
19
+ <row itemID="150354720" typeID="9832" quantity="8000" flag="5" singleton="0" />
20
+ <row itemID="150354721" typeID="3689" quantity="5000" flag="5" singleton="0" />
21
+ <row itemID="150354722" typeID="3683" quantity="25000" flag="5" singleton="0" />
22
+ <row itemID="150354723" typeID="44" quantity="4000" flag="5" singleton="0" />
23
+ </rowset>
24
+ </row>
25
+ <row itemID="150354706" locationID="30001984" typeID="11019" quantity="1" flag="0" singleton="1">
26
+ <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
27
+ <row itemID="150354741" typeID="24593" quantity="400" flag="5" singleton="0" />
28
+ <row itemID="150354742" typeID="24592" quantity="400" flag="5" singleton="0" />
29
+ <row itemID="150354755" typeID="16275" quantity="199000" flag="5" singleton="0" />
30
+ <row itemID="150354837" typeID="24597" quantity="400" flag="5" singleton="0" />
31
+ <row itemID="150354838" typeID="24596" quantity="400" flag="5" singleton="0" />
32
+ <row itemID="150354839" typeID="24595" quantity="400" flag="5" singleton="0" />
33
+ <row itemID="150354840" typeID="24594" quantity="400" flag="5" singleton="0" />
34
+ <row itemID="150356329" typeID="14343" quantity="1" flag="5" singleton="0" />
35
+ </rowset>
36
+ </row>
37
+ <row itemID="150212056" locationID="60001078" typeID="25851" quantity="10" flag="4" singleton="0" />
38
+ <row itemID="150212057" locationID="60001078" typeID="20424" quantity="20" flag="4" singleton="0" />
39
+ <row itemID="150212058" locationID="60001078" typeID="20421" quantity="20" flag="4" singleton="0" />
40
+ <row itemID="150357641" locationID="30001984" typeID="23" quantity="1" flag="0" singleton="1">
41
+ <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
42
+ <row itemID="150357740" typeID="16275" quantity="9166" flag="0" singleton="0" />
43
+ </rowset>
44
+ </row>
45
+ <row itemID="150212062" locationID="60001078" typeID="944" quantity="1" flag="4" singleton="1" />
46
+ <row itemID="150212063" locationID="60001078" typeID="597" quantity="1" flag="4" singleton="0" />
47
+ </rowset>
48
+ </result>
49
+ <cachedUntil>2007-12-02 16:55:07</cachedUntil>
50
+ </eveapi>