You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
743 B

  1. require 'rails_helper'
  2. RSpec.describe Tag, type: :model do
  3. describe 'HASHTAG_RE' do
  4. subject { Tag::HASHTAG_RE }
  5. it 'does not match URLs with anchors with non-hashtag characters' do
  6. expect(subject.match('Check this out https://medium.com/@alice/some-article#.abcdef123')).to be_nil
  7. end
  8. it 'does not match URLs with hashtag-like anchors' do
  9. expect(subject.match('https://en.wikipedia.org/wiki/Ghostbusters_(song)#Lawsuit')).to be_nil
  10. end
  11. end
  12. describe '.search_for' do
  13. it 'finds tag records with matching names' do
  14. tag = Fabricate(:tag, name: "match")
  15. _miss_tag = Fabricate(:tag, name: "miss")
  16. results = Tag.search_for("match")
  17. expect(results).to eq [tag]
  18. end
  19. end
  20. end