Permalink
Browse files

InventoryItemがItemモデルのメソッドに委譲するようにした。

  • Loading branch information...
sakomoko committed Jan 7, 2013
1 parent 50ad01d commit 63feb033a677ab40cde1748c7760f4a01c7f656b
Showing with 14 additions and 3 deletions.
  1. +4 −0 app/models/inventory_item.rb
  2. +10 −3 spec/models/inventory_item_spec.rb
@@ -53,4 +53,8 @@ def equipping?
false
end
+ def method_missing(method, *args)
+ item.send method, *args
+ end
+
end
@@ -2,11 +2,18 @@
require 'spec_helper'
describe InventoryItem do
+ let(:pc) { FactoryGirl.create :character, equip: (FactoryGirl.create :equip) }
+ let(:inventory_item) { FactoryGirl.create :inventory_item, character: pc }
+
+ describe 'Itemモデルのメソッドに委譲することができること' do
+ subject { inventory_item }
+ its(:item_type) { should eq inventory_item.item.item_type }
+ its(:weight) { should eq inventory_item.item.weight }
+ it { should_not be_equip }
+ end
+
describe '#equip' do
- let(:pc) { FactoryGirl.create :character, equip: (FactoryGirl.create :equip) }
let(:equip) { pc.equip }
- let(:inventory_item) { FactoryGirl.create :inventory_item, character: pc }
-
context 'DEX+1の武器Aを装備したとき' do
let(:inventory_item) { FactoryGirl.create :inventory_sword_item, character: pc }
before do

0 comments on commit 63feb03

Please sign in to comment.