summaryrefslogtreecommitdiffhomepage
path: root/spec/component_manager_spec.rb
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-12-30 07:28:14 -0500
committerrealtradam <[email protected]>2021-12-30 07:28:14 -0500
commitd03ce21592062aed27a571fda60483fcb3fba764 (patch)
treeb82c99051b378c18ad4a8af98292681869dfa5a7 /spec/component_manager_spec.rb
parent38e1a046dcc0ecf5e3ec672ca466f02038b86a02 (diff)
downloadFelECS-arry.tar.gz
FelECS-arry.zip
Diffstat (limited to 'spec/component_manager_spec.rb')
-rw-r--r--spec/component_manager_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/component_manager_spec.rb b/spec/component_manager_spec.rb
index d05a8a7..6fedf78 100644
--- a/spec/component_manager_spec.rb
+++ b/spec/component_manager_spec.rb
@@ -11,6 +11,8 @@ describe 'Components' do
end
before :each do
+ @orig_stderr = $stderr
+ $stderr = StringIO.new
@ent0 = FelFlame::Entities.new
@ent1 = FelFlame::Entities.new
@ent2 = FelFlame::Entities.new
@@ -20,10 +22,23 @@ describe 'Components' do
end
after :each do
+ $stderr = @orig_stderr
FelFlame::Entities.reverse_each(&:delete)
@component_manager.reverse_each(&:delete)
end
+ it 'can get a single entity' do
+ @cmp0.entity
+ $stderr.rewind
+ $stderr.string.chomp.should eq("This component belongs to NO entities but you called the method that is intended for components belonging to a single entity.\nYou may have a bug in your logic.")
+ @ent0.add @cmp0
+ expect(@cmp0.entity).to eq(@ent0)
+ @ent1.add @cmp0
+ @cmp0.entity
+ $stderr.rewind
+ $stderr.string.chomp.should eq("This component belongs to MANY entities but you called the method that is intended for components belonging to a single entity.\nYou may have a bug in your logic.")
+ end
+
it 'responds to array methods' do
expect(@component_manager.respond_to?(:[])).to be true
expect(@component_manager.respond_to?(:each)).to be true
@@ -37,6 +52,19 @@ describe 'Components' do
expect { @component_manager.somethingwrong }.to raise_error(NoMethodError)
end
+ it 'Component module responds to array methods' do
+ expect(FelFlame::Components.respond_to?(:[])).to be true
+ expect(FelFlame::Components.respond_to?(:each)).to be true
+ expect(FelFlame::Components.respond_to?(:filter)).to be true
+ expect(FelFlame::Components.respond_to?(:first)).to be true
+ expect(FelFlame::Components.respond_to?(:last)).to be true
+ expect(FelFlame::Components.respond_to?(:somethingwrong)).to be false
+ end
+
+ it 'Component module doesnt respond to missing methods' do
+ expect { FelFlame::Components.somethingwrong }.to raise_error(NoMethodError)
+ end
+
it 'can delete a component' do
#component_id = @cmp1.id
@ent0.add @cmp1