Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

convert to utf8 string #24

Merged
merged 2 commits into from

2 participants

@hotchpotch
  • #8 I fixed that problem.
@hotchpotch

Hi, I fixed capybara command support utf8.

( click_link, click_button, etc ...)

@jferris jferris merged commit 9db603c into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 19, 2011
  1. @hotchpotch

    convert to utf8 string

    hotchpotch authored
  2. @hotchpotch
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 5 deletions.
  1. +18 −2 spec/integration/session_spec.rb
  2. +4 −3 src/Connection.cpp
View
20 spec/integration/session_spec.rb
@@ -1,3 +1,5 @@
+# -*- encoding: UTF-8 -*-
+
require 'spec_helper'
require 'capybara-webkit'
@@ -50,18 +52,32 @@
body = <<-HTML
<html><body>
<strong>Hello</strong>
+ <span>UTF8文字列</span>
+ <input type="button" value="ボタン" />
</body></html>
HTML
[200,
- { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
+ { 'Content-Type' => 'text/html; charset=UTF-8', 'Content-Length' => body.length.to_s },
[body]]
end
end
- it "inspects nodes" do
+ before do
subject.visit("/")
+ end
+
+ it "inspects nodes" do
subject.all(:xpath, "//strong").first.inspect.should include("strong")
end
+
+ it "can read utf8 string" do
+ utf8str = subject.all(:xpath, "//span").first.text
+ utf8str.should eq('UTF8文字列')
+ end
+
+ it "can click utf8 string" do
+ subject.click_button('ボタン')
+ end
end
end
View
7 src/Connection.cpp
@@ -69,7 +69,7 @@ void Connection::processArgument(const char *data) {
} else if (m_expectingDataSize == -1) {
m_expectingDataSize = QString(data).toInt();
} else {
- m_arguments.append(data);
+ m_arguments.append(QString::fromUtf8(data));
}
if (m_arguments.length() == m_argumentsExpected) {
@@ -123,8 +123,9 @@ void Connection::writeResponse(bool success, QString &response) {
else
m_socket->write("failure\n");
- QString responseLength = QString::number(response.size()) + "\n";
+ QByteArray response_utf8 = response.toUtf8();
+ QString responseLength = QString::number(response_utf8.size()) + "\n";
m_socket->write(responseLength.toAscii());
- m_socket->write(response.toAscii());
+ m_socket->write(response_utf8);
}
Something went wrong with that request. Please try again.