spec/writer/fetcher/microdata/person_user_spec.rb in fetcher-microdata-0.0.11 vs spec/writer/fetcher/microdata/person_user_spec.rb in fetcher-microdata-0.0.12

- old
+ new

@@ -87,7 +87,67 @@ after :each do writer = Writer::Fetcher::Microdata::PersonUser.new @user_stub writer.hash["properties"].should include @properties_hash end end + end + + describe "#hash innecesary data" do + + it 'should not put dateRegistered on the data if data registered is nil' do + @properties_hash = { + "User#dateRegistered" => [nil] + } + aux_stub = stub "aux stub" + aux_stub.stub(:[]) do |symbol| + if symbol == :dateRegistered + nil + else + symbol.to_s + end + end + @nil_user_stub.should_receive(:_type).and_return "some type" + @nil_user_stub.should_receive(:attributes).and_return aux_stub + + writer = Writer::Fetcher::Microdata::PersonUser.new @nil_user_stub + writer.hash["properties"].should_not include @properties_hash + end + + it 'should not put description on the data if data registered is nil' do + @properties_hash = { + "description" => [nil] + } + aux_stub = stub "aux stub" + aux_stub.stub(:[]) do |symbol| + if symbol == :description + nil + else + symbol.to_s + end + end + @nil_user_stub.should_receive(:_type).and_return "some type" + @nil_user_stub.should_receive(:attributes).and_return aux_stub + + writer = Writer::Fetcher::Microdata::PersonUser.new @nil_user_stub + writer.hash["properties"].should_not include @properties_hash + end + + it 'should not put url on the data if data registered is nil' do + @properties_hash = { + "url" => [nil] + } + aux_stub = stub "aux stub" + aux_stub.stub(:[]) do |symbol| + if symbol == :url + nil + else + symbol.to_s + end + end + @nil_user_stub.should_receive(:_type).and_return "some type" + @nil_user_stub.should_receive(:attributes).and_return aux_stub + + writer = Writer::Fetcher::Microdata::PersonUser.new @nil_user_stub + writer.hash["properties"].should_not include @properties_hash + end end end \ No newline at end of file