metro-ld25 0.3.3

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 (177) hide show
  1. data/.gitignore +17 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +1 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +12 -0
  6. data/Guardfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +189 -0
  9. data/Rakefile +18 -0
  10. data/bin/metro +16 -0
  11. data/changelog.md +157 -0
  12. data/lib/assets/menu-movement.wav +0 -0
  13. data/lib/assets/menu-selection.wav +0 -0
  14. data/lib/assets/missing.ogg +0 -0
  15. data/lib/assets/missing.png +0 -0
  16. data/lib/assets/missing.wav +0 -0
  17. data/lib/assets/missing_animation.png +0 -0
  18. data/lib/commands/generate_game.rb +13 -0
  19. data/lib/commands/generate_model.rb +25 -0
  20. data/lib/commands/generate_scene.rb +36 -0
  21. data/lib/commands/generate_view.rb +21 -0
  22. data/lib/commands/thor.rb +83 -0
  23. data/lib/core_ext/class.rb +14 -0
  24. data/lib/core_ext/numeric.rb +59 -0
  25. data/lib/gosu_ext/color.rb +62 -0
  26. data/lib/gosu_ext/gosu_constants.rb +53 -0
  27. data/lib/locale/en.yml +35 -0
  28. data/lib/locale/locale.rb +1 -0
  29. data/lib/metro.rb +140 -0
  30. data/lib/metro/animation.rb +135 -0
  31. data/lib/metro/animation/after_interval_factory.rb +12 -0
  32. data/lib/metro/animation/animation_factory.rb +15 -0
  33. data/lib/metro/animation/easing/ease_in.rb +15 -0
  34. data/lib/metro/animation/easing/easing.rb +51 -0
  35. data/lib/metro/animation/easing/linear.rb +15 -0
  36. data/lib/metro/animation/has_animations.rb +70 -0
  37. data/lib/metro/animation/implicit_animation.rb +100 -0
  38. data/lib/metro/animation/on_update_operation.rb +96 -0
  39. data/lib/metro/animation/scene_animation.rb +16 -0
  40. data/lib/metro/asset_path.rb +97 -0
  41. data/lib/metro/events/control_definition.rb +11 -0
  42. data/lib/metro/events/controls.rb +42 -0
  43. data/lib/metro/events/event_data.rb +60 -0
  44. data/lib/metro/events/event_dictionary.rb +52 -0
  45. data/lib/metro/events/event_factory.rb +17 -0
  46. data/lib/metro/events/event_relay.rb +300 -0
  47. data/lib/metro/events/event_state_manager.rb +63 -0
  48. data/lib/metro/events/events.rb +3 -0
  49. data/lib/metro/events/has_events.rb +108 -0
  50. data/lib/metro/events/hit_list.rb +75 -0
  51. data/lib/metro/events/unknown_sender.rb +5 -0
  52. data/lib/metro/font.rb +69 -0
  53. data/lib/metro/game.rb +102 -0
  54. data/lib/metro/game/dsl.rb +68 -0
  55. data/lib/metro/image.rb +68 -0
  56. data/lib/metro/logging.rb +33 -0
  57. data/lib/metro/missing_scene.rb +21 -0
  58. data/lib/metro/models/audio/song.rb +33 -0
  59. data/lib/metro/models/draws.rb +86 -0
  60. data/lib/metro/models/key_value_coding.rb +38 -0
  61. data/lib/metro/models/model.rb +236 -0
  62. data/lib/metro/models/model_factory.rb +32 -0
  63. data/lib/metro/models/models.rb +62 -0
  64. data/lib/metro/models/properties/animation_property.rb +115 -0
  65. data/lib/metro/models/properties/array_property.rb +24 -0
  66. data/lib/metro/models/properties/boolean_property.rb +27 -0
  67. data/lib/metro/models/properties/color_property.rb +116 -0
  68. data/lib/metro/models/properties/dimensions_property.rb +84 -0
  69. data/lib/metro/models/properties/font_property.rb +130 -0
  70. data/lib/metro/models/properties/image_property.rb +96 -0
  71. data/lib/metro/models/properties/model_property.rb +84 -0
  72. data/lib/metro/models/properties/numeric_property.rb +29 -0
  73. data/lib/metro/models/properties/options_property/no_option.rb +29 -0
  74. data/lib/metro/models/properties/options_property/options.rb +94 -0
  75. data/lib/metro/models/properties/options_property/options_property.rb +125 -0
  76. data/lib/metro/models/properties/position_property.rb +90 -0
  77. data/lib/metro/models/properties/property.rb +221 -0
  78. data/lib/metro/models/properties/property_owner.rb +137 -0
  79. data/lib/metro/models/properties/sample_property.rb +84 -0
  80. data/lib/metro/models/properties/scale_property.rb +80 -0
  81. data/lib/metro/models/properties/song_property.rb +89 -0
  82. data/lib/metro/models/properties/text_property.rb +75 -0
  83. data/lib/metro/models/ui/animated_sprite.rb +85 -0
  84. data/lib/metro/models/ui/border.rb +95 -0
  85. data/lib/metro/models/ui/fps.rb +54 -0
  86. data/lib/metro/models/ui/generic.rb +66 -0
  87. data/lib/metro/models/ui/grid_drawer.rb +74 -0
  88. data/lib/metro/models/ui/image.rb +87 -0
  89. data/lib/metro/models/ui/label.rb +175 -0
  90. data/lib/metro/models/ui/menu.rb +214 -0
  91. data/lib/metro/models/ui/model_label.rb +65 -0
  92. data/lib/metro/models/ui/model_labeler.rb +79 -0
  93. data/lib/metro/models/ui/rectangle.rb +59 -0
  94. data/lib/metro/models/ui/sprite.rb +79 -0
  95. data/lib/metro/models/ui/tile_map.rb +162 -0
  96. data/lib/metro/models/ui/ui.rb +13 -0
  97. data/lib/metro/parameters/command_line_args_parser.rb +68 -0
  98. data/lib/metro/parameters/options.rb +25 -0
  99. data/lib/metro/parameters/parameters.rb +2 -0
  100. data/lib/metro/sample.rb +40 -0
  101. data/lib/metro/scene.rb +477 -0
  102. data/lib/metro/scenes.rb +154 -0
  103. data/lib/metro/song.rb +56 -0
  104. data/lib/metro/template_message.rb +60 -0
  105. data/lib/metro/transitions/edit_transition_scene.rb +100 -0
  106. data/lib/metro/transitions/fade_transition_scene.rb +66 -0
  107. data/lib/metro/transitions/scene_transitions.rb +44 -0
  108. data/lib/metro/transitions/transition_scene.rb +19 -0
  109. data/lib/metro/units/bounds.rb +8 -0
  110. data/lib/metro/units/calculation_validations.rb +74 -0
  111. data/lib/metro/units/dimensions.rb +60 -0
  112. data/lib/metro/units/point.rb +51 -0
  113. data/lib/metro/units/rectangle_bounds.rb +85 -0
  114. data/lib/metro/units/scale.rb +46 -0
  115. data/lib/metro/units/units.rb +6 -0
  116. data/lib/metro/version.rb +32 -0
  117. data/lib/metro/views/json_view.rb +60 -0
  118. data/lib/metro/views/no_view.rb +34 -0
  119. data/lib/metro/views/parsers.rb +42 -0
  120. data/lib/metro/views/scene_view.rb +107 -0
  121. data/lib/metro/views/view.rb +133 -0
  122. data/lib/metro/views/writers.rb +43 -0
  123. data/lib/metro/views/yaml_view.rb +94 -0
  124. data/lib/metro/window.rb +94 -0
  125. data/lib/setup_handlers/exit_if_dry_run.rb +26 -0
  126. data/lib/setup_handlers/game_execution.rb +65 -0
  127. data/lib/setup_handlers/load_game_configuration.rb +65 -0
  128. data/lib/setup_handlers/load_game_files.rb +101 -0
  129. data/lib/setup_handlers/move_to_game_directory.rb +25 -0
  130. data/lib/setup_handlers/reload_game_on_game_file_changes.rb +79 -0
  131. data/lib/templates/game/README.md.tt +52 -0
  132. data/lib/templates/game/assets/brand.jpg +0 -0
  133. data/lib/templates/game/assets/hero.png +0 -0
  134. data/lib/templates/game/lib/custom_easing.rb +32 -0
  135. data/lib/templates/game/metro.tt +63 -0
  136. data/lib/templates/game/models/hero.rb +62 -0
  137. data/lib/templates/game/scenes/brand_scene.rb +19 -0
  138. data/lib/templates/game/scenes/brand_to_title_scene.rb +13 -0
  139. data/lib/templates/game/scenes/first_scene.rb +28 -0
  140. data/lib/templates/game/scenes/game_scene.rb +43 -0
  141. data/lib/templates/game/scenes/title_scene.rb +15 -0
  142. data/lib/templates/game/views/brand.yaml +4 -0
  143. data/lib/templates/game/views/brand_to_title.yaml +8 -0
  144. data/lib/templates/game/views/first.yaml +26 -0
  145. data/lib/templates/game/views/title.yaml +11 -0
  146. data/lib/templates/message.erb +23 -0
  147. data/lib/templates/model.rb.tt +111 -0
  148. data/lib/templates/scene.rb.tt +140 -0
  149. data/lib/templates/view.yaml.tt +11 -0
  150. data/lib/tmxed_ext/tile_set.rb +34 -0
  151. data/metro.gemspec +56 -0
  152. data/spec/core_ext/numeric_spec.rb +78 -0
  153. data/spec/core_ext/string_spec.rb +33 -0
  154. data/spec/gosu_ext/color_spec.rb +80 -0
  155. data/spec/metro/events/event_state_manager_spec.rb +5 -0
  156. data/spec/metro/models/key_value_coding_spec.rb +61 -0
  157. data/spec/metro/models/properties/array_property_spec.rb +60 -0
  158. data/spec/metro/models/properties/color_property_spec.rb +85 -0
  159. data/spec/metro/models/properties/dimensions_spec.rb +29 -0
  160. data/spec/metro/models/properties/font_property_spec.rb +127 -0
  161. data/spec/metro/models/properties/numeric_property_spec.rb +46 -0
  162. data/spec/metro/models/properties/options_property/no_option_spec.rb +25 -0
  163. data/spec/metro/models/properties/options_property/options_property_spec.rb +133 -0
  164. data/spec/metro/models/properties/options_property/options_spec.rb +125 -0
  165. data/spec/metro/models/properties/position_property_spec.rb +90 -0
  166. data/spec/metro/models/ui/label_spec.rb +259 -0
  167. data/spec/metro/parameters/command_line_args_parser_spec.rb +42 -0
  168. data/spec/metro/scene_spec.rb +15 -0
  169. data/spec/metro/scene_views/json_view_spec.rb +27 -0
  170. data/spec/metro/scene_views/yaml_view_spec.rb +38 -0
  171. data/spec/metro/scenes_spec.rb +77 -0
  172. data/spec/metro/units/point_spec.rb +132 -0
  173. data/spec/metro/views/view_spec.rb +53 -0
  174. data/spec/setup_handlers/exit_if_dry_run_spec.rb +27 -0
  175. data/spec/setup_handlers/reload_game_on_game_file_changes_spec.rb +68 -0
  176. data/spec/spec_helper.rb +20 -0
  177. metadata +374 -0
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::Parameters::CommandLineArgsParser do
4
+
5
+ describe "Class Methods" do
6
+
7
+ subject { described_class }
8
+
9
+ describe "#parse" do
10
+ context "when given no parameters" do
11
+
12
+ end
13
+
14
+ context "when given an array of parameters" do
15
+
16
+ subject { described_class.parse parameters }
17
+ let(:parameters) { [ '--upset-the-world', expected_filename, '--check-dependencies', 'unread_command' ] }
18
+ let(:expected_filename) { 'metro' }
19
+
20
+ it "should maintain an original parameter list" do
21
+ subject.execution_parameters.should eq parameters
22
+ end
23
+
24
+ it "should consider the first non-flag the game file" do
25
+ subject.filename.should eq expected_filename
26
+ end
27
+
28
+ it "should find all the flags" do
29
+ subject.upset_the_world?.should be_true
30
+ subject.check_dependencies?.should be_true
31
+ end
32
+
33
+ it "should return false when non-existant flags are present" do
34
+ subject.wants_food_mild?.should be_false
35
+ end
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::Scene do
4
+
5
+ class SpecScene < Metro::Scene ; end
6
+
7
+ subject { SpecScene.new }
8
+
9
+ let(:expected_view_name) { "spec" }
10
+ its(:view_name) { should eq expected_view_name }
11
+
12
+ let(:expected_scene_name) { "spec" }
13
+ its(:scene_name) { should eq expected_scene_name }
14
+
15
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::Views::JSONView do
4
+
5
+ subject { described_class }
6
+ let(:view_name) { "example" }
7
+
8
+ before do
9
+ File.stub(:exists?).and_return(false)
10
+ end
11
+
12
+ describe ".exists?" do
13
+ context "when a view file exists with the extension JSON" do
14
+ before do
15
+ File.stub(:exists?).with(filepath_that_exists).and_return(true)
16
+ end
17
+
18
+ let(:filepath_that_exists) { "#{view_name}.json" }
19
+
20
+ it "should return true" do
21
+ subject.exists?(view_name).should be_true
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::Views::YAMLView do
4
+
5
+ subject { described_class }
6
+ let(:view_name) { "example" }
7
+
8
+ before do
9
+ File.stub(:exists?).and_return(false)
10
+ end
11
+
12
+ describe ".exists?" do
13
+ context "when a view file exists with the extension YAML" do
14
+ before do
15
+ File.stub(:exists?).with(filepath_that_exists).and_return(true)
16
+ end
17
+
18
+ let(:filepath_that_exists) { "#{view_name}.yaml" }
19
+
20
+ it "should return true" do
21
+ subject.exists?(view_name).should be_true
22
+ end
23
+
24
+ end
25
+ context "when a view file exists with the extension YML" do
26
+ before :each do
27
+ File.stub(:exists?).with(filepath_that_exists).and_return(true)
28
+ end
29
+
30
+ let(:filepath_that_exists) { "#{view_name}.yml" }
31
+
32
+ it "should return true" do
33
+ subject.exists?(view_name).should be_true
34
+ end
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::Scenes do
4
+
5
+ subject { described_class }
6
+
7
+ class SpecScene < Metro::Scene ; end
8
+ let(:existing_scene_name) { :spec }
9
+
10
+ describe ".find" do
11
+ context "when a scene does exist" do
12
+
13
+ let(:expected_value) { SpecScene }
14
+
15
+ it "should return the scene" do
16
+ subject.find(existing_scene_name).should eq expected_value
17
+ end
18
+ end
19
+
20
+ context "when a scene does not exist" do
21
+ let(:unknown_scene_name) { :unknown }
22
+
23
+ it "should return a missing scene" do
24
+ missing_scene = subject.find(unknown_scene_name)
25
+ missing_scene.missing_scene.should eq unknown_scene_name
26
+ end
27
+ end
28
+ end
29
+
30
+ describe ".generate" do
31
+ let(:existing_scene_name) { :spec }
32
+
33
+ context "when the provided scene name does exist" do
34
+
35
+ let(:expected_scene_class) { SpecScene }
36
+
37
+ it "should return an instance of the scene" do
38
+ subject.generate(existing_scene_name).should be_kind_of expected_scene_class
39
+ end
40
+ end
41
+
42
+ context "when the provided scene object does exist" do
43
+
44
+ let(:scene_instance) { SpecScene.new }
45
+
46
+ it "should return the same instance of scene" do
47
+ subject.generate(scene_instance).should eq scene_instance
48
+ end
49
+ end
50
+
51
+ it "should process the scene through the post filters" do
52
+ subject.should_receive(:apply_post_filters)
53
+ subject.generate(existing_scene_name)
54
+ end
55
+ end
56
+
57
+ describe ".register_post_filter" do
58
+
59
+ class SpecScenesPostFilter
60
+ def self.filter(scene,options)
61
+ scene
62
+ end
63
+ end
64
+
65
+ context "when a post filter is added" do
66
+ let(:post_filter) { SpecScenesPostFilter }
67
+
68
+ it "should be in the list of post filters" do
69
+ subject.register_post_filter SpecScenesPostFilter
70
+ subject.post_filters.should include(post_filter)
71
+ end
72
+ end
73
+
74
+ end
75
+
76
+
77
+ end
@@ -0,0 +1,132 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::Units::Point do
4
+
5
+ subject { described_class.new x, y, z }
6
+
7
+ let(:x) { 12 }
8
+ let(:y) { 24 }
9
+ let(:z) { 36 }
10
+
11
+ its(:x) { should eq x }
12
+ its(:y) { should eq y }
13
+ its(:z) { should eq z }
14
+ its(:z_order) { should eq z }
15
+
16
+ let(:expected_string) { "#{x},#{y},#{z}" }
17
+ its(:to_s) { should eq expected_string }
18
+
19
+ describe "#+" do
20
+ context "when adding it to another point" do
21
+ let(:point) { described_class.at 1, 2, 3 }
22
+ let(:summed_point) { described_class.at 13, 26, 39 }
23
+
24
+ it "should be a sum of the two points" do
25
+ sum = subject + point
26
+ sum.should eq summed_point
27
+ end
28
+ end
29
+
30
+ context "when adding it to another point-like object" do
31
+ let(:point) { stub('Point Like',x: 1, y: 2, z: 3) }
32
+ let(:summed_point) { described_class.at 13, 26, 39 }
33
+
34
+ it "should be a sum of the two points" do
35
+ sum = subject + point
36
+ sum.should eq summed_point
37
+ end
38
+ end
39
+
40
+ context "when adding it to something not like a point" do
41
+ let(:point) { stub('Not Point Like') }
42
+ let(:summed_point) { described_class.at 13, 26, 39 }
43
+
44
+ it "should raise an error" do
45
+ expect { subject + point }.to raise_error
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#-" do
51
+ context "when adding it to another point" do
52
+ let(:point) { described_class.at 1, 2, 3 }
53
+ let(:summed_point) { described_class.at 11, 22, 33 }
54
+
55
+ it "should be a sum of the two points" do
56
+ sum = subject - point
57
+ sum.should eq summed_point
58
+ end
59
+ end
60
+
61
+ context "when adding it to another point-like object" do
62
+ let(:point) { stub('Point Like',x: 1, y: 2, z: 3) }
63
+ let(:summed_point) { described_class.at 11, 22, 33 }
64
+
65
+ it "should be a sum of the two points" do
66
+ sum = subject - point
67
+ sum.should eq summed_point
68
+ end
69
+ end
70
+
71
+ context "when adding it to something not like a point" do
72
+ let(:point) { stub('Not Point Like') }
73
+ let(:summed_point) { described_class.at 13, 26, 39 }
74
+
75
+ it "should raise an error" do
76
+ expect { subject - point }.to raise_error
77
+ end
78
+ end
79
+ end
80
+
81
+ describe "Class Methods" do
82
+
83
+ subject { described_class }
84
+
85
+ describe "#zero" do
86
+ let(:expected_point) { Point.new 0,0,0 }
87
+
88
+ it "should create a zero point" do
89
+ subject.zero.should == expected_point
90
+ end
91
+ end
92
+
93
+ describe "#at" do
94
+ let(:expected_point) { Point.new 1,2,3 }
95
+
96
+ it "should be equal to a new created point" do
97
+ subject.at(1,2,3).should == expected_point
98
+ end
99
+ end
100
+
101
+ describe "#parse" do
102
+ context "when the input string is defined with 'x,y,z'" do
103
+ let(:input) { "1,2,3" }
104
+ let(:expected_value) { Point.at(1,2,3) }
105
+
106
+ it "should create the expected point" do
107
+ subject.parse(input).should eq expected_value
108
+ end
109
+ end
110
+
111
+ context "when the input string is defined with 'x,y'" do
112
+ let(:input) { "1,2" }
113
+ let(:expected_value) { Point.at(1,2,0) }
114
+
115
+ it "should create the expected point" do
116
+ subject.parse(input).should eq expected_value
117
+ end
118
+ end
119
+
120
+ context "when the input is a nil" do
121
+ let(:input) { nil }
122
+ let(:expected_value) { Point.at(0,0,0) }
123
+
124
+ it "should create the expected point" do
125
+ subject.parse(input).should eq expected_value
126
+ end
127
+ end
128
+ end
129
+
130
+ end
131
+
132
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::View do
4
+ before do
5
+ subject.name = "spec"
6
+ end
7
+
8
+ let(:expected_view_path) { "views/spec" }
9
+ its(:view_path) { should eq expected_view_path }
10
+
11
+ describe "#parser" do
12
+ before do
13
+ subject.stub(:supported_parsers) { [ mock(exists?: false), expected_parser ] }
14
+ end
15
+
16
+ let(:expected_parser) { mock(exists?: true) }
17
+
18
+ it "should return the first parser which has a existing view" do
19
+ subject.parser.should eq expected_parser
20
+ end
21
+ end
22
+
23
+ describe "#writer" do
24
+
25
+ context "when the parser has a format that matches a writer" do
26
+ before do
27
+ subject.stub(:parser) { mock(format: :json) }
28
+ subject.stub(:supported_writers) { [ mock(format: :yaml), expected_writer ] }
29
+ end
30
+
31
+ let(:expected_writer) { mock(format: :json) }
32
+
33
+ it "should match the parser format" do
34
+ subject.writer.format.should eq :json
35
+ end
36
+ end
37
+
38
+ context "when the format has been specified" do
39
+ before do
40
+ subject.stub(:parser) { mock(format: :json) }
41
+ subject.stub(:supported_writers) { [ expected_writer, mock(format: :json) ] }
42
+ end
43
+
44
+ let(:expected_writer) { mock(format: :yaml) }
45
+
46
+ it "should match the format (ignoring the parser format)" do
47
+ subject.format = :yaml
48
+ subject.writer.format.should eq :yaml
49
+ end
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::SetupHandlers::ExitIfDryRun do
4
+
5
+ describe "#setup" do
6
+ context "when the options specify that this is a dry run" do
7
+
8
+ let(:options) { stub('Options', dry_run?: true) }
9
+
10
+ it "should exit the game" do
11
+ subject.should_receive(:exit)
12
+ subject.setup(options)
13
+ end
14
+ end
15
+
16
+ context "when the options DO NOT specify that this is a dry run" do
17
+
18
+ let(:options) { stub('Options', dry_run?: false) }
19
+
20
+ it "should not exit the game" do
21
+ subject.should_not_receive(:exit)
22
+ subject.setup(options)
23
+ end
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::SetupHandlers::ReloadGameOnGameFileChanges do
4
+
5
+ let(:expected_filepaths) do
6
+ %w[ lib scenes models views assets ]
7
+ end
8
+
9
+ its(:watched_filepaths) { should eq expected_filepaths }
10
+
11
+
12
+ describe "#setup" do
13
+ context "when the game is not in debug mode" do
14
+ before do
15
+ Game.stub(:debug?).and_return(false)
16
+ end
17
+
18
+ let(:options) { mock('Options',packaged?: false) }
19
+
20
+ it "should not start the watcher" do
21
+ subject.should_not_receive(:start_watcher)
22
+ subject.setup(options)
23
+ end
24
+ end
25
+
26
+ context "when the options specify that it is being run in a package" do
27
+ before do
28
+ Game.stub(:debug?).and_return(true)
29
+ end
30
+
31
+ let(:options) { mock('Options',packaged?: true) }
32
+
33
+ it "should not start the watcher" do
34
+ subject.should_not_receive(:start_watcher)
35
+ subject.setup(options)
36
+ end
37
+ end
38
+
39
+ context "when the game is debug mode" do
40
+ before do
41
+ Game.stub(:debug?).and_return(true)
42
+ end
43
+
44
+ let(:options) { mock('Options',packaged?: false) }
45
+
46
+
47
+ it "should start the watcher" do
48
+ subject.should_receive(:start_watcher)
49
+ subject.setup(options)
50
+ end
51
+ end
52
+ end
53
+
54
+ describe "#reload_game_because_files_changed" do
55
+
56
+ before do
57
+ Metro.stub(:game_has_valid_code?).and_return(false)
58
+ end
59
+
60
+ let(:changed_files) { [ :new_file, :update_file, :deleted_file ] }
61
+
62
+ it "should not ask the current scene to reload if the code is invalid" do
63
+ Game.should_not_receive(:current_scene)
64
+ subject.reload_game_because_files_changed(changed_files)
65
+ end
66
+ end
67
+
68
+ end