termtter 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/bin/termtter +1 -0
- data/lib/plugins/another_prompt.rb +131 -0
- data/lib/plugins/async.rb +23 -0
- data/lib/plugins/confirm.rb +1 -1
- data/lib/plugins/db.rb +1 -1
- data/lib/plugins/defaults/auto_reload.rb +20 -19
- data/lib/plugins/defaults/command_line.rb +10 -5
- data/lib/plugins/defaults/hashtag.rb +35 -0
- data/lib/plugins/defaults/lists.rb +14 -0
- data/lib/plugins/defaults/retweet.rb +15 -15
- data/lib/plugins/defaults/standard_commands.rb +22 -28
- data/lib/plugins/defaults/standard_completion.rb +5 -5
- data/lib/plugins/defaults/switch.rb +34 -0
- data/lib/plugins/eject.rb +15 -0
- data/lib/plugins/expand-tinyurl.rb +1 -1
- data/lib/plugins/favotter.rb +77 -0
- data/lib/plugins/friends.rb +50 -0
- data/lib/plugins/g.rb +16 -0
- data/lib/plugins/gsub.rb +17 -0
- data/lib/plugins/haml.rb +55 -0
- data/lib/plugins/hatebu_and_update.rb +2 -2
- data/lib/plugins/history.rb +9 -0
- data/lib/plugins/irc_gw.rb +11 -4
- data/lib/plugins/linefeed.rb +31 -0
- data/lib/plugins/md5pass.rb +42 -0
- data/lib/plugins/outputz.rb +1 -1
- data/lib/plugins/primes.rb +1 -1
- data/lib/plugins/quote.rb +43 -0
- data/lib/plugins/reduce_text.rb +26 -0
- data/lib/plugins/reverse.rb +7 -6
- data/lib/plugins/source.rb +31 -0
- data/lib/plugins/storage/status.rb +2 -2
- data/lib/plugins/storage.rb +1 -1
- data/lib/plugins/stream.rb +192 -0
- data/lib/plugins/switch_user.rb +1 -22
- data/lib/plugins/truncate.rb +29 -0
- data/lib/plugins/uri-open.rb +23 -9
- data/lib/plugins/w3mimg.rb +76 -0
- data/lib/termtter/active_rubytter.rb +8 -0
- data/lib/termtter/api.rb +37 -13
- data/lib/termtter/client.rb +26 -47
- data/lib/termtter/command.rb +15 -9
- data/lib/termtter/config.rb +6 -2
- data/lib/termtter/hookable.rb +59 -0
- data/lib/termtter/optparse.rb +51 -39
- data/lib/termtter/rubytter_proxy.rb +32 -0
- data/lib/termtter/system_extensions/core_compatibles.rb +16 -0
- data/lib/termtter/system_extensions/termtter_compatibles.rb +19 -0
- data/lib/termtter/system_extensions/windows.rb +86 -0
- data/lib/termtter/system_extensions.rb +8 -121
- data/lib/termtter/task_manager.rb +4 -10
- data/lib/termtter/version.rb +1 -1
- data/lib/termtter.rb +5 -3
- data/spec/plugins/defaults/hashtag_spec.rb +41 -0
- data/spec/plugins/defaults/lists_spec.rb +34 -0
- data/spec/plugins/{english_spec.rb → english_spec_.rb} +0 -0
- data/spec/plugins/{filter_spec.rb → filter_spec_.rb} +0 -0
- data/spec/plugins/gsub_spec.rb +18 -0
- data/spec/plugins/haml_spec.rb +134 -0
- data/spec/plugins/md5pass_spec.rb +13 -0
- data/spec/plugins/{primes_spec.rb → primes_spec_.rb} +0 -0
- data/spec/plugins/{sl_spec.rb → sl_spec_.rb} +0 -0
- data/spec/plugins/standard_commands_spec.rb +1 -1
- data/spec/plugins/storage/{DB_spec.rb → DB_spec_.rb} +0 -0
- data/spec/plugins/storage/{status_spec.rb → status_spec_.rb} +0 -0
- data/spec/plugins/truncate_spec.rb +27 -0
- data/spec/plugins/whois_spec_.rb +20 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/termtter/active_rubytter_spec.rb +17 -0
- data/spec/termtter/api_spec.rb +107 -0
- data/spec/termtter/client_spec.rb +262 -73
- data/spec/termtter/command_spec.rb +31 -5
- data/spec/termtter/config_setup_spec.rb +19 -0
- data/spec/termtter/config_spec.rb +57 -27
- data/spec/termtter/hook_spec.rb +12 -0
- data/spec/termtter/hookable_spec.rb +53 -0
- data/spec/termtter/optparse_spec.rb +64 -9
- data/spec/termtter/rubytter_proxy_spec.rb +42 -0
- data/spec/termtter/system_extensions/windows_spec.rb +9 -0
- data/spec/termtter/system_extensions_spec.rb +61 -0
- data/spec/termtter/task_manager_spec.rb +58 -0
- data/spec/termtter_spec.rb +11 -0
- metadata +45 -20
- data/lib/termtter/connection.rb +0 -41
- data/spec/plugins/whois_spec.rb +0 -26
@@ -8,28 +8,54 @@ module Termtter
|
|
8
8
|
@config = Config.new
|
9
9
|
end
|
10
10
|
|
11
|
-
it '
|
11
|
+
it 'can store value to new storage' do
|
12
12
|
@config.new_storage = :value
|
13
13
|
@config.new_storage.should == :value
|
14
14
|
end
|
15
15
|
|
16
|
-
it '
|
16
|
+
it 'can make subb.key and store value' do
|
17
17
|
@config.subb.key = :value
|
18
18
|
@config.subb.key.should == :value
|
19
19
|
end
|
20
20
|
|
21
|
-
it '
|
21
|
+
it 'can make multiple storage' do
|
22
22
|
@config.subb.more.for.test = 'value'
|
23
23
|
@config.subb.more.for.test.should == 'value'
|
24
24
|
end
|
25
25
|
|
26
|
-
it '
|
26
|
+
it 'can change value in storage' do
|
27
27
|
@config.storage = :value1
|
28
28
|
@config.storage = :value2
|
29
29
|
@config.storage.should == :value2
|
30
30
|
end
|
31
31
|
|
32
|
-
it '
|
32
|
+
it 'can inspect' do
|
33
|
+
@config.storage = :value
|
34
|
+
@config.inspect.should == {:storage => :value}.inspect
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'can get __values__' do
|
38
|
+
@config.storage = :value
|
39
|
+
@config.__values__.should == {:storage => :value}
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'can __clear__' do
|
43
|
+
@config.storage = :value
|
44
|
+
@config.storage.should == :value
|
45
|
+
@config.__clear__
|
46
|
+
result = @config.__values__
|
47
|
+
result.should be_empty
|
48
|
+
result.should be_an_instance_of Hash
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'can be called __clear__ with name' do
|
52
|
+
@config.foo = 'foo'
|
53
|
+
@config.foo.should_not be_empty
|
54
|
+
@config.__clear__(:foo)
|
55
|
+
@config.foo.should be_empty
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'can store any data' do
|
33
59
|
[
|
34
60
|
['string', 'value' ],
|
35
61
|
['symbol', :value ],
|
@@ -44,14 +70,14 @@ module Termtter
|
|
44
70
|
end
|
45
71
|
end
|
46
72
|
|
47
|
-
it '
|
73
|
+
it 'can raise error when add by prohibited name' do
|
48
74
|
lambda {
|
49
75
|
@config.set_default('sub.aaa', :value)
|
50
76
|
@config.sub.aaa
|
51
77
|
}.should raise_error
|
52
78
|
end
|
53
79
|
|
54
|
-
it '
|
80
|
+
it 'can raise error when add subb-storage to existed key' do
|
55
81
|
@config.subb = 'original value'
|
56
82
|
lambda {
|
57
83
|
@config.subb.key = 'invalid subbstitution'
|
@@ -61,7 +87,7 @@ module Termtter
|
|
61
87
|
)
|
62
88
|
end
|
63
89
|
|
64
|
-
it '
|
90
|
+
it 'can set intermediate defult configs' do
|
65
91
|
@config.set_default 'subb.more', 'value'
|
66
92
|
@config.subb.class.should == Config
|
67
93
|
@config.subb.more.should == 'value'
|
@@ -70,31 +96,29 @@ module Termtter
|
|
70
96
|
@config.proxy.port.should == 'value'
|
71
97
|
end
|
72
98
|
|
73
|
-
# FIXME:
|
99
|
+
# FIXME: Is this need spec?
|
74
100
|
# it 'should have :undefined value in un-assigned key' do
|
75
101
|
# @config.aaaa.should == :undefined
|
76
102
|
# end
|
77
103
|
|
78
|
-
it '
|
79
|
-
@config.
|
80
|
-
|
104
|
+
it 'can examin that storage is empty' do
|
105
|
+
@config.should be_empty
|
81
106
|
@config.aaa = 1
|
82
|
-
@config.
|
83
|
-
|
84
|
-
@config.bbb.empty?.should be_true
|
107
|
+
@config.should_not be_empty
|
108
|
+
@config.bbb.should be_empty
|
85
109
|
end
|
86
110
|
|
87
|
-
it '
|
111
|
+
it 'can examin that storage is not empty (nil)' do
|
88
112
|
@config.bbb = nil
|
89
|
-
@config.
|
113
|
+
@config.should_not be_empty
|
90
114
|
end
|
91
115
|
|
92
|
-
it '
|
116
|
+
it 'can examin that storage is not empty (default)' do
|
93
117
|
@config.set_default('aaa', 1)
|
94
|
-
@config.
|
118
|
+
@config.should_not be_empty
|
95
119
|
end
|
96
120
|
|
97
|
-
it '
|
121
|
+
it 'can use in expression' do
|
98
122
|
@config.set_default(:ssb, 'hoge')
|
99
123
|
lambda {
|
100
124
|
res = @config.ssb + ' piyo'
|
@@ -102,20 +126,26 @@ module Termtter
|
|
102
126
|
}.should_not raise_error
|
103
127
|
end
|
104
128
|
|
105
|
-
it '
|
129
|
+
it 'can not change value when call set_default twice' do
|
106
130
|
@config.plugins.set_default :only, 'before_value'
|
107
131
|
@config.plugins.set_default :only, 'after_value'
|
108
132
|
@config.plugins.only.should == 'before_value'
|
109
133
|
end
|
110
134
|
|
111
|
-
it '
|
112
|
-
|
113
|
-
|
135
|
+
it 'can be called set_default with int multiple times' do
|
136
|
+
lambda {
|
137
|
+
@config.set_default(:foo, 1)
|
138
|
+
@config.set_default(:foo, 2)
|
139
|
+
@config.foo.should == 1
|
140
|
+
}.should_not raise_error
|
114
141
|
end
|
115
142
|
|
116
|
-
it '
|
117
|
-
|
118
|
-
|
143
|
+
it 'can be called set_default with string multiple times' do
|
144
|
+
lambda {
|
145
|
+
@config.set_default(:foo, 'foo')
|
146
|
+
@config.set_default(:foo, 'bar')
|
147
|
+
@config.foo.should == 'foo'
|
148
|
+
}.should_not raise_error
|
119
149
|
end
|
120
150
|
end
|
121
151
|
end
|
data/spec/termtter/hook_spec.rb
CHANGED
@@ -62,6 +62,18 @@ module Termtter
|
|
62
62
|
hook.match?(:'_bar_').should == false
|
63
63
|
end
|
64
64
|
|
65
|
+
it 'should not match invalid point' do
|
66
|
+
hook = Hook.new(
|
67
|
+
:name => :spam,
|
68
|
+
:points => [1, { }, nil],
|
69
|
+
:exec_proc => lambda{|cmd, arg|
|
70
|
+
}
|
71
|
+
)
|
72
|
+
hook.match?(1).should == false
|
73
|
+
hook.match?({ }).should == false
|
74
|
+
hook.match?(nil).should == false
|
75
|
+
end
|
76
|
+
|
65
77
|
it 'call hook proc' do
|
66
78
|
proc_args = nil
|
67
79
|
hook = Hook.new(
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
3
|
+
|
4
|
+
module Dummy
|
5
|
+
include Termtter::Hookable
|
6
|
+
end
|
7
|
+
|
8
|
+
module Termtter
|
9
|
+
describe Hookable do
|
10
|
+
|
11
|
+
it 'takes new_hook' do
|
12
|
+
hook = Hook.new(:name => :test)
|
13
|
+
Dummy.register_hook(hook)
|
14
|
+
Dummy.get_hook(:test).should == hook
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'takes hook as Hash' do
|
18
|
+
Dummy.register_hook(:name => :test)
|
19
|
+
Dummy.get_hook(:test).name.should == :test
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'calls new_hook' do
|
23
|
+
hook_called = false
|
24
|
+
Dummy.register_hook(:name => :test1, :points => [:point1], :exec_proc => lambda {hook_called = true})
|
25
|
+
hook_called.should == false
|
26
|
+
Dummy.call_hooks(:point1)
|
27
|
+
hook_called.should == true
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'calls new_hook with args' do
|
31
|
+
arg1 = nil
|
32
|
+
arg2 = nil
|
33
|
+
Dummy.register_hook(:name => :test1, :points => [:point1], :exec_proc => lambda {|a1, a2| arg1 = a1; arg2 = a2})
|
34
|
+
arg1.should == nil
|
35
|
+
arg2.should == nil
|
36
|
+
Dummy.call_hooks(:point1, 'foo', 'bar')
|
37
|
+
arg1.should == 'foo'
|
38
|
+
arg2.should == 'bar'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'return hooks when call get_hooks' do
|
42
|
+
hook1 = Dummy.register_hook(:name => :test1, :points => [:point1])
|
43
|
+
hook2 = Dummy.register_hook(:name => :test2, :points => [:point1])
|
44
|
+
hook3 = Dummy.register_hook(:name => :test3, :points => [:point2])
|
45
|
+
|
46
|
+
hooks = Dummy.get_hooks(:point1)
|
47
|
+
hooks.size.should == 2
|
48
|
+
hooks.include?(hook1).should == true
|
49
|
+
hooks.include?(hook2).should == true
|
50
|
+
hooks.include?(hook3).should == false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,16 +1,71 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require File.dirname(__FILE__) + '/../spec_helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
`./run_termtter.rb #{opt}`
|
7
|
-
end
|
4
|
+
module Termtter
|
5
|
+
describe OptParser do
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
before do
|
8
|
+
@original_conf ||= config
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
conf = @original_conf
|
13
|
+
end
|
14
|
+
|
15
|
+
def run_termtter(opt)
|
16
|
+
`./run_termtter.rb #{opt}`
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'accepts -h option' do
|
20
|
+
run_termtter('-h').should match(/Usage/)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'accepts -f option' do
|
24
|
+
Termtter::OptParser::parse!(%w{-f ~/config})
|
25
|
+
config.system.conf_file.should == '~/config'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'accepts -t option' do
|
29
|
+
Termtter::OptParser::parse!(%w{-t ~/termtter_directory})
|
30
|
+
config.system.conf_dir.should == '~/termtter_directory'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'accepts -d option' do
|
34
|
+
Termtter::OptParser::parse!(%w{-d})
|
35
|
+
config.devel.should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'accepts -c option' do
|
39
|
+
Termtter::OptParser::parse!(%w{-c})
|
40
|
+
config.system.cmd_mode.should be_true
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'accepts -r option' do
|
44
|
+
Termtter::OptParser::parse!(%w{-r cool})
|
45
|
+
config.system.run_commands.should == %w{cool}
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'accepts -p option' do
|
49
|
+
Termtter::OptParser::parse!(%w{-p cool})
|
50
|
+
config.system.load_plugins.should == %w{cool}
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'accepts -e option' do
|
54
|
+
Termtter::OptParser::parse!(%w{-e foo})
|
55
|
+
config.system.eval_scripts.should == %w{foo}
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'accepts -m option' do
|
59
|
+
require 'termcolor'
|
60
|
+
TermColor.parse('<red>cool</red>').should == "\e[31mcool\e[0m"
|
61
|
+
Termtter::OptParser::parse!(%w{-m})
|
62
|
+
TermColor.parse('<red>cool</red>').should == 'cool'
|
63
|
+
module ::TermColor
|
64
|
+
class << self
|
65
|
+
alias parse parse_orig
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
12
69
|
|
13
|
-
it 'accepts -m option' do
|
14
|
-
pending
|
15
70
|
end
|
16
71
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
3
|
+
|
4
|
+
module Termtter
|
5
|
+
describe RubytterProxy do
|
6
|
+
before do
|
7
|
+
@rubytter_mock = Object.new
|
8
|
+
Rubytter.stub!(:new).and_return(@rubytter_mock)
|
9
|
+
@twitter = RubytterProxy.new('foo', 'bar', {})
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should call a Rubytter\'s method' do
|
13
|
+
@rubytter_mock.should_receive(:update).with('test').once
|
14
|
+
@twitter.update('test')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should call a Rubytter\'s method with block' do
|
18
|
+
block = Proc.new{}
|
19
|
+
@rubytter_mock.should_receive(:update).with('test').once
|
20
|
+
@twitter.update('test')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should call hooks' do
|
24
|
+
pre_hook = RubytterProxy.register_hook(:pre, :point => :pre_update) {}
|
25
|
+
pre_hook.should_receive(:call).with('test').and_return(["TEST"])
|
26
|
+
post_hook = RubytterProxy.register_hook(:post, :point => :post_update) {}
|
27
|
+
post_hook.should_receive(:call).with('test')
|
28
|
+
@rubytter_mock.should_receive(:update).with("TEST")
|
29
|
+
|
30
|
+
@twitter.update('test')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should cancel to call method' do
|
34
|
+
pre_hook = RubytterProxy.register_hook(:pre, :point => :pre_update) {raise HookCanceled}
|
35
|
+
post_hook = RubytterProxy.register_hook(:post, :point => :post_update) {}
|
36
|
+
post_hook.should_receive(:call).with('test').never
|
37
|
+
@rubytter_mock.should_receive(:update).never
|
38
|
+
|
39
|
+
@twitter.update('test')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
+
require 'highline'
|
5
|
+
|
6
|
+
describe Termtter do
|
7
|
+
|
8
|
+
it 'provides create_highline' do
|
9
|
+
h = create_highline
|
10
|
+
h.class.should == HighLine
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'provides win?' do
|
14
|
+
be_quiet do
|
15
|
+
original_ruby_platform = RUBY_PLATFORM
|
16
|
+
RUBY_PLATFORM = 'darwin'
|
17
|
+
win?.should == false
|
18
|
+
RUBY_PLATFORM = 'mswin'
|
19
|
+
win?.should == true
|
20
|
+
RUBY_PLATFORM = original_ruby_platform
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'Readline can refresh line' do
|
25
|
+
Readline::LIBREADLINE.should_receive(:rl_refresh_line).with(0, 0)
|
26
|
+
Readline.refresh_line
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'extend DL::Impoter when not be able to find DL::Importable' do
|
30
|
+
DL::Importer = mock(:importer)
|
31
|
+
DL.stub(:const_defined?).with(:Importable).and_return(false)
|
32
|
+
Readline::LIBREADLINE.should_receive(:extend).with(DL::Importer)
|
33
|
+
load 'termtter/system_extensions.rb'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'can handle error when difine LIBREADLINE' do
|
37
|
+
Readline::LIBREADLINE.stub(:extend) { raise }
|
38
|
+
load 'termtter/system_extensions.rb'
|
39
|
+
Readline::LIBREADLINE.should_not_receive(:rl_refresh_line)
|
40
|
+
Readline.refresh_line
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'can open browser that suites platform' do
|
44
|
+
be_quiet(:stdout => false) do
|
45
|
+
url = 'example.com'
|
46
|
+
[
|
47
|
+
['linux', 'firefox'],
|
48
|
+
['mswin', 'explorer'],
|
49
|
+
['mingw', 'explorer'],
|
50
|
+
['bccwin', 'explorer'],
|
51
|
+
['darwin', 'open'],
|
52
|
+
['hogehog', 'open'],
|
53
|
+
].each do |platform, browser|
|
54
|
+
RUBY_PLATFORM = platform
|
55
|
+
self.should_receive(:system).with(browser, url)
|
56
|
+
open_browser(url)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -68,11 +68,69 @@ module Termtter
|
|
68
68
|
@task_manager.instance_eval('@tasks').size.should == 1
|
69
69
|
end
|
70
70
|
|
71
|
+
it 'should run (not pause)' do
|
72
|
+
be_quiet do
|
73
|
+
counter = 0
|
74
|
+
TaskManager::INTERVAL = 0
|
75
|
+
@task_manager.stub(:step) { counter += 1 }
|
76
|
+
@task_manager.instance_variable_set(:@work, true)
|
77
|
+
@task_manager.run
|
78
|
+
100.times do
|
79
|
+
break if counter != 0
|
80
|
+
sleep 0.1
|
81
|
+
end
|
82
|
+
@task_manager.instance_variable_set(:@work, false)
|
83
|
+
counter.should > 0
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should run (pause)' do
|
88
|
+
be_quiet do
|
89
|
+
counter = 0
|
90
|
+
TaskManager::INTERVAL = 0.1
|
91
|
+
@task_manager.stub(:step) { counter += 1 }
|
92
|
+
@task_manager.instance_variable_set(:@work, true)
|
93
|
+
@task_manager.instance_variable_set(:@pause, true)
|
94
|
+
@task_manager.run
|
95
|
+
sleep 0.1
|
96
|
+
counter.should == 0
|
97
|
+
@task_manager.instance_variable_set(:@pause, false)
|
98
|
+
100.times do
|
99
|
+
break if counter != 0
|
100
|
+
sleep 0.1
|
101
|
+
end
|
102
|
+
@task_manager.instance_variable_set(:@work, false)
|
103
|
+
counter.should > 0
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
71
107
|
it 'should add task with :name' do
|
72
108
|
@task_manager.add_task(:name => 'foo')
|
73
109
|
@task_manager.get_task('foo').name.should == 'foo'
|
74
110
|
@task_manager.delete_task('foo')
|
75
111
|
@task_manager.get_task('foo').should == nil
|
76
112
|
end
|
113
|
+
|
114
|
+
it 'should be killed' do
|
115
|
+
@task_manager.instance_eval('@work').should == true
|
116
|
+
@task_manager.kill
|
117
|
+
@task_manager.instance_eval('@work').should == false
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should be paused or resumed' do
|
121
|
+
@task_manager.instance_eval('@pause').should == false
|
122
|
+
@task_manager.pause
|
123
|
+
@task_manager.instance_eval('@pause').should == true
|
124
|
+
@task_manager.resume
|
125
|
+
@task_manager.instance_eval('@pause').should == false
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'invoke_later calls invoke_and_wait' do
|
129
|
+
called = false
|
130
|
+
block = lambda { called = true}
|
131
|
+
@task_manager.should_receive(:invoke_and_wait).with(&block)
|
132
|
+
@task_manager.invoke_later &block
|
133
|
+
called.should be_true
|
134
|
+
end
|
77
135
|
end
|
78
136
|
end
|
data/spec/termtter_spec.rb
CHANGED
@@ -26,3 +26,14 @@ describe Termtter, 'when plugin is called (with init option)' do
|
|
26
26
|
config.plugins.aaa.bbb.should == :ccc
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
describe Termtter, 'when termtter is loaded' do
|
31
|
+
it 'will add load path' do
|
32
|
+
termtter_path = File.expand_path(File.dirname(__FILE__) + '/../lib/termtter.rb')
|
33
|
+
original_load_path = $:.dup
|
34
|
+
$:.clear
|
35
|
+
be_quiet { load termtter_path }
|
36
|
+
$:.include?(File.dirname(termtter_path)).should == true
|
37
|
+
$:.concat(original_load_path)
|
38
|
+
end
|
39
|
+
end
|