spec/zemanta/enhancer_spec.rb in zemanta_client-0.0.5 vs spec/zemanta/enhancer_spec.rb in zemanta_client-0.0.6
- old
+ new
@@ -20,7 +20,31 @@
input = "I like Machu Pichu. Machu Pichu? Yeah, Machu Pichu"
output = Zemanta::Enhancer.new(input, no_duplicates: true).enhance
output.scan('<a').should have(1).elements
end
end
+
+ describe "skip option" do
+ it "skips links whose URL matches a user-provided regexp" do
+ stub_zemanta_enhancer!
+ output = Zemanta::Enhancer.new(input, skip: /machu_picchu/).enhance
+ output.scan('<a').should have(1).elements
+ end
+
+ it "doesn't affect the links that don't match thr user-provided regexp" do
+ stub_zemanta_enhancer!
+ output = Zemanta::Enhancer.new(input, skip: /macchu_picchu/).enhance
+ output.scan('<a').should have(2).elements
+ end
+ end
+
+ describe "strip_query_string" do
+ it "strips the query string from the suggested urls" do
+ text = "Hello foo bar"
+ suggestions = [{ word: 'foo', link: "http://bar.com/foo?bar=123" }]
+ Zemanta::Enhancer.any_instance.stub(words_to_anchor: suggestions)
+ output = Zemanta::Enhancer.new(text, strip_query_string: true).enhance
+ output.should == "Hello <a href=http://bar.com/foo>foo</a> bar"
+ end
+ end
end
end