about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-04-25 22:03:51 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-04-25 15:03:51 +0200
commit3ea5b948a4cee9ea5a1e229f567974c323947ef5 (patch)
treee206923c459c98c6f4d9c1862bd867e4bfaea031 /spec
parent164bad171f8ebfc5fb240f9c8369df34a506a0df (diff)
Decodes URL containing IDN (#2436)
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/formatter_spec.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/lib/formatter_spec.rb b/spec/lib/formatter_spec.rb
index b70231d26..b762907b2 100644
--- a/spec/lib/formatter_spec.rb
+++ b/spec/lib/formatter_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe Formatter do
     end
 
     it 'contains a link' do
-      expect(subject).to match('<a href="http://google.com" rel="nofollow noopener" target="_blank"><span class="invisible">http://</span><span class="">google.com</span><span class="invisible"></span></a>')
+      expect(subject).to match('<a href="http://google.com/" rel="nofollow noopener" target="_blank"><span class="invisible">http://</span><span class="">google.com/</span><span class="invisible"></span></a>')
     end
 
     context 'matches a stand-alone medium URL' do
@@ -31,7 +31,18 @@ RSpec.describe Formatter do
     context 'matches a stand-alone google URL' do
       let(:local_text) { 'http://google.com' }
       it 'has valid url' do
-        expect(subject).to include('href="http://google.com"')
+        expect(subject).to include('href="http://google.com/"')
+      end
+    end
+
+    context 'matches a stand-alone IDN URL' do
+      let(:local_text) { 'https://nic.みんな/' }
+      it 'has valid url' do
+        expect(subject).to include('href="https://nic.xn--q9jyb4c/"')
+      end
+
+      it 'has display url' do
+        expect(subject).to include('<span class="">nic.みんな/</span>')
       end
     end
 
@@ -51,21 +62,21 @@ RSpec.describe Formatter do
     context 'matches a URL without exclamation point' do
       let(:local_text) { 'http://www.google.com!' }
       it 'has valid url' do
-        expect(subject).to include('href="http://www.google.com"')
+        expect(subject).to include('href="http://www.google.com/"')
       end
     end
 
     context 'matches a URL without single quote' do
       let(:local_text) { "http://www.google.com'" }
       it 'has valid url' do
-        expect(subject).to include('href="http://www.google.com"')
+        expect(subject).to include('href="http://www.google.com/"')
       end
     end
 
     context 'matches a URL without angle brackets' do
       let(:local_text) { 'http://www.google.com>' }
       it 'has valid url' do
-        expect(subject).to include('href="http://www.google.com"')
+        expect(subject).to include('href="http://www.google.com/"')
       end
     end