spec/rubytter_spec.rb in rubytter-0.11.0 vs spec/rubytter_spec.rb in rubytter-1.0.0
- old
+ new
@@ -127,20 +127,20 @@
end
@rubytter.search('test', :lang => 'ja')
end
it 'should respond to to_param_str' do
- param_str = Rubytter.to_param_str(:page => 2, :foo => 'bar')
+ param_str = @rubytter.to_param_str(:page => 2, :foo => 'bar')
param_str.should =~ /^.+?=.+?&.+?=.+?$/
param_str.should =~ /page=2/
param_str.should =~ /foo=bar/
end
it 'should raise when call to_param_str with invalid arg' do
- lambda { Rubytter.to_param_str(nil) }.should raise_error(ArgumentError)
- lambda { Rubytter.to_param_str('foo') }.should raise_error(ArgumentError)
- lambda { Rubytter.to_param_str(:bar) }.should raise_error(ArgumentError)
+ lambda { @rubytter.to_param_str(nil) }.should raise_error(ArgumentError)
+ lambda { @rubytter.to_param_str('foo') }.should raise_error(ArgumentError)
+ lambda { @rubytter.to_param_str(:bar) }.should raise_error(ArgumentError)
end
it 'should set default header' do
rubytter = Rubytter.new('test', 'test')
rubytter.header.should == {'User-Agent', "Rubytter/#{VERSION} (http://github.com/jugyo/rubytter)"}
@@ -178,11 +178,11 @@
nil => nil,
:c => {:a => 1, :b => 2},
:d => {:a => {:a => 1, :b => 2}, :b => 1},
:e => [{:a => 1, :b => 2}, {:c => '"<>&'}]
}
- struct = Rubytter.structize(hash)
+ struct = @rubytter.structize(hash)
struct.a.should == 'a'
struct.b.should == 1
struct.c.a.should == 1
struct.c.b.should == 2
struct.d.a.a.should == 1
@@ -196,11 +196,11 @@
it 'should create struct from json(Array)' do
data = [
{"status" => {"text" => "foo", "user" => {"screen_name" => "jugyo_foo"}}},
{"status" => {"text" => "bar", "user" => {"screen_name" => "jugyo_bar"}}},
]
- struct = Rubytter.structize(data)
+ struct = @rubytter.structize(data)
struct[0].status.text.should == 'foo'
struct[0].status.user.screen_name.should == 'jugyo_foo'
struct[1].status.text.should == 'bar'
struct[1].status.user.screen_name.should == 'jugyo_bar'
end
@@ -214,11 +214,11 @@
nil => nil,
:c => {:a => 1, :b => 2},
:d => {:a => {:a => 1, :b => 2}, :b => 1},
:e => [{:a => 1, :b => 2}, {:c => '"<>&'}]
}
- struct = Rubytter.structize(hash)
+ struct = @rubytter.structize(hash)
struct.to_hash.should == {
:a => "a",
"b" => 1,
:b => 1,
:c => {:b => 2, :a => 1},
@@ -230,11 +230,11 @@
it 'should convert struct to hash with escape as HTML' do
pending
hash = {
:e => [{:a => 1, :b => 2}, {:c => '"<>&'}]
}
- struct = Rubytter.structize(hash)
+ struct = @rubytter.structize(hash)
struct.to_hash(true).should == {"e"=>[{"a"=>1, "b"=>2}, {"c"=>""<>&"}]}
end
it 'should convert struct to json' do
pending
@@ -246,11 +246,11 @@
nil => nil,
:c => {:a => 1, :b => 2},
:d => {:a => {:a => 1, :b => 2}, :b => 1},
:e => [{:a => 1, :b => 2}, {:c => '"<>&'}]
}
- struct = Rubytter.structize(hash)
+ struct = @rubytter.structize(hash)
struct.to_json.should == '{"a":"a","b":1,"c":{"a":1,"b":2},"d":{"a":{"a":1,"b":2},"b":1},"e":[{"a":1,"b":2},{"c":"\"<>&"}]}'
end
it 'should convert struct to json with escape as HTML' do
pending
@@ -260,13 +260,13 @@
struct = Rubytter.structize(hash)
struct.to_json(true).should == '{"e":[{"a":1,"b":2},{"c":""<>&"}]}'
end
it 'should create same structs from same datas' do
- Rubytter.structize({:a => 'a'}).should == Rubytter.structize({:a => 'a'})
- Rubytter.structize({:a => 'a', :b => {:c => 'c'}}).should ==
- Rubytter.structize({:a => 'a', :b => {:c => 'c'}})
+ @rubytter.structize({:a => 'a'}).should == @rubytter.structize({:a => 'a'})
+ @rubytter.structize({:a => 'a', :b => {:c => 'c'}}).should ==
+ @rubytter.structize({:a => 'a', :b => {:c => 'c'}})
end
it 'should be set app_name' do
rubytter = Rubytter.new('test', 'teat', :app_name => "Foo")
rubytter.should_receive(:__update_status).with({:status => 'test', :source => "Foo"})
@@ -283,12 +283,11 @@
'to_usre' => 'jugyo_test',
'from_user_id' => '3748631',
'from_user' => 'jugyo',
'profile_image_url' => 'http://s3.amazonaws.com/twitter_production/profile_images/63467667/megane2_normal.png'
}
- rubytter = Rubytter.new('test', 'teat')
- result = Rubytter.search_result_to_hash(json_data)
+ result = @rubytter.search_result_to_hash(json_data)
result['id'].should == '123'
result['text'].should == 'foo foo bar bar'
result['created_at'].should == 'Sat, 21 Mar 2009 09:48:20 +0000'
result['source'].should == '<a href="http:\/\/twitter.com\/">web<\/a>'
result['in_reply_to_user_id'].should == '20660692'
@@ -353,10 +352,10 @@
access_token = Object.new
rubytter = OAuthRubytter.new(access_token)
response = simple_mock(:body => '{}', :code => '200')
access_token.should_receive(:post).with(
"/statuses/update.json",
- {:status => 'test'},
+ {'status' => 'test'},
{"User-Agent"=>"Rubytter/#{Rubytter::VERSION} (http://github.com/jugyo/rubytter)"}
).and_return(response)
rubytter.update('test')
end