spec/netprint/agent_spec.rb in netprint-0.3.1 vs spec/netprint/agent_spec.rb in netprint-0.3.3
- old
+ new
@@ -6,11 +6,11 @@
describe Agent do
before do
@agent = Agent.new('user_id', 'password')
stub_request(:get, 'https://www.printing.ne.jp/usr/web/NPCM0010.seam').
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../login.html')).read)
+ to_return(read_fixture_file('login.html'))
stub_request(:post, 'https://www.printing.ne.jp/usr/web/NPCM0010.seam').
with(body: {
'NPCM0010' => 'NPCM0010',
'NPCM0010:login-btn' => 'ログイン',
@@ -18,11 +18,11 @@
'NPCM0010:password-pwd' => 'password',
'controlParamKey' => 'foo',
'javax.faces.ViewState' => 'bar'
}
).
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list_empty.html')).read)
+ to_return(read_fixture_file('list_empty.html'))
end
it 'should login' do
@agent.should_not be_login
@@ -40,25 +40,25 @@
'create-document' => '',
'controlParamKey' => 'xxx',
'javax.faces.ViewState' => 'yyy'
}
).
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../upload.html')).read)
+ to_return(read_fixture_file('upload.html'))
stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0020.seam').
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list_processing.html')).read)
+ to_return(read_fixture_file('list_processing.html'))
stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0010.seam').
with(body: {
'NPFL0010' => 'NPFL0010',
'display-max-rows' => '10',
'reload' => '',
'controlParamKey' => 'xxx',
'javax.faces.ViewState' => 'yyy'
}
).
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list_processed.html')).read)
+ to_return(read_fixture_file('list_processed.html'))
filename = File.expand_path(pdf_filename)
@agent.login
code = @agent.upload(filename)
@@ -73,25 +73,25 @@
'create-document' => '',
'controlParamKey' => 'xxx',
'javax.faces.ViewState' => 'yyy'
}
).
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../upload.html')).read)
+ to_return(read_fixture_file('upload.html'))
stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0020.seam').
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list_processing.html')).read)
+ to_return(read_fixture_file('list_processing.html'))
stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0010.seam').
with(body: {
'NPFL0010' => 'NPFL0010',
'display-max-rows' => '10',
'reload' => '',
'controlParamKey' => 'xxx',
'javax.faces.ViewState' => 'yyy'
}
).
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list_error.html')).read)
+ to_return(read_fixture_file('list_error.html'))
filename = File.expand_path(pdf_filename)
@agent.login
lambda {
@@ -107,14 +107,14 @@
'create-document' => '',
'controlParamKey' => 'xxx',
'javax.faces.ViewState' => 'yyy'
}
).
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../upload.html')).read)
+ to_return(read_fixture_file('upload.html'))
stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0020.seam').
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../upload_error.html')).read)
+ to_return(read_fixture_file('upload_error.html'))
filename = File.expand_path(pdf_filename)
@agent.login
lambda {
@@ -122,16 +122,16 @@
}.should raise_error(UploadError, 'error message')
end
end
context 'filename is ASCII only' do
- let(:pdf_filename) { File.dirname(__FILE__) + '/../foo.pdf' }
+ let(:pdf_filename) { fixture_file('foo.pdf') }
it_should_behave_like '#upload'
end
context 'filename has non-ASCII characters' do
- let(:pdf_filename) { File.dirname(__FILE__) + '/../あいうえお.pdf' }
+ let(:pdf_filename) { fixture_file('あいうえお.pdf') }
it_should_behave_like '#upload'
end
end