1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

added more tests for hooks system

This commit is contained in:
John Mair 2011-11-17 23:20:07 +13:00
parent 8f08cf7300
commit dc7e094e98

View file

@ -41,6 +41,28 @@ describe Pry::Hooks do
end
end
describe "getting a hook" do
it 'should return the correct requested hook' do
run = false
fun = false
@hooks.add_hook(:test_hook, :my_name) { run = true }
@hooks.add_hook(:test_hook, :my_name2) { fun = true }
@hooks.get_hook(:test_hook, :my_name).call
run.should == true
fun.should == false
end
end
describe "clearing all hooks for an event" do
it 'should clear all hooks' do
@hooks.add_hook(:test_hook, :my_name) { }
@hooks.add_hook(:test_hook, :my_name2) { }
@hooks.add_hook(:test_hook, :my_name3) { }
@hooks.clear(:test_hook)
@hooks.hook_count(:test_hook).should == 0
end
end
describe "deleting a hook" do
it 'should successfully delete a hook function' do
@hooks.add_hook(:test_hook, :my_name) {}
@ -49,9 +71,10 @@ describe Pry::Hooks do
end
it 'should return the deleted hook function' do
@hooks.add_hook(:test_hook, :my_name) {}
@hooks.delete_hook(:test_hook, :my_name)
@hooks.hook_count(:test_hook).should == 0
run = false
@hooks.add_hook(:test_hook, :my_name) { run = true }
@hooks.delete_hook(:test_hook, :my_name).call
run.should == true
end
end