gosu_extensions 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/spec/lib/units/sprite_spec.rb +123 -0
  3. metadata +4 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
@@ -0,0 +1,123 @@
1
+ require File.join(File.dirname(__FILE__), '/../../spec_helper')
2
+
3
+ describe Sprite do
4
+
5
+ before(:each) do
6
+ @sprites = stub :sprites
7
+ @window = stub :window, :sprites => @sprites
8
+ @sprite = Sprite.new @window
9
+ end
10
+
11
+ describe "current_size" do
12
+ it "should return [1.0, 1.0] by default" do
13
+ @sprite.current_size.should == [1.0, 1.0]
14
+ end
15
+ end
16
+
17
+ describe "draw" do
18
+ before(:each) do
19
+ @image = stub :image
20
+ @sprite.stub! :image => @image,
21
+ :position => Struct.new(:x, :y).new(:some_x, :some_y),
22
+ :layer => :some_layer,
23
+ :drawing_rotation => :some_drawing_rotation,
24
+ :current_size => [:size_x, :size_y]
25
+ end
26
+ context 'debug on' do
27
+
28
+ end
29
+ context 'debug off' do
30
+ before(:each) do
31
+ @window.stub! :debug? => false
32
+ end
33
+ it "should delegate to the image" do
34
+ @image.should_receive(:draw_rot).once.with :some_x, :some_y, :some_layer, :some_drawing_rotation, 0.5, 0.5, :size_x, :size_y
35
+
36
+ @sprite.draw
37
+ end
38
+ end
39
+ end
40
+
41
+ describe "threaded" do
42
+ before(:each) do
43
+ @scheduling = stub :scheduling
44
+ @window.stub! :scheduling => @scheduling
45
+ end
46
+ it "should delegate to the window" do
47
+ some_block = Proc.new {}
48
+
49
+ @scheduling.should_receive(:add).once.with :some_time, &some_block
50
+
51
+ @sprite.threaded :some_time, &some_block
52
+ end
53
+ end
54
+
55
+ describe "window" do
56
+ it "should return the window" do
57
+ @sprite.window.should == @window
58
+ end
59
+ end
60
+
61
+ describe "destroy!" do
62
+ context 'already destroyed' do
63
+ before(:each) do
64
+ @sprite.destroyed = true
65
+ end
66
+ it "should not unregister" do
67
+ @window.should_receive(:unregister).never
68
+
69
+ @sprite.destroy!
70
+ end
71
+ it "should not set destroyed" do
72
+ @sprite.should_receive(:destroyed=).never
73
+
74
+ @sprite.destroy!
75
+ end
76
+ end
77
+ context 'not yet destroyed' do
78
+ before(:each) do
79
+ @sprites.stub! :remove => nil
80
+ end
81
+ it "should remove" do
82
+ @sprites.should_receive(:remove).once.with @sprite
83
+
84
+ @sprite.destroy!
85
+ end
86
+ it "should set destroyed" do
87
+ @sprite.should_receive(:destroyed=).once.with true
88
+
89
+ @sprite.destroy!
90
+ end
91
+ end
92
+ end
93
+
94
+ describe "destroyed?" do
95
+ it "should be nil after creating the object" do
96
+ @sprite.destroyed?.should == nil
97
+ end
98
+ end
99
+ describe "destroyed=" do
100
+ it "should exist" do
101
+ lambda { @sprite.destroyed = true }.should_not raise_error
102
+ end
103
+ end
104
+
105
+ describe "layer" do
106
+ context 'default' do
107
+ it "should be on the player layer" do
108
+ @sprite.layer.should == Layer::Ambient
109
+ end
110
+ end
111
+ context 'non-default' do
112
+ before(:each) do
113
+ class Sprote < Sprite
114
+ layer :non_default_layer
115
+ end
116
+ end
117
+ it "should be on the non default layer" do
118
+ Sprote.new(@window).layer.should == :non_default_layer
119
+ end
120
+ end
121
+ end
122
+
123
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 4
9
- version: 0.3.4
8
+ - 5
9
+ version: 0.3.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-19 00:00:00 +02:00
18
+ date: 2010-04-21 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -156,4 +156,5 @@ test_files:
156
156
  - spec/lib/traits/targeting_spec.rb
157
157
  - spec/lib/traits/turnable_spec.rb
158
158
  - spec/lib/traits/user_interface_spec.rb
159
+ - spec/lib/units/sprite_spec.rb
159
160
  - spec/lib/units/thing_spec.rb