GitHub PullRequestReviewCommentEvent at 2014-01-09 01:39:17
Repository: facter
Actor: joshcooper
Payload: {"comment":{"url":"https://api.github.com/repos/puppetlabs/facter/pulls/comments/8745286","id":8745286,"diff_hunk":"@@ -0,0 +1,97 @@\n+# encoding: utf-8\n+\n+require 'spec_helper'\n+require 'facter/util/normalization'\n+\n+describe Facter::Util::Normalization do\n+\n+  subject { described_class }\n+\n+  describe \"validating strings\" do\n+    describe \"and string encoding is supported\", :if => String.instance_methods.include?(:encoding) do\n+      it \"accepts strings that are ASCII and match their encoding\" do\n+        str = \"ASCII\".force_encoding(Encoding::ASCII)\n+        subject.normalize(str)\n+      end\n+\n+      it \"accepts strings that are UTF-8 and match their encoding\" do\n+        str = \"let's make a ☃!\".force_encoding(Encoding::UTF_8)\n+        subject.normalize(str)\n+      end\n+\n+      it \"converts valid non UTF-8 strings to UTF-8\" do\n+        str = \"let's make a ☃!\".encode(Encoding::UTF_16LE)\n+        subject.normalize(str)\n+        expect(str.encoding).to eq Encoding::UTF_8\n+      end\n+\n+      it \"rejects strings that are not UTF-8 and cannot be converted to UTF-8\" do\n+        str = 'ｵﾈ'.force_encoding(Encoding::SHIFT_JIS)\n+        expect {\n+          subject.normalize(str)\n+        }.to raise_error(Facter::Util::Normalization::NormalizationError, /String encoding Shift_JIS is not UTF-8 and could not be converted to UTF-8/)\n+      end\n+\n+      it \"rejects strings that are UTF-8 encoded, but do not match the encoding\" do\n+        str = \"\\255ay!\".force_encoding(Encoding::UTF_8)\n+        expect {\n+          subject.normalize(str)\n+        }.to raise_error(Facter::Util::Normalization::NormalizationError, /String.*doesn't match the reported encoding UTF-8/)\n+      end\n+    end\n+\n+    describe \"and string encoding is not supported\", :unless => String.instance_methods.include?(:encoding) do\n+      it \"accepts strings that are UTF-8 and match their encoding\" do\n+        str = \"let's make a ☃!\"\n+        expect { subject.normalize(str) }.to_not raise_error","path":"spec/unit/util/normalization_spec.rb","position":47,"original_position":46,"commit_id":"22d55a64c192cc95706bbbec8ad95d208e38772b","original_commit_id":"c73931cb804f304d91d3db95dba20c7dfa06bbfe","user":{"login":"joshcooper","id":737664,"avatar_url":"https://gravatar.com/avatar/c7ff0fe7a67ef06a7717c0dde345acc7?d=https%3A%2F%2Fidenticons.github.com%2F490120ce0ccf7a44a9ea68c1bafe66a0.png&r=x","gravatar_id":"c7ff0fe7a67ef06a7717c0dde345acc7","url":"https://api.github.com/users/joshcooper","html_url":"https://github.com/joshcooper","followers_url":"https://api.github.com/users/joshcooper/followers","following_url":"https://api.github.com/users/joshcooper/following{/other_user}","gists_url":"https://api.github.com/users/joshcooper/gists{/gist_id}","starred_url":"https://api.github.com/users/joshcooper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshcooper/subscriptions","organizations_url":"https://api.github.com/users/joshcooper/orgs","repos_url":"https://api.github.com/users/joshcooper/repos","events_url":"https://api.github.com/users/joshcooper/events{/privacy}","received_events_url":"https://api.github.com/users/joshcooper/received_events","type":"User","site_admin":false},"body":"I think you can remove the `expect { .. }.to_not raise_error` part.","created_at":"2014-01-09T01:39:17Z","updated_at":"2014-01-09T01:39:17Z","html_url":"https://github.com/puppetlabs/facter/pull/575#discussion_r8745286","pull_request_url":"https://api.github.com/repos/puppetlabs/facter/pulls/575","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/facter/pulls/comments/8745286"},"html":{"href":"https://github.com/puppetlabs/facter/pull/575#discussion_r8745286"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/facter/pulls/575"}}}}