spec/writer/fetcher/microdata/review_spec.rb in fetcher-microdata-0.0.9 vs spec/writer/fetcher/microdata/review_spec.rb in fetcher-microdata-0.0.10

- old
+ new

@@ -2,12 +2,13 @@ describe Writer::Fetcher::Microdata::Review 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) + @author_stub = stub 'author', :to => stub( :hash => "hi Im the author") + @viewer_stub = stub 'viewer', :to => stub( :hash => "hi Im the viewer") + @itemReviewed_stub = stub 'item review', :to => stub( :hash => "hi im the itemReviewed") end it 'should return a hash with the type' do final_hash = { "type" => [ @@ -33,33 +34,35 @@ ] } @schema_stub.should_receive(:attributes) .and_return :additionalType => "http://getfetcher.net/Item", :author => @author_stub, - :viewer => @viewer_stub + :viewer => @viewer_stub, + :itemReviewed => @itemReviewed_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, :viewer => @viewer_stub + .and_return :id => 234536234, :author => @author_stub, :viewer => @viewer_stub, + :itemReviewed => @itemReviewed_stub end it 'should include the itemReviewed' do @properties_hash = { "itemReviewed" => [ - "some body" + "hi im the itemReviewed" ] } @schema_stub.should_receive(:attributes) - .and_return :itemReviewed => "some body", :author => @author_stub, :viewer => @viewer_stub + .and_return :itemReviewed => @itemReviewed_stub, :author => @author_stub, :viewer => @viewer_stub end it 'should include the author' do @author = stub 'author' @author_writer = stub 'author writer' @@ -70,11 +73,12 @@ "hi Im the author" ] } @schema_stub.should_receive(:attributes) - .and_return :author => @author, :viewer => @viewer_stub + .and_return :author => @author, :viewer => @viewer_stub, + :itemReviewed => @itemReviewed_stub end it 'should include the viewer' do @viewer = stub 'viewer' @viewer_writer = stub 'viewer writer' @@ -85,22 +89,24 @@ "hi Im the viewer" ] } @schema_stub.should_receive(:attributes) - .and_return :viewer => @viewer, :author => @author_stub + .and_return :viewer => @viewer, :author => @author_stub, + :itemReviewed => @itemReviewed_stub end it 'should include the dateCreated' do @properties_hash = { "dateCreated" => [ 23456235 ] } @schema_stub.should_receive(:attributes) - .and_return :dateCreated => 23456235, :author => @author_stub, :viewer => @viewer_stub + .and_return :dateCreated => 23456235, :author => @author_stub, :viewer => @viewer_stub, + :itemReviewed => @itemReviewed_stub end it 'should include the provider' do @properties_hash = { "provider" => [ @@ -108,30 +114,32 @@ "fetcher" ] } @schema_stub.should_receive(:attributes) - .and_return :provider => ["twitter", "fetcher"], :author => @author_stub, :viewer => @viewer_stub + .and_return :provider => ["twitter", "fetcher"], :author => @author_stub, :viewer => @viewer_stub, + :itemReviewed => @itemReviewed_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, :viewer => @viewer_stub + .and_return :url => "http://myurl.info", :author => @author_stub, :viewer => @viewer_stub, + :itemReviewed => @itemReviewed_stub end it 'should include the original tweet' do @properties_hash = { "itemReviewed" => [ - "Im the original tweet that was retreeted" + "hi im the itemReviewed" ] } @schema_stub.should_receive(:attributes) - .and_return :itemReviewed => "Im the original tweet that was retreeted", :author => @author_stub, :viewer => @viewer_stub + .and_return :itemReviewed => @itemReviewed_stub, :author => @author_stub, :viewer => @viewer_stub end after :each do writer = Writer::Fetcher::Microdata::Review.new @schema_stub writer.hash["properties"].should include @properties_hash \ No newline at end of file