문제

I have the following failing unit test;

it "should handle white space" do
  Sanitize.clean('   ').should == ''
end

Which fails because the result of Sanitize.clean(' ') is ' ' not ''.

The same test on other people's machines works fine, which lead me down the track of maybe an incorrect gem being installed but I have checked and everyone is running the same gemfile.lock which is running Sanitize 2.0.3 which in turn is running Nokogiri 1.5.5

The version of Ruby (including patch) is the same at 1.9.3-p392, the only difference is that most people are running the tests on Ubuntu machines and I am running them on Mac OS X.

Other tests that use Sanitize pass fine, things like stripping out unwanted tags and allowing other tags, it is only whitespace that is falling over.

This led me to then think that maybe it was something to do with the encoding or the characters I am sending through, perhaps on my system the whitespace character isn't coming across as one that Sanitize can understand? I have no idea how to verify this.

Any help on what my next step should be would be greatly appreciated.

도움이 되었습니까?

해결책 2

Unfortunately the answer to this question isn't very helpful, but when I was reviewing this with another member of staff we decided that the test that needed this code wasn't a valid test, so we removed it.

다른 팁

Sanitize uses libxml2, is this library installed on your system ? You can install it with brew install libxml2.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top