Skip to content

Commit

Permalink
convert expect syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Feb 24, 2014
1 parent cee0b15 commit 4008c40
Show file tree
Hide file tree
Showing 44 changed files with 491 additions and 500 deletions.
1 change: 0 additions & 1 deletion atig.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ Gem::Specification.new do |gem|

gem.add_development_dependency 'bundler'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'coveralls'
end
14 changes: 7 additions & 7 deletions spec/command/autofix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
@opts.autofix = true
target = status 'hello', 'id'=>'42'
entry = entry user(1,'mzp'), target, "entry", 1
@statuses.should_receive(:find_by_user).with(@me,:limit=>1).and_return([ entry ])
expect(@statuses).to receive(:find_by_user).with(@me,:limit=>1).and_return([ entry ])
end

it "should post normal tweet" do
res = status('blah blah')
@api.should_receive(:post).with('statuses/update', {:status=>'blah blah'}).and_return(res)
expect(@api).to receive(:post).with('statuses/update', {:status=>'blah blah'}).and_return(res)

call '#twitter', "autofix", %w(blah blah)
end

it "should delete old similar tweet" do
res = status('hillo')
@api.should_receive(:post).with('statuses/update', {:status=>'hillo'}).and_return(res)
@api.should_receive(:post).with("statuses/destroy/42")
@statuses.should_receive(:remove_by_id).with(1)
expect(@api).to receive(:post).with('statuses/update', {:status=>'hillo'}).and_return(res)
expect(@api).to receive(:post).with("statuses/destroy/42")
expect(@statuses).to receive(:remove_by_id).with(1)

@channel.should_receive(:notify).with("Similar update in previous. Conclude that it has error.")
@channel.should_receive(:notify).with("And overwrite previous as new status: hillo")
expect(@channel).to receive(:notify).with("Similar update in previous. Conclude that it has error.")
expect(@channel).to receive(:notify).with("And overwrite previous as new status: hillo")

call '#twitter', "autofix", %w(hillo)
end
Expand Down
20 changes: 10 additions & 10 deletions spec/command/destroy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

it "should specified other's status" do
entry = entry user(2,'other'), status('blah blah', 'id'=>'1')
@statuses.stub(:find_by_tid).with('b').and_return(entry)
allow(@statuses).to receive(:find_by_tid).with('b').and_return(entry)

@channel.should_receive(:notify).with("The status you specified by the ID tid is not yours.")
expect(@channel).to receive(:notify).with("The status you specified by the ID tid is not yours.")
call "#twitter","destory",%w(b)
end
end
Expand All @@ -34,17 +34,17 @@
stub_status(:find_by_screen_name,'mzp' => [ entry ], :default=>[])

# api
@api.should_receive(:post).with("statuses/destroy/1")
expect(@api).to receive(:post).with("statuses/destroy/1")

# notice
@channel.should_receive(:notify).with("Destroyed: blah blah")
expect(@channel).to receive(:notify).with("Destroyed: blah blah")

# update topics
new_entry = entry @me, status('foo', 'id'=>'2')
@gateway.should_receive(:topic).with(new_entry)
expect(@gateway).to receive(:topic).with(new_entry)

@statuses.should_receive(:remove_by_id).with(1).and_return{
@statuses.should_receive(:find_by_screen_name).with(@me.screen_name,:limit=>1).and_return{
expect(@statuses).to receive(:remove_by_id).with(1){
expect(@statuses).to receive(:find_by_screen_name).with(@me.screen_name,:limit=>1){
[ new_entry ]
}
}
Expand Down Expand Up @@ -78,13 +78,13 @@
stub_status(:find_by_screen_name, @db.me.screen_name => [ entry ], :default=>[])

# api
@api.should_receive(:post).with("statuses/destroy/1")
expect(@api).to receive(:post).with("statuses/destroy/1")

# notice
@channel.should_receive(:notify).with("Destroyed: blah blah")
expect(@channel).to receive(:notify).with("Destroyed: blah blah")

# update topics
@statuses.should_receive(:remove_by_id).with(1)
expect(@statuses).to receive(:remove_by_id).with(1)
end

it "should specified by tid" do
Expand Down
8 changes: 4 additions & 4 deletions spec/command/dm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
end

it "should have '/me dm' name" do
@gateway.names.should == ['d', 'dm','dms']
expect(@gateway.names).to eq(['d', 'dm','dms'])
end

it "should post the status by API" do
@api.should_receive(:post).with('direct_messages/new',
expect(@api).to receive(:post).with('direct_messages/new',
{:screen_name => 'mzp', :text => 'blah blah'})
@channel.should_receive(:notify).with("Sent message to mzp: blah blah")
expect(@channel).to receive(:notify).with("Sent message to mzp: blah blah")
call '#twitter', "dm", %w(mzp blah blah)
end

it "should post the status by API" do
@channel.should_receive(:notify).with("/me dm <SCREEN_NAME> blah blah")
expect(@channel).to receive(:notify).with("/me dm <SCREEN_NAME> blah blah")
call '#twitter', "dm", %w()
end
end
20 changes: 10 additions & 10 deletions spec/command/favorite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,36 @@
end

it "should post fav by tid" do
@api.should_receive(:post).with("favorites/create", {:id => "1"})
@channel.should_receive(:notify).with("FAV: mzp: blah blah")
expect(@api).to receive(:post).with("favorites/create", {:id => "1"})
expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")

call "#twitter","fav",%w(a)
end

it "should post fav by sid" do
@api.should_receive(:post).with("favorites/create", {:id => "1"})
@channel.should_receive(:notify).with("FAV: mzp: blah blah")
expect(@api).to receive(:post).with("favorites/create", {:id => "1"})
expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")

call "#twitter","fav",%w(mzp:a)
end

it "should post fav by screen name" do
@api.should_receive(:post).with("favorites/create", {:id => "1"})
@channel.should_receive(:notify).with("FAV: mzp: blah blah")
expect(@api).to receive(:post).with("favorites/create", {:id => "1"})
expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")

call "#twitter","fav",%w(mzp)
end

it "should post fav by screen name with at" do
@api.should_receive(:post).with("favorites/create", {:id => "1"})
@channel.should_receive(:notify).with("FAV: mzp: blah blah")
expect(@api).to receive(:post).with("favorites/create", {:id => "1"})
expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")

call "#twitter","fav",%w(@mzp)
end

it "should post unfav" do
@api.should_receive(:post).with("favorites/destroy", {:id => "1"})
@channel.should_receive(:notify).with("UNFAV: mzp: blah blah")
expect(@api).to receive(:post).with("favorites/destroy", {:id => "1"})
expect(@channel).to receive(:notify).with("UNFAV: mzp: blah blah")

call "#twitter","unfav",%w(a)
end
Expand Down
12 changes: 6 additions & 6 deletions spec/command/limit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
before do
@reset = ::Time.utc(2010,9,25,8,24,12)
@command = init Atig::Command::Limit
@api.stub(:limit).and_return(150)
@api.stub(:remain).and_return(148)
@api.stub(:reset).and_return(@reset)
allow(@api).to receive(:limit).and_return(150)
allow(@api).to receive(:remain).and_return(148)
allow(@api).to receive(:reset).and_return(@reset)
end

it "should provide limit command" do
@gateway.names.should == ['rls','limit','limits']
expect(@gateway.names).to eq(['rls','limit','limits'])
end

it "should show limit" do
@channel.should_receive(:notify).with("148 / 150 (reset at 2010-09-25 08:24:12)")
expect(@channel).to receive(:notify).with("148 / 150 (reset at 2010-09-25 08:24:12)")
call '#twitter', 'limit', []
@gateway.notified.should == '#twitter'
expect(@gateway.notified).to eq('#twitter')
end
end
8 changes: 4 additions & 4 deletions spec/command/location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
end

it "should update location" do
@api.should_receive(:post).with('account/update_profile',:location=>'some place')
@channel.should_receive(:notify).with("You are in some place now.")
expect(@api).to receive(:post).with('account/update_profile',:location=>'some place')
expect(@channel).to receive(:notify).with("You are in some place now.")
call '#twitter','location',%w(some place)
end

it "should reset location" do
@api.should_receive(:post).with('account/update_profile',:location=>'')
@channel.should_receive(:notify).with("You are nowhere now.")
expect(@api).to receive(:post).with('account/update_profile',:location=>'')
expect(@channel).to receive(:notify).with("You are nowhere now.")
call '#twitter','location',%w()
end
end
4 changes: 2 additions & 2 deletions spec/command/name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
end

it "should update name" do
@api.should_receive(:post).with('account/update_profile',:name=>'mzp')
@channel.should_receive(:notify).with("You are named mzp.")
expect(@api).to receive(:post).with('account/update_profile',:name=>'mzp')
expect(@channel).to receive(:notify).with("You are named mzp.")
call '#twitter', 'name', %w(mzp)
end
end
56 changes: 28 additions & 28 deletions spec/command/option_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

it "should provide option command" do
@command.command_name.should == %w(opt opts option options)
expect(@command.command_name).to eq(%w(opt opts option options))
end
end

Expand All @@ -24,20 +24,20 @@
@opts.foo2 = 42
@opts.foo3 = 42.1

@opts.stub(:foo1=)
@opts.stub(:foo2=)
@opts.stub(:foo3=)
allow(@opts).to receive(:foo1=)
allow(@opts).to receive(:foo2=)
allow(@opts).to receive(:foo3=)
end

it "should list up values" do
xs = []
@channel.stub(:notify){|x| xs << x}
allow(@channel).to receive(:notify){|x| xs << x}
call '#twitter', 'opt', %w()
xs.should == [
expect(xs).to eq([
"foo1 => true",
"foo2 => 42",
"foo3 => 42.1",
]
])
end
end

Expand All @@ -47,19 +47,19 @@

before do
@command = init Atig::Command::Option
@opts.stub(:foo).and_return true
@opts.stub(:foo=){|v| @value = v }
@channel.stub(:notify)
allow(@opts).to receive(:foo).and_return true
allow(@opts).to receive(:foo=){|v| @value = v }
allow(@channel).to receive(:notify)
end

it "should show the value" do
@channel.should_receive(:notify).with("foo => true")
expect(@channel).to receive(:notify).with("foo => true")
call '#twitter', 'opt', %w(foo)
end

it "should update the value" do
call '#twitter', 'opt', %w(foo false)
@value.should be_false
expect(@value).to be_falsey
end
end

Expand All @@ -68,19 +68,19 @@

before do
@command = init Atig::Command::Option
@opts.stub(:foo).and_return 42
@opts.stub(:foo=){|v| @value = v }
@channel.stub(:notify)
allow(@opts).to receive(:foo).and_return 42
allow(@opts).to receive(:foo=){|v| @value = v }
allow(@channel).to receive(:notify)
end

it "should show the value" do
@channel.should_receive(:notify).with("foo => 42")
expect(@channel).to receive(:notify).with("foo => 42")
call '#twitter', 'opt', %w(foo)
end

it "should update the value" do
call '#twitter', 'opt', %w(foo 42)
@value.should == 42
expect(@value).to eq(42)
end
end

Expand All @@ -89,19 +89,19 @@

before do
@command = init Atig::Command::Option
@opts.stub(:foo).and_return 1.23
@opts.stub(:foo=){|v| @value = v }
@channel.stub(:notify)
allow(@opts).to receive(:foo).and_return 1.23
allow(@opts).to receive(:foo=){|v| @value = v }
allow(@channel).to receive(:notify)
end

it "should show the value" do
@channel.should_receive(:notify).with("foo => 1.23")
expect(@channel).to receive(:notify).with("foo => 1.23")
call '#twitter', 'opt', %w(foo)
end

it "should update the value" do
call '#twitter', 'opt', %w(foo 1.24)
@value.should == 1.24
expect(@value).to eq(1.24)
end
end

Expand All @@ -110,23 +110,23 @@

before do
@command = init Atig::Command::Option
@opts.stub(:foo).and_return "bar"
@opts.stub(:foo=){|v| @value = v }
@channel.stub(:notify)
allow(@opts).to receive(:foo).and_return "bar"
allow(@opts).to receive(:foo=){|v| @value = v }
allow(@channel).to receive(:notify)
end

it "should show the value" do
@channel.should_receive(:notify).with("foo => bar")
expect(@channel).to receive(:notify).with("foo => bar")
call '#twitter', 'opt', %w(foo)
end

it "should update the value" do
call '#twitter', 'opt', %w(foo baz)
@value.should == 'baz'
expect(@value).to eq('baz')
end

it "should update the value" do
call '#twitter', 'opt', %w(foo blah Blah)
@value.should == 'blah Blah'
expect(@value).to eq('blah Blah')
end
end
6 changes: 3 additions & 3 deletions spec/command/refresh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
end

it "should refresh all" do
@followings.should_receive(:invalidate)
@lists.should_receive(:invalidate).with(:all)
@channel.should_receive(:notify).with("refresh followings/lists...")
expect(@followings).to receive(:invalidate)
expect(@lists).to receive(:invalidate).with(:all)
expect(@channel).to receive(:notify).with("refresh followings/lists...")

call '#twitter','refresh', []
end
Expand Down
Loading

0 comments on commit 4008c40

Please sign in to comment.