Skip to content

Instantly share code, notes, and snippets.

@AJFaraday
Last active December 21, 2015 06:09
Show Gist options
  • Select an option

  • Save AJFaraday/6262089 to your computer and use it in GitHub Desktop.

Select an option

Save AJFaraday/6262089 to your computer and use it in GitHub Desktop.
andrew@andrew-laptop:~/RubyPG$ ruby test/unit/skill_effect_test.rb
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
*** Mocha deprecation warning: Test::Unit or MiniTest must be loaded *before* Mocha.
*** Mocha deprecation warning: If you're integrating with a test library other than Test::Unit or MiniTest, you should use `require 'mocha/api'` instead of `require 'mocha'`.
Loaded suite test/unit/skill_effect_test
Started
E
Finished in 0.43956 seconds.
1) Error:
test_attack(SkillEffectTest):
NoMethodError: undefined method `stub' for #<Mocha::ClassMethods::AnyInstance:0xb6d576c0>
test/unit/skill_effect_test.rb:22:in `stub_for_successful_effect'
test/unit/skill_effect_test.rb:13:in `test_attack'
1 tests, 0 assertions, 0 failures, 1 errors
require File.dirname(__FILE__)+'/../test_helper.rb'
class SkillEffectTest < ActiveSupport::TestCase
def setup
@character = Character.create(:name => 'Player',
:character_class => CharacterClass.find_by_name('Fighter'))
@enemy = Character.create(:name => 'Snail',
:character_class => CharacterClass.find_by_name('Snail'))
end
def test_attack
stub_for_successful_effect
skill = @character.skills.find_by_label('Attack')
effect = skill.skill_effects[0]
# character attacks enemy
effect.use(@character,@enemy)
end
def stub_for_successful_effect
SkillEffect.any_instance.stub(:roll_for_evade).and_return(false)
#SkillEffect.any_instance.stub(:roll_for_defence).and_return(false)
#SkillEffect.any_instnace.stub(:roll_for_critical).and_retrn(true)
end
end
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment