spec/writer/fetcher/microdata/twitter/article_small_spec.rb in fetcher-microdata-twitter-0.0.1 vs spec/writer/fetcher/microdata/twitter/article_small_spec.rb in fetcher-microdata-twitter-0.0.2

- old
+ new

@@ -3,10 +3,11 @@ describe Writer::Fetcher::Microdata::Twitter::ArticleSmall do describe '#hash' do before do @schema_stub = stub 'schema' @author_stub = stub 'author', :to => stub( :hash => nil) + @viewer_stub = stub 'viewer', :to => stub( :hash => nil) end it 'should return a hash with the type' do final_hash = { "type" => [ @@ -29,31 +30,36 @@ @properties_hash = { "additionalType" => [ "http://getfetcher.net/Item" ] } - @schema_stub.should_receive(:attributes).and_return :additionalType => "http://getfetcher.net/Item", :author => @author_stub + @schema_stub.should_receive(:attributes) + .and_return :additionalType => "http://getfetcher.net/Item", + :author => @author_stub, + :viewer => @viewer_stub end it 'should include the Item#id' do @properties_hash = { "Item#id" => [ 234536234 ] } - @schema_stub.should_receive(:attributes).and_return :id => 234536234, :author => @author_stub + @schema_stub.should_receive(:attributes) + .and_return :id => 234536234, :author => @author_stub, :viewer => @viewer_stub end it 'should include the articleBody' do @properties_hash = { "articleBody" => [ "some body" ] } - @schema_stub.should_receive(:attributes).and_return :articleBody => "some body", :author => @author_stub + @schema_stub.should_receive(:attributes) + .and_return :articleBody => "some body", :author => @author_stub, :viewer => @viewer_stub end it 'should include the author' do @author = stub 'author' @author_writer = stub 'author writer' @@ -63,41 +69,60 @@ "author" => [ "hi Im the author" ] } - @schema_stub.should_receive(:attributes).and_return :author => @author + @schema_stub.should_receive(:attributes) + .and_return :author => @author, :viewer => @viewer_stub end + it 'should include the viewer' do + @viewer = stub 'viewer' + @viewer_writer = stub 'viewer writer' + @viewer_writer.should_receive(:hash).and_return "hi Im the viewer" + @viewer.should_receive(:to).and_return @viewer_writer + @properties_hash = { + "Item#viewer" => [ + "hi Im the viewer" + ] + } + + @schema_stub.should_receive(:attributes) + .and_return :viewer => @viewer, :author => @author_stub + end + it 'should include the dateCreated' do @properties_hash = { "dateCreated" => [ 23456235 ] } - @schema_stub.should_receive(:attributes).and_return :dateCreated => 23456235, :author => @author_stub + @schema_stub.should_receive(:attributes) + .and_return :dateCreated => 23456235, :author => @author_stub, :viewer => @viewer_stub end it 'should include the provider' do @properties_hash = { "provider" => [ "twitter", "fetcher" ] } - @schema_stub.should_receive(:attributes).and_return :provider => ["twitter", "fetcher"], :author => @author_stub + @schema_stub.should_receive(:attributes) + .and_return :provider => ["twitter", "fetcher"], :author => @author_stub, :viewer => @viewer_stub end it 'should include the url' do @properties_hash = { "url" => [ "http://myurl.info" ] } - @schema_stub.should_receive(:attributes).and_return :url => "http://myurl.info", :author => @author_stub + @schema_stub.should_receive(:attributes) + .and_return :url => "http://myurl.info", :author => @author_stub, :viewer => @viewer_stub end after :each do writer = Writer::Fetcher::Microdata::Twitter::ArticleSmall.new @schema_stub writer.hash["properties"].should include @properties_hash \ No newline at end of file