spec/rubytter_spec.rb in jugyo-rubytter-0.4.5 vs spec/rubytter_spec.rb in jugyo-rubytter-0.4.6
- old
+ new
@@ -135,16 +135,36 @@
end
@rubytter.search(:q => 'test', :lang => 'ja')
end
it 'should respond to to_param_str' do
- @rubytter.to_param_str(:page => 2, :foo => 'bar').should == 'foo=bar&page=2'
+ param_str = @rubytter.to_param_str(:page => 2, :foo => 'bar')
+ p param_str
+ 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
+ end
+
+ it 'should set default header' do
+ rubytter = Rubytter.new('test', 'test')
+ rubytter.header.should == {'User-Agent', "#{APP_NAME}/#{VERSION} (#{HOMEPAGE})"}
+ end
+
+ it 'should able to set custom header' do
+ rubytter = Rubytter.new('test', 'test',
+ {
+ :header => {
+ 'User-Agent' => 'foo'
+ }
+ }
+ )
+ rubytter.header.should == {'User-Agent' => 'foo'}
end
it 'should create struct from json' do
hash = {
:a => 'a',