Sha256: ea022f9872dacae797bb5664a9c25c1a396e052c7f368890e549fa4a606e4e79

Contents?: true

Size: 958 Bytes

Versions: 3

Compression:

Stored size: 958 Bytes

Contents

$:.unshift(File.dirname(__FILE__))
require 'spec_helper'

describe 'hashtag method' do
  include TwhereHelperMethods

  it 'should find hashtags' do
    # no hashtags
    hashtag('').should == nil
    hashtag('a').should == nil
    hashtag('#').should == nil
    hashtag('##').should == nil

    # lowercase
    hashtag('#a').should == 'a'
    hashtag('#aa').should == 'aa'

    # uppercase
    hashtag('#A').should == 'A'
    hashtag('#AA').should == 'AA'

    # digits
    hashtag('#1').should == '1'
    hashtag('#11').should == '11'

    # TODO: unicode?

    # mixed character classes
    hashtag('#aA').should == 'aA'
    hashtag('#Aa').should == 'Aa'
    hashtag('#a1').should == 'a1'
    hashtag('#1a').should == '1a'
    hashtag('#A1').should == 'A1'
    hashtag('#1A').should == '1A'

    # in text
    hashtag('a #b').should == 'b'
    hashtag('#a b').should == 'a'

    # multiple hashtags, use first
    hashtag('#a #b').should == 'a'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sarnesjo-twhere-0.0.10 spec/hashtag_spec.rb
sarnesjo-twhere-0.0.8 spec/hashtag_spec.rb
sarnesjo-twhere-0.0.9 spec/hashtag_spec.rb