diff --git a/spec/shared_behaviors/account_deletion.rb b/spec/shared_behaviors/account_deletion.rb
index d685432e6..50ecf251e 100644
--- a/spec/shared_behaviors/account_deletion.rb
+++ b/spec/shared_behaviors/account_deletion.rb
@@ -4,39 +4,36 @@
require 'spec_helper'
-describe 'deleteing your account' do
- shared_examples_for 'it removes the person associations' do
- it "removes all of the person's posts" do
- Post.where(:author_id => @person.id).count.should == 0
- end
+shared_examples_for 'it removes the person associations' do
+ it "removes all of the person's posts" do
+ Post.where(:author_id => @person.id).count.should == 0
+ end
- it 'deletes all person contacts' do
- Contact.where(:person_id => @person.id).should be_empty
- end
+ it 'deletes all person contacts' do
+ Contact.where(:person_id => @person.id).should be_empty
+ end
- it 'deletes all mentions' do
- @person.mentions.should be_empty
- end
+ it 'deletes all mentions' do
+ @person.mentions.should be_empty
+ end
- it "removes all of the person's photos" do
- Photo.where(:author_id => @person.id).should be_empty
- end
+ it "removes all of the person's photos" do
+ Photo.where(:author_id => @person.id).should be_empty
+ end
- it 'sets the person object as closed and the profile is cleared' do
- @person.reload.closed_account.should be_true
+ it 'sets the person object as closed and the profile is cleared' do
+ @person.reload.closed_account.should be_true
- @person.profile.reload.first_name.should be_blank
- @person.profile.reload.last_name.should be_blank
- end
+ @person.profile.reload.first_name.should be_blank
+ @person.profile.reload.last_name.should be_blank
+ end
- it 'deletes only the converersation visibility for the deleted user' do
- ConversationVisibility.where(:person_id => alice.person.id).should_not be_empty
- ConversationVisibility.where(:person_id => @person.id).should be_empty
- end
+ it 'deletes only the converersation visibility for the deleted user' do
+ ConversationVisibility.where(:person_id => alice.person.id).should_not be_empty
+ ConversationVisibility.where(:person_id => @person.id).should be_empty
+ end
- it "deletes the share visibilities on the person's posts" do
- ShareVisibility.for_contacts_of_a_person(@person).should be_empty
- end
+ it "deletes the share visibilities on the person's posts" do
+ ShareVisibility.for_contacts_of_a_person(@person).should be_empty
end
end
-
diff --git a/spec/shared_behaviors/relayable.rb b/spec/shared_behaviors/relayable.rb
index ed753e003..1b3dc9766 100644
--- a/spec/shared_behaviors/relayable.rb
+++ b/spec/shared_behaviors/relayable.rb
@@ -4,127 +4,125 @@
require 'spec_helper'
-describe Diaspora::Relayable do
- shared_examples_for "it is relayable" do
+shared_examples_for "it is relayable" do
- describe 'interacted_at' do
- it 'sets the interacted at of the parent to the created at of the relayable post' do
- Timecop.freeze Time.now do
+ describe 'interacted_at' do
+ it 'sets the interacted at of the parent to the created at of the relayable post' do
+ Timecop.freeze Time.now do
+ relayable = build_object
+ relayable.save
+ if relayable.parent.respond_to?(:interacted_at) #I'm sorry.
+ relayable.parent.interacted_at.to_i.should == relayable.created_at.to_i
+ end
+ end
+ end
+ end
+
+ describe 'validations' do
+ describe 'on :author_id' do
+ context "the author is on the parent object author's ignore list when object is created" do
+ before do
+ bob.blocks.create(:person => alice.person)
+ @relayable = build_object
+ end
+
+ it "is invalid" do
+ @relayable.should_not be_valid
+ @relayable.should have(1).error_on(:author_id)
+ end
+
+ it "sends a retraction for the object" do
+ pending 'need to figure out how to test this'
+ RelayableRetraction.should_receive(:build)
+ Postzord::Dispatcher.should_receive(:build)
+ @relayable.valid?
+ end
+
+ it "works if the object has no parent" do # This can happen if we get a comment for a post that's been deleted
+ @relayable.parent = nil
+ expect { @relayable.valid? }.to_not raise_exception
+ end
+ end
+
+ context "the author is added to the parent object author's ignore list later" do
+ it "is valid" do
relayable = build_object
- relayable.save
- if relayable.parent.respond_to?(:interacted_at) #I'm sorry.
- relayable.parent.interacted_at.to_i.should == relayable.created_at.to_i
- end
+ relayable.save!
+ bob.blocks.create(:person => alice.person)
+ relayable.should be_valid
end
end
end
+ end
- describe 'validations' do
- describe 'on :author_id' do
- context "the author is on the parent object author's ignore list when object is created" do
- before do
- bob.blocks.create(:person => alice.person)
- @relayable = build_object
- end
+ context 'encryption' do
+ describe '#parent_author_signature' do
+ it 'should sign the object if the user is the post author' do
+ @object_by_parent_author.verify_parent_author_signature.should be_true
+ end
- it "is invalid" do
- @relayable.should_not be_valid
- @relayable.should have(1).error_on(:author_id)
- end
+ it 'does not sign as the parent author is not parent' do
+ @object_by_recipient.author_signature = @object_by_recipient.send(:sign_with_key, @local_leia.encryption_key)
+ @object_by_recipient.verify_parent_author_signature.should be_false
+ end
- it "sends a retraction for the object" do
- pending 'need to figure out how to test this'
- RelayableRetraction.should_receive(:build)
- Postzord::Dispatcher.should_receive(:build)
- @relayable.valid?
- end
-
- it "works if the object has no parent" do # This can happen if we get a comment for a post that's been deleted
- @relayable.parent = nil
- expect { @relayable.valid? }.to_not raise_exception
- end
- end
-
- context "the author is added to the parent object author's ignore list later" do
- it "is valid" do
- relayable = build_object
- relayable.save!
- bob.blocks.create(:person => alice.person)
- relayable.should be_valid
- end
- end
+ it 'should verify a object made on a remote post by a different contact' do
+ @object_by_recipient.author_signature = @object_by_recipient.send(:sign_with_key, @local_leia.encryption_key)
+ @object_by_recipient.parent_author_signature = @object_by_recipient.send(:sign_with_key, @local_luke.encryption_key)
+ @object_by_recipient.verify_parent_author_signature.should be_true
end
end
- context 'encryption' do
- describe '#parent_author_signature' do
- it 'should sign the object if the user is the post author' do
- @object_by_parent_author.verify_parent_author_signature.should be_true
- end
+ describe '#author_signature' do
+ it 'should sign as the object author' do
+ @object_on_remote_parent.signature_valid?.should be_true
+ @object_by_parent_author.signature_valid?.should be_true
+ @object_by_recipient.signature_valid?.should be_true
+ end
+ end
+ end
- it 'does not sign as the parent author is not parent' do
- @object_by_recipient.author_signature = @object_by_recipient.send(:sign_with_key, @local_leia.encryption_key)
- @object_by_recipient.verify_parent_author_signature.should be_false
- end
-
- it 'should verify a object made on a remote post by a different contact' do
- @object_by_recipient.author_signature = @object_by_recipient.send(:sign_with_key, @local_leia.encryption_key)
- @object_by_recipient.parent_author_signature = @object_by_recipient.send(:sign_with_key, @local_luke.encryption_key)
- @object_by_recipient.verify_parent_author_signature.should be_true
- end
+ context 'propagation' do
+ describe '#receive' do
+ it 'does not overwrite a object that is already in the db' do
+ expect {
+ @dup_object_by_parent_author.receive(@local_leia, @local_luke.person)
+ }.to_not change { @dup_object_by_parent_author.class.count }
end
- describe '#author_signature' do
- it 'should sign as the object author' do
- @object_on_remote_parent.signature_valid?.should be_true
- @object_by_parent_author.signature_valid?.should be_true
- @object_by_recipient.signature_valid?.should be_true
- end
+ it 'does not process if post_creator_signature is invalid' do
+ @object_by_parent_author.delete # remove object from db so we set a creator sig
+ @dup_object_by_parent_author.parent_author_signature = "dsfadsfdsa"
+ @dup_object_by_parent_author.receive(@local_leia, @local_luke.person).should == nil
+ end
+
+ it 'signs when the person receiving is the parent author' do
+ @object_by_recipient.save
+ @object_by_recipient.receive(@local_luke, @local_leia.person)
+ @object_by_recipient.reload.parent_author_signature.should_not be_blank
+ end
+
+ it 'dispatches when the person receiving is the parent author' do
+ p = Postzord::Dispatcher.build(@local_luke, @object_by_recipient)
+ p.should_receive(:post)
+ p.class.stub(:new).and_return(p)
+ @object_by_recipient.receive(@local_luke, @local_leia.person)
+ end
+
+ it 'calls after_receive callback' do
+ @object_by_recipient.should_receive(:after_receive)
+ @object_by_recipient.class.stub(:where).and_return([@object_by_recipient])
+ @object_by_recipient.receive(@local_luke, @local_leia.person)
end
end
- context 'propagation' do
- describe '#receive' do
- it 'does not overwrite a object that is already in the db' do
- expect {
- @dup_object_by_parent_author.receive(@local_leia, @local_luke.person)
- }.to_not change { @dup_object_by_parent_author.class.count }
- end
-
- it 'does not process if post_creator_signature is invalid' do
- @object_by_parent_author.delete # remove object from db so we set a creator sig
- @dup_object_by_parent_author.parent_author_signature = "dsfadsfdsa"
- @dup_object_by_parent_author.receive(@local_leia, @local_luke.person).should == nil
- end
-
- it 'signs when the person receiving is the parent author' do
- @object_by_recipient.save
- @object_by_recipient.receive(@local_luke, @local_leia.person)
- @object_by_recipient.reload.parent_author_signature.should_not be_blank
- end
-
- it 'dispatches when the person receiving is the parent author' do
- p = Postzord::Dispatcher.build(@local_luke, @object_by_recipient)
- p.should_receive(:post)
- p.class.stub(:new).and_return(p)
- @object_by_recipient.receive(@local_luke, @local_leia.person)
- end
-
- it 'calls after_receive callback' do
- @object_by_recipient.should_receive(:after_receive)
- @object_by_recipient.class.stub(:where).and_return([@object_by_recipient])
- @object_by_recipient.receive(@local_luke, @local_leia.person)
- end
+ describe '#subscribers' do
+ it 'returns the posts original audience, if the post is owned by the user' do
+ @object_by_parent_author.subscribers(@local_luke).map(&:id).should =~ [@local_leia.person, @remote_raphael].map(&:id)
end
- describe '#subscribers' do
- it 'returns the posts original audience, if the post is owned by the user' do
- @object_by_parent_author.subscribers(@local_luke).map(&:id).should =~ [@local_leia.person, @remote_raphael].map(&:id)
- end
-
- it 'returns the owner of the original post, if the user owns the object' do
- @object_by_recipient.subscribers(@local_leia).map(&:id).should =~ [@local_luke.person].map(&:id)
- end
+ it 'returns the owner of the original post, if the user owns the object' do
+ @object_by_recipient.subscribers(@local_leia).map(&:id).should =~ [@local_luke.person].map(&:id)
end
end
end
diff --git a/spec/shared_behaviors/stream.rb b/spec/shared_behaviors/stream.rb
index 9ff20b395..9207be34e 100644
--- a/spec/shared_behaviors/stream.rb
+++ b/spec/shared_behaviors/stream.rb
@@ -1,45 +1,43 @@
require 'spec_helper'
-describe 'Streams' do
- shared_examples_for 'it is a stream' do
- context 'required methods for display' do
- it '#title' do
- @stream.title.should_not be_nil
- end
+shared_examples_for 'it is a stream' do
+ context 'required methods for display' do
+ it '#title' do
+ @stream.title.should_not be_nil
+ end
- it '#posts' do
- @stream.posts.should_not be_nil
- end
+ it '#posts' do
+ @stream.posts.should_not be_nil
+ end
- it '#people' do
- @stream.people.should_not be_nil
- end
+ it '#people' do
+ @stream.people.should_not be_nil
+ end
- it '#publisher_opts' do
- @stream.send(:publisher_opts).should_not be_nil
- end
+ it '#publisher_opts' do
+ @stream.send(:publisher_opts).should_not be_nil
+ end
- it 'has a #contacts title' do
- @stream.contacts_title.should_not be_nil
- end
+ it 'has a #contacts title' do
+ @stream.contacts_title.should_not be_nil
+ end
- it 'has a contacts link' do
- @stream.contacts_link.should_not be_nil
- end
+ it 'has a contacts link' do
+ @stream.contacts_link.should_not be_nil
+ end
- it 'should make the stream a time object' do
- @stream.max_time = 123
- @stream.max_time.should be_a(Time)
- end
+ it 'should make the stream a time object' do
+ @stream.max_time = 123
+ @stream.max_time.should be_a(Time)
+ end
- it 'should always have an order (default created_at)' do
- @stream.order=nil
- @stream.order.should_not be_nil
- end
+ it 'should always have an order (default created_at)' do
+ @stream.order=nil
+ @stream.order.should_not be_nil
+ end
- it 'initializes a publisher' do
- @stream.publisher.should be_a(Publisher)
- end
+ it 'initializes a publisher' do
+ @stream.publisher.should be_a(Publisher)
end
end
end
diff --git a/spec/shared_behaviors/taggable.rb b/spec/shared_behaviors/taggable.rb
index 1d7efcbc5..339556bf2 100644
--- a/spec/shared_behaviors/taggable.rb
+++ b/spec/shared_behaviors/taggable.rb
@@ -5,165 +5,162 @@
require 'spec_helper'
-describe Diaspora::Taggable do
- shared_examples_for "it is taggable" do
- include ActionView::Helpers::UrlHelper
+shared_examples_for "it is taggable" do
+ include ActionView::Helpers::UrlHelper
- def tag_link(s)
- link_to "##{s}", "/tags/#{s}", :class => 'tag'
+ def tag_link(s)
+ link_to "##{s}", "/tags/#{s}", :class => 'tag'
+ end
+
+ describe '.format_tags' do
+ before do
+ @str = '#what #hey #vöglein'
+ @object.send(@object.class.field_with_tags_setter, @str)
+ @object.build_tags
+ @object.save!
end
- describe '.format_tags' do
- before do
- @str = '#what #hey #vöglein'
- @object.send(@object.class.field_with_tags_setter, @str)
- @object.build_tags
- @object.save!
- end
-
- it "supports non-ascii characters" do
- @object.tags(true).map(&:name).should include('vöglein')
- end
-
- it 'links each tag' do
- formatted_string = Diaspora::Taggable.format_tags(@str)
- formatted_string.should include(tag_link('what'))
- formatted_string.should include(tag_link('hey'))
- formatted_string.should include(tag_link('vöglein'))
- end
-
- it 'responds to plain_text' do
- Diaspora::Taggable.format_tags(@str, :plain_text => true).should == @str
- end
-
- it "doesn't mangle text when tags are involved" do
- expected = {
- nil => '',
- '' => '',
- 'abc' => 'abc',
- 'a #b c' => "a #{tag_link('b')} c",
- '#' => '#',
- '##' => '##',
- '###' => '###',
- '#a' => tag_link('a'),
- '#foobar' => tag_link('foobar'),
- '#foocar
' => "#{tag_link('foocar')}<br>",
- '#fooo@oo' => "#{tag_link('fooo')}@oo",
- '#num3ric hash tags' => "#{tag_link('num3ric')} hash tags",
- '#12345 tag' => "#{tag_link('12345')} tag",
- '#12cde tag' => "#{tag_link('12cde')} tag",
- '#abc45 tag' => "#{tag_link('abc45')} tag",
- '#<3' => %{#<3},
- 'i #<3' => %{i #<3},
- 'i #<3 you' => %{i #<3 you},
- '#<4' => '#<4',
- 'test#foo test' => 'test#foo test',
- 'test.#joo bar' => 'test.#joo bar',
- 'test #foodar test' => "test #{tag_link('foodar')} test",
- 'test #foofar
test' => "test #{tag_link('foofar')}<br> test",
- 'test #gooo@oo test' => "test #{tag_link('gooo')}@oo test",
- 'test #foo-test test' => "test #{tag_link('foo-test')} test",
- 'test #hoo' => "test #{tag_link('hoo')}",
- 'test #two_word tags' => "test #{tag_link('two_word')} tags",
- 'test #three_word_tags' => "test #{tag_link('three_word_tags')}",
- '#terminal_underscore_' => tag_link('terminal_underscore_'),
- '#terminalunderscore_' => tag_link('terminalunderscore_'),
- '#_initialunderscore' => tag_link('_initialunderscore'),
- '#_initial_underscore' => tag_link('_initial_underscore'),
- '#terminalhyphen-' => tag_link('terminalhyphen-'),
- '#terminal-hyphen-' => tag_link('terminal-hyphen-'),
- '#terminalhyphen- tag' => "#{tag_link('terminalhyphen-')} tag",
- '#-initialhyphen' => tag_link('-initialhyphen'),
- '#-initialhyphen tag' => "#{tag_link('-initialhyphen')} tag",
- '#-initial-hyphen' => tag_link('-initial-hyphen'),
- }
-
- expected.each do |input,output|
- Diaspora::Taggable.format_tags(input).should == output
- end
- end
+ it "supports non-ascii characters" do
+ @object.tags(true).map(&:name).should include('vöglein')
end
- describe '#build_tags' do
- it 'builds the tags' do
- @object.send(@object.class.field_with_tags_setter, '#what')
- @object.build_tags
- @object.tag_list.should == ['what']
- lambda {
- @object.save
- }.should change{@object.tags.count}.by(1)
- end
+ it 'links each tag' do
+ formatted_string = Diaspora::Taggable.format_tags(@str)
+ formatted_string.should include(tag_link('what'))
+ formatted_string.should include(tag_link('hey'))
+ formatted_string.should include(tag_link('vöglein'))
end
- describe '#tag_strings' do
- it 'returns a string for every #thing' do
- str = '#what #hey #that"smybike. #@hey ##boo # #THATWASMYBIKE #vöglein #hey#there #135440we #abc/23 ### #h!gh #ok? #see: #re:publica'
- arr = ['what', 'hey', 'that', 'THATWASMYBIKE', 'vöglein', '135440we', 'abc', 'h', 'ok', 'see', 're']
+ it 'responds to plain_text' do
+ Diaspora::Taggable.format_tags(@str, :plain_text => true).should == @str
+ end
- @object.send(@object.class.field_with_tags_setter, str)
- @object.tag_strings.should =~ arr
- end
+ it "doesn't mangle text when tags are involved" do
+ expected = {
+ nil => '',
+ '' => '',
+ 'abc' => 'abc',
+ 'a #b c' => "a #{tag_link('b')} c",
+ '#' => '#',
+ '##' => '##',
+ '###' => '###',
+ '#a' => tag_link('a'),
+ '#foobar' => tag_link('foobar'),
+ '#foocar
' => "#{tag_link('foocar')}<br>",
+ '#fooo@oo' => "#{tag_link('fooo')}@oo",
+ '#num3ric hash tags' => "#{tag_link('num3ric')} hash tags",
+ '#12345 tag' => "#{tag_link('12345')} tag",
+ '#12cde tag' => "#{tag_link('12cde')} tag",
+ '#abc45 tag' => "#{tag_link('abc45')} tag",
+ '#<3' => %{#<3},
+ 'i #<3' => %{i #<3},
+ 'i #<3 you' => %{i #<3 you},
+ '#<4' => '#<4',
+ 'test#foo test' => 'test#foo test',
+ 'test.#joo bar' => 'test.#joo bar',
+ 'test #foodar test' => "test #{tag_link('foodar')} test",
+ 'test #foofar
test' => "test #{tag_link('foofar')}<br> test",
+ 'test #gooo@oo test' => "test #{tag_link('gooo')}@oo test",
+ 'test #foo-test test' => "test #{tag_link('foo-test')} test",
+ 'test #hoo' => "test #{tag_link('hoo')}",
+ 'test #two_word tags' => "test #{tag_link('two_word')} tags",
+ 'test #three_word_tags' => "test #{tag_link('three_word_tags')}",
+ '#terminal_underscore_' => tag_link('terminal_underscore_'),
+ '#terminalunderscore_' => tag_link('terminalunderscore_'),
+ '#_initialunderscore' => tag_link('_initialunderscore'),
+ '#_initial_underscore' => tag_link('_initial_underscore'),
+ '#terminalhyphen-' => tag_link('terminalhyphen-'),
+ '#terminal-hyphen-' => tag_link('terminal-hyphen-'),
+ '#terminalhyphen- tag' => "#{tag_link('terminalhyphen-')} tag",
+ '#-initialhyphen' => tag_link('-initialhyphen'),
+ '#-initialhyphen tag' => "#{tag_link('-initialhyphen')} tag",
+ '#-initial-hyphen' => tag_link('-initial-hyphen'),
+ }
- it 'extracts tags despite surrounding text' do
- expected = {
- '' => nil,
- '#' => nil,
- '##' => nil,
- '###' => nil,
- '#a' => 'a',
- '#foobar' => 'foobar',
- '#foocar
' => 'foocar',
- '#fooo@oo' => 'fooo',
- '#num3ric hash tags' => 'num3ric',
- '#12345 tag' => '12345',
- '#12cde tag' => '12cde',
- '#abc45 tag' => 'abc45',
- '#<3' => '<3',
- '#<4' => nil,
- 'test#foo test' => nil,
- 'test.#joo bar' => nil,
- 'test #foodar test' => 'foodar',
- 'test #foofar
test' => 'foofar',
- 'test #gooo@oo test' => 'gooo',
- 'test #<3 test' => '<3',
- 'test #foo-test test' => 'foo-test',
- 'test #hoo' => 'hoo',
- 'test #two_word tags' => 'two_word',
- 'test #three_word_tags' => 'three_word_tags',
- '#terminal_underscore_' => 'terminal_underscore_',
- '#terminalunderscore_' => 'terminalunderscore_',
- '#_initialunderscore' => '_initialunderscore',
- '#_initial_underscore' => '_initial_underscore',
- '#terminalhyphen-' => 'terminalhyphen-',
- '#terminal-hyphen-' => 'terminal-hyphen-',
- '#terminalhyphen- tag' => 'terminalhyphen-',
- '#-initialhyphen' => '-initialhyphen',
- '#-initialhyphen tag' => '-initialhyphen',
- '#-initial-hyphen' => '-initial-hyphen',
- }
-
- expected.each do |text,hashtag|
- @object.send @object.class.field_with_tags_setter, text
- @object.tag_strings.should == [hashtag].compact
- end
- end
-
- it 'returns no duplicates' do
- str = '#what #what #what #whaaaaaaaaaat'
- arr = ['what','whaaaaaaaaaat']
-
- @object.send(@object.class.field_with_tags_setter, str)
- @object.tag_strings.should =~ arr
- end
-
- it 'is case insensitive' do
- str = '#what #wHaT #WHAT'
- arr = ['what']
-
- @object.send(@object.class.field_with_tags_setter, str)
- @object.tag_strings.should =~ arr
+ expected.each do |input,output|
+ Diaspora::Taggable.format_tags(input).should == output
end
end
end
-end
+ describe '#build_tags' do
+ it 'builds the tags' do
+ @object.send(@object.class.field_with_tags_setter, '#what')
+ @object.build_tags
+ @object.tag_list.should == ['what']
+ lambda {
+ @object.save
+ }.should change{@object.tags.count}.by(1)
+ end
+ end
+
+ describe '#tag_strings' do
+ it 'returns a string for every #thing' do
+ str = '#what #hey #that"smybike. #@hey ##boo # #THATWASMYBIKE #vöglein #hey#there #135440we #abc/23 ### #h!gh #ok? #see: #re:publica'
+ arr = ['what', 'hey', 'that', 'THATWASMYBIKE', 'vöglein', '135440we', 'abc', 'h', 'ok', 'see', 're']
+
+ @object.send(@object.class.field_with_tags_setter, str)
+ @object.tag_strings.should =~ arr
+ end
+
+ it 'extracts tags despite surrounding text' do
+ expected = {
+ '' => nil,
+ '#' => nil,
+ '##' => nil,
+ '###' => nil,
+ '#a' => 'a',
+ '#foobar' => 'foobar',
+ '#foocar
' => 'foocar',
+ '#fooo@oo' => 'fooo',
+ '#num3ric hash tags' => 'num3ric',
+ '#12345 tag' => '12345',
+ '#12cde tag' => '12cde',
+ '#abc45 tag' => 'abc45',
+ '#<3' => '<3',
+ '#<4' => nil,
+ 'test#foo test' => nil,
+ 'test.#joo bar' => nil,
+ 'test #foodar test' => 'foodar',
+ 'test #foofar
test' => 'foofar',
+ 'test #gooo@oo test' => 'gooo',
+ 'test #<3 test' => '<3',
+ 'test #foo-test test' => 'foo-test',
+ 'test #hoo' => 'hoo',
+ 'test #two_word tags' => 'two_word',
+ 'test #three_word_tags' => 'three_word_tags',
+ '#terminal_underscore_' => 'terminal_underscore_',
+ '#terminalunderscore_' => 'terminalunderscore_',
+ '#_initialunderscore' => '_initialunderscore',
+ '#_initial_underscore' => '_initial_underscore',
+ '#terminalhyphen-' => 'terminalhyphen-',
+ '#terminal-hyphen-' => 'terminal-hyphen-',
+ '#terminalhyphen- tag' => 'terminalhyphen-',
+ '#-initialhyphen' => '-initialhyphen',
+ '#-initialhyphen tag' => '-initialhyphen',
+ '#-initial-hyphen' => '-initial-hyphen',
+ }
+
+ expected.each do |text,hashtag|
+ @object.send @object.class.field_with_tags_setter, text
+ @object.tag_strings.should == [hashtag].compact
+ end
+ end
+
+ it 'returns no duplicates' do
+ str = '#what #what #what #whaaaaaaaaaat'
+ arr = ['what','whaaaaaaaaaat']
+
+ @object.send(@object.class.field_with_tags_setter, str)
+ @object.tag_strings.should =~ arr
+ end
+
+ it 'is case insensitive' do
+ str = '#what #wHaT #WHAT'
+ arr = ['what']
+
+ @object.send(@object.class.field_with_tags_setter, str)
+ @object.tag_strings.should =~ arr
+ end
+ end
+end