Skip to content

Instantly share code, notes, and snippets.

@Sephi-Chan
Created January 8, 2013 19:59
Show Gist options
  • Save Sephi-Chan/4487364 to your computer and use it in GitHub Desktop.
Save Sephi-Chan/4487364 to your computer and use it in GitHub Desktop.
class BuyWeaponTest < ActiveSupport::TestCase
test "User buys a weapon" do
mp5 = WeaponType.create('mp5', gold: 40)
ak47 = WeaponType.create('ak47', gold: 100)
argo = User.create(name: 'Argo', gold: 100)
argo_mp5 = Weapon.create(weapon_type: mp5, user: argo)
UserBuysWeapon.new(user, ak47).perform!
assert_equal ak47, argo.weapon.weapon_type, "User's new weapon should be a AK-47"
assert_equal 20, argo.gold, 'User should be granted 50% of his current MP5'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment