Skip to content

Commit

Permalink
Fixes for Ruby 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
macks committed Dec 2, 2009
1 parent 3dd06db commit ad3358b
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/termtter/rubytter_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(*args)
end

def method_missing(method, *args, &block)
if @rubytter.methods.include?(method.to_s)
if @rubytter.respond_to?(method)
result = nil
begin
modified_args = args
Expand Down
3 changes: 2 additions & 1 deletion lib/termtter/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def initialize(args = {}, &block)
@work = true
end
def execute
exec_proc.call(self) if work
args = if exec_proc.arity.zero? then [] else [self] end
exec_proc.call(*args) if work
end
end
end
4 changes: 2 additions & 2 deletions spec/plugins/defaults/hashtag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

it 'should add hashtag "test"' do
Termtter::Client.call_commands('hashtag add test')
Termtter::Client.public_storage[:hashtags].should == Set.new('#test')
Termtter::Client.public_storage[:hashtags].should == Set.new(['#test'])
end

it 'should add hashtag "#test"' do
Termtter::Client.call_commands('hashtag add #test')
Termtter::Client.public_storage[:hashtags].should == Set.new('#test')
Termtter::Client.public_storage[:hashtags].should == Set.new(['#test'])
end

it 'should add hashtags "foo", "bar"' do
Expand Down
8 changes: 4 additions & 4 deletions spec/termtter/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
module Termtter
describe 'Command#initialize' do
it 'requires the name element in the argument hash' do
lambda { Command.new(:nama => 1) }.should raise_error(ArgumentError)
lambda { Command.new(:name => 1) }.should_not raise_error(ArgumentError)
lambda { Command.new(:nama => :a) }.should raise_error(ArgumentError)
lambda { Command.new(:name => :a) }.should_not raise_error(ArgumentError)
end

it 'does not destroy the argument hash' do
hash = {
:name => 1,
:name => 'a',
:exec => 3
}
Command.new hash

hash.should eql(hash)
hash[:name].should == 1
hash[:name].should == 'a'
hash[:exec].should == 3
hash[:exec_proc].should be_nil
end
Expand Down
4 changes: 2 additions & 2 deletions spec/termtter/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ module Termtter

it 'can raise error when add by prohibited name' do
lambda {
@config.set_default('sub.aaa', :value)
@config.sub.aaa
@config.set_default('open.aaa', :value)
@config.open.aaa
}.should raise_error
end

Expand Down
12 changes: 6 additions & 6 deletions spec/termtter/system_extensions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

it 'provides win?' do
be_quiet do
original_ruby_platform = RUBY_PLATFORM
RUBY_PLATFORM = 'darwin'
original_ruby_platform = ::RUBY_PLATFORM
::RUBY_PLATFORM = 'darwin'
win?.should == false
RUBY_PLATFORM = 'mswin'
::RUBY_PLATFORM = 'mswin'
win?.should == true
RUBY_PLATFORM = original_ruby_platform
::RUBY_PLATFORM = original_ruby_platform
end
end

Expand All @@ -27,7 +27,7 @@
end

it 'extend DL::Impoter when not be able to find DL::Importable' do
DL::Importer = mock(:importer)
be_quiet { DL::Importer = mock(:importer) }
DL.stub(:const_defined?).with(:Importable).and_return(false)
Readline::LIBREADLINE.should_receive(:extend).with(DL::Importer)
load 'termtter/system_extensions.rb'
Expand All @@ -51,7 +51,7 @@
['darwin', 'open'],
['hogehog', 'open'],
].each do |platform, browser|
RUBY_PLATFORM = platform
::RUBY_PLATFORM = platform
self.should_receive(:system).with(browser, url)
open_browser(url)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/termtter/task_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module Termtter
called = false
block = lambda { called = true}
@task_manager.should_receive(:invoke_and_wait).with(&block)
@task_manager.invoke_later &block
@task_manager.invoke_later(&block).join
called.should be_true
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/termtter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
describe Termtter, 'when termtter is loaded' do
it 'will add load path' do
termtter_path = File.expand_path(File.dirname(__FILE__) + '/../lib/termtter.rb')
termtter_lib_path = File.dirname(termtter_path)
original_load_path = $:.dup
$:.clear
$:.delete(termtter_lib_path)
$:.include?(termtter_lib_path).should == false
be_quiet { load termtter_path }
$:.include?(File.dirname(termtter_path)).should == true
$:.include?(termtter_lib_path).should == true
$:.concat(original_load_path)
end
end

0 comments on commit ad3358b

Please sign in to comment.