eve 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +174 -0
- data/PostInstall.txt +6 -0
- data/README.rdoc +126 -0
- data/Rakefile +128 -0
- data/features/support/env.rb +1 -0
- data/lib/eve.rb +31 -0
- data/lib/eve/api.rb +247 -0
- data/lib/eve/api/connectivity.rb +39 -0
- data/lib/eve/api/request.rb +74 -0
- data/lib/eve/api/response.rb +100 -0
- data/lib/eve/api/response/inspection.rb +62 -0
- data/lib/eve/api/response/rowset.rb +56 -0
- data/lib/eve/api/response/rowsets.rb +42 -0
- data/lib/eve/api/response/wrap_object.rb +15 -0
- data/lib/eve/api/services.rb +20 -0
- data/lib/eve/api/services/account.rb +12 -0
- data/lib/eve/api/services/character.rb +96 -0
- data/lib/eve/api/services/corporation.rb +150 -0
- data/lib/eve/api/services/eve.rb +76 -0
- data/lib/eve/api/services/map.rb +45 -0
- data/lib/eve/api/services/misc.rb +24 -0
- data/lib/eve/api/services/server.rb +20 -0
- data/lib/eve/core_extensions.rb +3 -0
- data/lib/eve/core_extensions/hash.rb +51 -0
- data/lib/eve/core_extensions/string.rb +11 -0
- data/lib/eve/dependencies.rb +18 -0
- data/lib/eve/errors.rb +129 -0
- data/lib/eve/errors/authentication_errors.rb +33 -0
- data/lib/eve/errors/internal_errors.rb +64 -0
- data/lib/eve/errors/miscellaneous_errors.rb +19 -0
- data/lib/eve/errors/user_input_errors.rb +62 -0
- data/lib/eve/helpers.rb +12 -0
- data/lib/eve/helpers/javascript_helper.rb +198 -0
- data/lib/eve/helpers/view_helper.rb +13 -0
- data/lib/eve/trust.rb +88 -0
- data/lib/eve/trust/controller_helpers.rb +90 -0
- data/lib/eve/trust/igb_interface.rb +88 -0
- data/lib/eve/trust/mime_types.rb +4 -0
- data/script/console +10 -0
- data/script/console.cmd +1 -0
- data/script/destroy +14 -0
- data/script/destroy.cmd +1 -0
- data/script/generate +14 -0
- data/script/generate.cmd +1 -0
- data/spec/lib/eve/api/calls/account/characters_spec.rb +22 -0
- data/spec/lib/eve/api/calls/character/account_balance_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/asset_list_spec.rb +23 -0
- data/spec/lib/eve/api/calls/character/character_sheet_spec.rb +51 -0
- data/spec/lib/eve/api/calls/character/fac_war_stats_spec.rb +31 -0
- data/spec/lib/eve/api/calls/character/industry_jobs_spec.rb +27 -0
- data/spec/lib/eve/api/calls/character/kill_log_spec.rb +27 -0
- data/spec/lib/eve/api/calls/character/mail_messages_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/mailing_lists_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/market_orders_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/medals_spec.rb +24 -0
- data/spec/lib/eve/api/calls/character/research_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/skill_in_training_spec.rb +44 -0
- data/spec/lib/eve/api/calls/character/skill_queue_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/standings_spec.rb +26 -0
- data/spec/lib/eve/api/calls/character/wallet_journal_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character/wallet_transactions_spec.rb +21 -0
- data/spec/lib/eve/api/calls/character_portrait_spec.rb +17 -0
- data/spec/lib/eve/api/calls/corporation/account_balances_spec.rb +21 -0
- data/spec/lib/eve/api/calls/corporation/asset_list_spec.rb +25 -0
- data/spec/lib/eve/api/calls/corporation/container_log_spec.rb +23 -0
- data/spec/lib/eve/api/calls/corporation/corporation_sheet_spec.rb +36 -0
- data/spec/lib/eve/api/calls/corporation/fac_war_stats_spec.rb +23 -0
- data/spec/lib/eve/api/calls/corporation/industry_jobs_spec.rb +30 -0
- data/spec/lib/eve/api/calls/corporation/kill_log_spec.rb +27 -0
- data/spec/lib/eve/api/calls/corporation/market_orders_spec.rb +22 -0
- data/spec/lib/eve/api/calls/corporation/medals_spec.rb +21 -0
- data/spec/lib/eve/api/calls/corporation/member_medals_spec.rb +21 -0
- data/spec/lib/eve/api/calls/corporation/member_security_log_spec.rb +24 -0
- data/spec/lib/eve/api/calls/corporation/member_security_spec.rb +25 -0
- data/spec/lib/eve/api/calls/corporation/member_tracking_spec.rb +22 -0
- data/spec/lib/eve/api/calls/corporation/shareholders_spec.rb +23 -0
- data/spec/lib/eve/api/calls/corporation/standings_spec.rb +30 -0
- data/spec/lib/eve/api/calls/corporation/starbase_detail_spec.rb +32 -0
- data/spec/lib/eve/api/calls/corporation/starbase_list_spec.rb +22 -0
- data/spec/lib/eve/api/calls/corporation/titles_spec.rb +26 -0
- data/spec/lib/eve/api/calls/corporation/wallet_journal_spec.rb +22 -0
- data/spec/lib/eve/api/calls/corporation/wallet_transactions_spec.rb +22 -0
- data/spec/lib/eve/api/calls/empty_call_spec.rb +29 -0
- data/spec/lib/eve/api/calls/eve/alliance_list_spec.rb +26 -0
- data/spec/lib/eve/api/calls/eve/certificate_tree_spec.rb +18 -0
- data/spec/lib/eve/api/calls/eve/character_id_spec.rb +27 -0
- data/spec/lib/eve/api/calls/eve/conquerable_station_list_spec.rb +11 -0
- data/spec/lib/eve/api/calls/eve/error_list_spec.rb +21 -0
- data/spec/lib/eve/api/calls/eve/fac_war_stats_spec.rb +25 -0
- data/spec/lib/eve/api/calls/eve/fac_war_top_stats_spec.rb +54 -0
- data/spec/lib/eve/api/calls/eve/ref_types_spec.rb +11 -0
- data/spec/lib/eve/api/calls/eve/skill_tree_spec.rb +17 -0
- data/spec/lib/eve/api/calls/map/fac_war_systems_spec.rb +11 -0
- data/spec/lib/eve/api/calls/map/jumps_spec.rb +11 -0
- data/spec/lib/eve/api/calls/map/kills_spec.rb +15 -0
- data/spec/lib/eve/api/calls/map/sovereignty_spec.rb +11 -0
- data/spec/lib/eve/api/calls/server_status_spec.rb +24 -0
- data/spec/lib/eve/api/request_spec.rb +17 -0
- data/spec/lib/eve/api/response/error_spec.rb +13 -0
- data/spec/lib/eve/api/response/rowset_spec.rb +28 -0
- data/spec/lib/eve/api/response_spec.rb +79 -0
- data/spec/lib/eve/api_spec.rb +13 -0
- data/spec/lib/eve/core_extensions/hash_spec.rb +23 -0
- data/spec/lib/eve/core_extensions/string_spec.rb +8 -0
- data/spec/lib/eve/helpers/javascript_helper_spec.rb +80 -0
- data/spec/lib/eve/helpers/view_helper_spec.rb +12 -0
- data/spec/lib/eve/trust/controller_helpers_spec.rb +70 -0
- data/spec/lib/eve/trust/igb_interface_spec.rb +102 -0
- data/spec/rcov.opts +2 -0
- data/spec/readme_spec.rb +36 -0
- data/spec/sample_api_key.yml +20 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/behaves_like_rowset.rb +50 -0
- data/spec/support/controllers/trust_controller.rb +7 -0
- data/spec/support/jpg/mock_portrait.jpg +0 -0
- data/spec/support/mock_api_helpers.rb +41 -0
- data/spec/support/xml/account/characters.xml +15 -0
- data/spec/support/xml/character/account_balance.xml +10 -0
- data/spec/support/xml/character/asset_list.xml +50 -0
- data/spec/support/xml/character/character_sheet.xml +65 -0
- data/spec/support/xml/character/fac_war_stats.xml +20 -0
- data/spec/support/xml/character/industry_jobs.xml +70 -0
- data/spec/support/xml/character/kill_log.xml +51 -0
- data/spec/support/xml/character/mail_messages.xml +12 -0
- data/spec/support/xml/character/mailing_lists.xml +12 -0
- data/spec/support/xml/character/market_orders.xml +11 -0
- data/spec/support/xml/character/medals.xml +13 -0
- data/spec/support/xml/character/research.xml +13 -0
- data/spec/support/xml/character/skill_in_training.xml +14 -0
- data/spec/support/xml/character/skill_not_in_training.xml +7 -0
- data/spec/support/xml/character/skill_queue.xml +11 -0
- data/spec/support/xml/character/standings.xml +32 -0
- data/spec/support/xml/character/wallet_journal.xml +39 -0
- data/spec/support/xml/character/wallet_transactions.xml +44 -0
- data/spec/support/xml/corporation/account_balance.xml +15 -0
- data/spec/support/xml/corporation/asset_list.xml +50 -0
- data/spec/support/xml/corporation/container_log.xml +32 -0
- data/spec/support/xml/corporation/fac_war_stats.xml +19 -0
- data/spec/support/xml/corporation/industry_jobs.xml +70 -0
- data/spec/support/xml/corporation/kill_log.xml +51 -0
- data/spec/support/xml/corporation/market_orders.xml +37 -0
- data/spec/support/xml/corporation/medals.xml +8 -0
- data/spec/support/xml/corporation/member_corporation_sheet.xml +51 -0
- data/spec/support/xml/corporation/member_medals.xml +10 -0
- data/spec/support/xml/corporation/member_security.xml +21 -0
- data/spec/support/xml/corporation/member_security_log.xml +55 -0
- data/spec/support/xml/corporation/member_tracking.xml +18 -0
- data/spec/support/xml/corporation/non_member_corporation_sheet.xml +30 -0
- data/spec/support/xml/corporation/shareholders.xml +11 -0
- data/spec/support/xml/corporation/standings.xml +33 -0
- data/spec/support/xml/corporation/starbase_detail.xml +33 -0
- data/spec/support/xml/corporation/starbase_list.xml +17 -0
- data/spec/support/xml/corporation/titles.xml +34 -0
- data/spec/support/xml/corporation/wallet_journal.xml +40 -0
- data/spec/support/xml/corporation/wallet_transactions.xml +12 -0
- data/spec/support/xml/errors/106.xml +5 -0
- data/spec/support/xml/errors/516.xml +5 -0
- data/spec/support/xml/eve/alliance_list.xml +22 -0
- data/spec/support/xml/eve/certificate_tree.xml +49 -0
- data/spec/support/xml/eve/character_id.xml +15 -0
- data/spec/support/xml/eve/conquerable_station_list.xml +24 -0
- data/spec/support/xml/eve/error_list.xml +78 -0
- data/spec/support/xml/eve/fac_war_stats.xml +31 -0
- data/spec/support/xml/eve/fac_war_top_stats.xml +238 -0
- data/spec/support/xml/eve/ref_types.xml +105 -0
- data/spec/support/xml/eve/skill_tree.xml +52 -0
- data/spec/support/xml/map/fac_war_systems.xml +180 -0
- data/spec/support/xml/map/jumps.xml +166 -0
- data/spec/support/xml/map/kills.xml +191 -0
- data/spec/support/xml/map/sovereignty.xml +20 -0
- data/spec/support/xml/rowset_with_mismatched_attributes.xml +6 -0
- data/spec/support/xml/server/server_status.xml +9 -0
- metadata +364 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API::Services::Eve do
|
4
|
+
context "#skill_tree" do
|
5
|
+
subject { mock_service(:eve, :skill_tree).skill_groups }
|
6
|
+
|
7
|
+
it "contains rows of skills" do
|
8
|
+
subject.should behave_like_rowset('groupName,groupID') do |group|
|
9
|
+
group.skills.should behave_like_rowset('typeName,groupID,typeID') do |skill|
|
10
|
+
for field in %w(description rank required_skills required_attributes skill_bonus_collection)
|
11
|
+
skill.should respond_to(field)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API::Services::Map do
|
4
|
+
context "#fac_war_systems" do
|
5
|
+
subject { mock_service('map', 'fac_war_systems').solar_systems }
|
6
|
+
|
7
|
+
it "should behave like a Rowset" do
|
8
|
+
subject.should behave_like_rowset("solarSystemID,solarSystemName,occupyingFactionID,occupyingFactionName,contested")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API::Services::Map do
|
4
|
+
context "#jumps" do
|
5
|
+
subject { mock_service('map', 'jumps').solar_systems }
|
6
|
+
|
7
|
+
it "should behave like a Rowset" do
|
8
|
+
subject.should behave_like_rowset('solarSystemID,shipJumps')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API::Services::Map do
|
4
|
+
context "#kills" do
|
5
|
+
subject { mock_service('map', 'kills').solar_systems }
|
6
|
+
|
7
|
+
it "should behave like a Rowset" do
|
8
|
+
subject.should behave_like_rowset("solarSystemID,shipKills,factionKills,podKills")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "produces a RowSet called :solar_systems" do
|
12
|
+
subject.should be_kind_of(Eve::API::Response::Rowset)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API::Services::Map do
|
4
|
+
context "#sovereignty" do
|
5
|
+
subject { mock_service('map', 'sovereignty').solar_systems }
|
6
|
+
|
7
|
+
it "should behave like a Rowset" do
|
8
|
+
subject.should behave_like_rowset("solarSystemID,allianceID,factionID,solarSystemName,corporationID")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API do
|
4
|
+
context "#server_status" do
|
5
|
+
before(:each) { @result = mock_service('server', 'server_status').server_status }
|
6
|
+
subject { Eve::API.new }
|
7
|
+
|
8
|
+
it "should respond to current_time" do
|
9
|
+
@result.should respond_to(:current_time)
|
10
|
+
end
|
11
|
+
it "should respond to api_version" do
|
12
|
+
@result.should respond_to(:api_version)
|
13
|
+
end
|
14
|
+
it "should respond to server_open" do
|
15
|
+
@result.should respond_to(:server_open)
|
16
|
+
end
|
17
|
+
it "should respond to online_players" do
|
18
|
+
@result.should respond_to(:online_players)
|
19
|
+
end
|
20
|
+
it "should respond to cached_until" do
|
21
|
+
@result.should respond_to(:cached_until)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API::Request do
|
4
|
+
subject { Eve::API::Request.new('server', 'server_status') }
|
5
|
+
|
6
|
+
it "should dispatch and return a Response" do
|
7
|
+
response = subject.dispatch
|
8
|
+
response.should be_a(Eve::API::Response)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should cache repeat requests" do
|
12
|
+
Eve.cache.delete_matched /#{Regexp.escape subject.namespace}\/#{Regexp.escape subject.service}/
|
13
|
+
Net::HTTP.should_receive(:post_form).once.and_return(mock_http_response(subject.namespace, subject.service))
|
14
|
+
subject.dispatch
|
15
|
+
subject.dispatch
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API::Response do
|
4
|
+
%w(106 516).each do |code|
|
5
|
+
context "with error #{code}" do
|
6
|
+
subject { mock_service("xml/errors/#{code}.xml", :cache => false) }
|
7
|
+
|
8
|
+
it("should raise a #{code} error") do
|
9
|
+
proc { subject.server_status }.should raise_error(Eve::Errors::API_ERROR_MAP[code.to_i])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API::Response::Rowset do
|
4
|
+
context "with mismatched attributes" do
|
5
|
+
subject do
|
6
|
+
Eve::API::Response::Rowset.new(Hpricot::XML(mock_response_body('xml/rowset_with_mismatched_attributes.xml')).root)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Note, in order to address /char/character_sheet (which provides 2 optional attributes, 'level' and 'unpublished',
|
10
|
+
# this requirement has been removed.
|
11
|
+
#
|
12
|
+
# TODO: See if this is an error in the mock XML, or if these attributes are really optional.
|
13
|
+
#
|
14
|
+
#it "should raise an InvalidRowset error" do
|
15
|
+
# proc { subject }.should raise_error(Eve::Errors::InvalidRowset)
|
16
|
+
#end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with a sovereignty map" do
|
20
|
+
subject do
|
21
|
+
Eve::API::Response::Rowset.new((Hpricot::XML(mock_response_body('map', 'sovereignty')).root / "rowset").first)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should define row attributes as methods" do
|
25
|
+
subject[0].should respond_to(:solar_system_id)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API::Response do
|
4
|
+
context "server_status" do
|
5
|
+
subject do
|
6
|
+
Eve::API::Response.new(mock_http_response(:server, :server_status).body)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be convertible to Hash" do
|
10
|
+
subject.to_hash.should == {"current_time"=>DateTime.parse("Wed, 10 Mar 2010 01:03:36 +0000"),
|
11
|
+
"cached_until"=>DateTime.parse("Sat, 10 Mar 2040 01:06:36 +0000"),
|
12
|
+
"online_players"=>31835,
|
13
|
+
"server_open"=>true,
|
14
|
+
"api_version"=>"2"}
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be convertible to YAML" do
|
18
|
+
subject.to_yaml.should == subject.to_hash.to_yaml
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should respond_to :api_version" do
|
22
|
+
should respond_to(:api_version)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should respond_to :current_time" do
|
26
|
+
should respond_to(:current_time)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should respond_to :server_open" do
|
30
|
+
should respond_to(:server_open)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should respond_to :online_players" do
|
34
|
+
should respond_to(:online_players)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should respond_to :cached_until" do
|
38
|
+
should respond_to(:cached_until)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should provide access to attributes via [] operator" do
|
42
|
+
subject[:api_version].should_not be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should provide access to attributes via [] operator" do
|
46
|
+
subject[:apiVersion].should_not be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should provide access to attributes via [] operator" do
|
50
|
+
subject[:online_players].should_not be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should provide access to attributes via [] operator" do
|
54
|
+
subject[:onlinePlayers].should_not be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "with a rowset" do
|
59
|
+
subject do
|
60
|
+
Eve::API::Response.new(mock_http_response(:map, :sovereignty).body)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "delegates the name of the rowset into the rowset from the response object" do
|
64
|
+
subject.should respond_to(:solar_systems)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "defines rowset attributes: #name" do
|
68
|
+
subject.solar_systems.name.should == 'solarSystems'
|
69
|
+
end
|
70
|
+
|
71
|
+
it "defines rowset attributes: #key" do
|
72
|
+
subject.solar_systems.key.should == 'solarSystemID'
|
73
|
+
end
|
74
|
+
|
75
|
+
it "defines rowset attributes: #columns" do
|
76
|
+
subject.solar_systems.columns.should == %w(solarSystemID allianceID factionID solarSystemName corporationID)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::API do
|
4
|
+
it "should update options with #set, given 2 arguments" do
|
5
|
+
subject.set(:api_key, $limited_api_key)
|
6
|
+
subject[:api_key].should == $limited_api_key
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should update options with #set, given a hash" do
|
10
|
+
subject.set(:api_key => $full_api_key)
|
11
|
+
subject[:api_key].should == $full_api_key
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
it "#without" do
|
5
|
+
{ :a => 1, :b => 2, :c => 3 }.without(:a, :b).should == {:c => 3}
|
6
|
+
end
|
7
|
+
|
8
|
+
it "#without_values" do
|
9
|
+
{ :a => 1, :b => 1, :c => 2, :d => 2}.without_values(1).should == {:c => 2, :d => 2}
|
10
|
+
end
|
11
|
+
|
12
|
+
it "#optionalize" do
|
13
|
+
{ :a => nil, :b => nil, :c => 1, :d => 2 }.optionalize.should == { :c => 1, :d => 2}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "#camelize_keys" do
|
17
|
+
{ :hello_world => 1, :goodbye_john => 2}.camelize_keys.should == { 'HelloWorld' => 1, 'GoodbyeJohn' => 2 }
|
18
|
+
end
|
19
|
+
|
20
|
+
it "#rename" do
|
21
|
+
{ :a => 1, :b => 2 }.rename(:a => :b, :b => :c).should == { :b => 1, :c => 2 }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::Helpers::JavascriptHelper do
|
4
|
+
subject { ActionView::Base.new }
|
5
|
+
|
6
|
+
it "should link to mailing list" do
|
7
|
+
subject.link_to_mailing_list("link", '1').should == '<a href="#" onclick="CCPEVE.joinMailingList("1"); return false;">link</a>'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should link to channel" do
|
11
|
+
subject.link_to_channel("link", '1').should == '<a href="#" onclick="CCPEVE.joinChannel("1"); return false;">link</a>'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should link to waypoing" do
|
15
|
+
subject.link_to_waypoint("link", '1').should == '<a href="#" onclick="CCPEVE.addWaypoint("1"); return false;">link</a>'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should link to destination" do
|
19
|
+
subject.link_to_destination("link", '1').should == '<a href="#" onclick="CCPEVE.setDestination("1"); return false;">link</a>'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should request trust" do
|
23
|
+
subject.request_trust("link").should == "<script type=\"text/javascript\">\n//<![CDATA[\nCCPEVE.requestTrust(\"link\");\n//]]>\n</script>"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should link to trust request" do
|
27
|
+
subject.link_to_trust_request("link", '1').should == '<a href="#" onclick="CCPEVE.requestTrust("1"); return false;">link</a>'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should link to market details" do
|
31
|
+
subject.link_to_market_details("link", '1').should == '<a href="#" onclick="CCPEVE.showMarketDetails("1"); return false;">link</a>'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should link to contract" do
|
35
|
+
subject.link_to_contract("link", '1', '2').should == '<a href="#" onclick="CCPEVE.showContract("1", "2"); return false;">link</a>'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should link to fitting" do
|
39
|
+
subject.link_to_fitting("link", '1').should == '<a href="#" onclick="CCPEVE.showFitting("1"); return false;">link</a>'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should link to map" do
|
43
|
+
subject.link_to_route("link", '1').should == '<a href="#" onclick="CCPEVE.showRouteTo("1"); return false;">link</a>'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should link to route" do
|
47
|
+
subject.link_to_route("link", '1').should == '<a href="#" onclick="CCPEVE.showRouteTo("1"); return false;">link</a>'
|
48
|
+
subject.link_to_route("link", '1', '2').should == '<a href="#" onclick="CCPEVE.showRouteTo("1", "2"); return false;">link</a>'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should link to preview" do
|
52
|
+
subject.link_to_preview("link", '1').should == '<a href="#" onclick="CCPEVE.showPreview("1"); return false;">link</a>'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should link to showinfo" do
|
56
|
+
subject.link_to_info("link", "typeid").should == '<a href="#" onclick="CCPEVE.showInfo("typeid"); return false;">link</a>'
|
57
|
+
subject.link_to_info("link", 1, 2).should == '<a href="#" onclick="CCPEVE.showInfo(1, 2); return false;">link</a>'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should link to evemail" do
|
61
|
+
subject.link_to_evemail("link").should == '<a href="#" onclick="CCPEVE.openEveMail(); return false;">link</a>'
|
62
|
+
end
|
63
|
+
|
64
|
+
context '#type_id' do
|
65
|
+
it "should raise ArgumentError if type doesn't match" do
|
66
|
+
proc { subject.type_id('something that is completely invalid') }.should raise_error(ArgumentError)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should return valid ID when given a valid argument' do
|
70
|
+
subject.type_id('Alliance').should == 16159
|
71
|
+
subject.type_id('Character').should == 1377
|
72
|
+
subject.type_id(:corporation).should == 2
|
73
|
+
subject.type_id(:constellation).should == 4
|
74
|
+
subject.type_id(:region).should == 3
|
75
|
+
subject.type_id(:solar_system).should == 5
|
76
|
+
subject.type_id("Solar System").should == 5
|
77
|
+
subject.type_id(:station).should == 3867
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::Helpers::ViewHelper do
|
4
|
+
subject do
|
5
|
+
env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '', 'HTTP_USER_AGENT' => 'eve-minibrowser')
|
6
|
+
ActionView::Base.new([], {}, TrustController.call(env).template.controller)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should delegate #igb into #controller" do
|
10
|
+
subject.igb.should be_kind_of(Eve::Trust::IgbInterface)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Eve::Trust::ControllerHelpers do
|
4
|
+
subject do
|
5
|
+
subject = TrustController.call(@rack_env)
|
6
|
+
if exception = subject.template.instance_variable_get("@exception")
|
7
|
+
raise exception
|
8
|
+
end
|
9
|
+
subject
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should not consider the helper methods to be actions" do
|
13
|
+
TrustController.action_methods.sort.should == %w(index)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "from the IGB" do
|
17
|
+
before :all do
|
18
|
+
@rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '', 'HTTP_USER_AGENT' => 'eve-minibrowser')
|
19
|
+
end
|
20
|
+
|
21
|
+
context "without trust" do
|
22
|
+
it "should require trust" do
|
23
|
+
subject.headers['eve.trustme'].should_not be_blank
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "with trust" do
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
context "and an IGB template exists" do
|
32
|
+
before(:all) { @rack_env.merge!('mock_methods' => { :default_template_exists? => true }) }
|
33
|
+
it "responds with an IGB-specific page" do
|
34
|
+
subject.template.template_format.should == :igb
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "and an IGB template does not exist" do
|
39
|
+
before(:all) { @rack_env.merge!('mock_methods' => { :default_template_exists? => false }) }
|
40
|
+
it "does not respond with an IGB-specific page" do
|
41
|
+
subject.template.template_format.should_not == :igb
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "from any other browser" do
|
47
|
+
before :all do
|
48
|
+
@rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '',
|
49
|
+
'HTTP_USER_AGENT' => 'Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should not require trust" do
|
53
|
+
subject.headers['eve.trustme'].should be_blank
|
54
|
+
end
|
55
|
+
|
56
|
+
context "and an IGB template exists" do
|
57
|
+
before(:all) { @rack_env.merge!('mock_methods' => { :default_template_exists? => true }) }
|
58
|
+
it "does not respond with an IGB-specific page" do
|
59
|
+
subject.template.template_format.should_not == :igb
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "and an IGB template does not exist" do
|
64
|
+
before(:all) { @rack_env.merge!('mock_methods' => { :default_template_exists? => false }) }
|
65
|
+
it "does not respond with an IGB-specific page" do
|
66
|
+
subject.template.template_format.should_not == :igb
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|