Sha256: 1a7b2a45ff5075e0ee14bdaf1f32545a9caaf24c1f7ef46ee2bb736f203557b4

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'
require "scrapers/sinfest"

module Scrapers

  describe Sinfest do
    it{should respond_to :scrape}
    context "scraping" do
      before(:all) do
        @comic = VCR.use_cassette('sinfest') do
          Scrapers::Sinfest.scrape
        end
      end

      it "retrieves a comic" do
        @comic.should_not be_nil
      end
      it "should be a Hash" do
        @comic.should be_a(Hash)
      end
      %w{title url pubdate img_src}.map(&:to_sym).each do |key|
        it "should have key #{key}" do
          @comic.should have_key(key)
        end
      end
      context "title" do
        it{@comic[:title].should_not be_empty}
        it{@comic[:title].should match /Nails/}
      end
      context "url" do
        it{@comic[:url].should_not be_empty}
        it{@comic[:url].should match /http:\/\/sinfest.net/}
      end
      context "pubdate" do
        it{@comic[:pubdate].should_not be_empty}
        it{Date.parse(@comic[:pubdate]).should be_a(Date)}
      end
      context "img_src" do
        it{@comic[:img_src].should_not be_empty}
        it{URI.parse(@comic[:img_src]).should be_a(URI::HTTP)}
        it{@comic[:img_src].should eq 'http://sinfest.net/comikaze/comics/2013-10-19.gif'}
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scrapers-3.2.0 spec/scrapers/sinfest_spec.rb
scrapers-3.1.0 spec/scrapers/sinfest_spec.rb
scrapers-3.0.0 spec/scrapers/sinfest_spec.rb