Here's an example of a simple mock I did for a controller test in a rails application: before(:each) do @page = mock_model(Page) @page.stub!(:path) @page.stub!(:find_by_id) @page_type = mock_model(PageType) @page_type.stub!(:name) @page.stub!(:page_type).and_return(@page_type) end In this case, I'm mocking the Page & PageType models (Objects) as well as stubbing out a few of the methods I call. Th
I want to test uploading a file in a Rails Rspec request test. I'm using Paperclip for asset storage. I've tried: path = 'path/to/fixture_file' params = { file: Rack::Test::UploadedFile.new(path, 'application/pdf', true) } post v1_product_documents_path, params: params In the controller, I get a string "#Rack::Test::UploadedFile:0x0055b544479128>" instead of the actual file. The same code works in
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く