spec/unit/crawl_segment_spec.rb in elasticrawl-1.0.0 vs spec/unit/crawl_segment_spec.rb in elasticrawl-1.1.0

- old
+ new

@@ -4,24 +4,33 @@ it { should belong_to(:crawl) } it { should have_many(:job_steps) } it { should have_db_column(:segment_name).of_type(:string) } it { should have_db_column(:segment_s3_uri).of_type(:string) } it { should have_db_column(:parse_time).of_type(:datetime) } + it { should have_db_column(:file_count).of_type(:integer) } - describe '#initialize' do - let(:crawl) { Elasticrawl::Crawl.create(:crawl_name => 'CC-MAIN-2013-20') } - subject { crawl.crawl_segments[0]} - - before do - crawl.create_segments - end - + describe '.create_segment' do + let(:crawl) { Elasticrawl::Crawl.create(:crawl_name => 'CC-MAIN-2014-49') } + let(:segment_name) { '1416400372202.67' } + let(:file_count) { 3 } + let(:segment_desc) { 'Segment: 1416400372202.67 Files: 3' } + subject { Elasticrawl::CrawlSegment.create_segment(crawl, + segment_name, + file_count) } it 'should have a segment name' do - expect(subject.segment_name).to eq '1368696381249' + expect(subject.segment_name).to eq segment_name end it 'should have an s3 uri' do expect(subject.segment_s3_uri).to eq \ - 's3://aws-publicdatasets/common-crawl/crawl-data/CC-MAIN-2013-20/segments/1368696381249/' + "s3://aws-publicdatasets/common-crawl/crawl-data/#{crawl.crawl_name}/segments/#{segment_name}/" + end + + it 'should have a file count' do + expect(subject.file_count).to eq file_count + end + + it 'should have a segment description' do + expect(subject.segment_desc).to eq segment_desc end end end