spec/processor_spec.rb in pupa-0.0.7 vs spec/processor_spec.rb in pupa-0.0.8

- old
+ new

@@ -29,10 +29,14 @@ let :processor do PersonProcessor.new('/tmp', level: 'WARN', logdev: io) end + let :novalidate do + PersonProcessor.new('/tmp', level: 'WARN', logdev: io, validate: false) + end + describe '#get' do it 'should send a GET request' do processor.get('http://httpbin.org/get', 'foo=bar')['args'].should == {'foo' => 'bar'} end @@ -49,11 +53,11 @@ it 'should automatically parse the response' do processor.post('http://httpbin.org/post').should be_a(Hash) end end - describe '#add_scraping_task' do + describe '.add_scraping_task' do it 'should add a scraping task and define a lazy method' do PersonProcessor.tasks.should == [:people] processor.should respond_to(:people) end end @@ -62,13 +66,13 @@ let :path do path = "/tmp/person_#{processor.person._id}.json" end it 'should not overwrite an existing file' do - FileUtils.touch(path) + File.open(path, 'w') {} expect{processor.dump_scraped_objects(:people)}.to raise_error(Pupa::Errors::DuplicateObjectIdError) - FileUtils.rm(path) + File.delete(path) end it 'should dump a JSON document' do processor.dump_scraped_objects(:people) File.exist?(path).should == true @@ -77,9 +81,15 @@ it 'should validate the object' do processor.make_person_invalid processor.dump_scraped_objects(:people) io.string.should match('http://popoloproject.com/schemas/person.json') + end + + it 'should not validate the object' do + novalidate.make_person_invalid + novalidate.dump_scraped_objects(:people) + io.string.should_not match('http://popoloproject.com/schemas/person.json') end end describe '#import' do before :each do