Skip to content

Commit

Permalink
Better failure when screenshot doesn't save
Browse files Browse the repository at this point in the history
* Non-writable paths would raise JSON::ParseError
* Now a clearer error is raised
  • Loading branch information
eagletmt authored and jferris committed Feb 6, 2014
1 parent d787215 commit b78ba75
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions spec/driver_rendering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,14 @@ def render(options)
driver.evaluate_script('window.innerHeight').should eq 600
end
end

context "with invalid filepath" do
before do
@file_name = File.dirname(@file_name)
end

it "raises an InvalidResponseError" do
expect { render({}) }.to raise_error(Capybara::Webkit::InvalidResponseError)
end
end
end
11 changes: 10 additions & 1 deletion src/Render.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Render.h"
#include "WebPage.h"
#include "WebPageManager.h"
#include "ErrorMessage.h"

Render::Render(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
}
Expand All @@ -14,5 +15,13 @@ void Render::start() {

bool result = page()->render( imagePath, size );

finish(result);
if (result) {
finish(true);
} else {
const QString failure = QString("Unable to save %1x%2 image to %3").
arg(width).
arg(height).
arg(imagePath);
finish(false, new ErrorMessage(failure));
}
}

0 comments on commit b78ba75

Please sign in to comment.