Sha256: 57a2815b8d2e0075ffdb64ee429e857f1ef615727b763040c8a137e976f855f6

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe HitCounter do
  before :all do
    HitCounter.delete_all
    @hit_counter = HitCounter.get 'www.google.com'
  end

  describe '#get' do
    context 'when existing URL' do
      describe 'document count' do
        specify { HitCounter.count.should == 1 }
      end
    end

    context 'when new URL' do
      before { HitCounter.get 'www.cnn.com' }

      describe 'document count' do
        specify { HitCounter.count.should == 2 }
      end
    end
  end

  describe '#hits' do
    subject { @hit_counter.hits }

    it { should == 0 }

    context 'when incremented' do
      before { @hit_counter.increment }

      specify { @hit_counter.hits.should == 1 }
    end
  end

  describe '#image' do
    subject { @hit_counter.image }

    it { should be_a Magick::Image }
    pending 'should reflect hits'
  end

  describe '#normalize_url' do
    context 'with "cnn.com"' do
      specify { HitCounter.normalize_url('cnn.com').should == 'http://cnn.com' }
    end

    context 'with "http://www.nytimes.com"' do
      specify { HitCounter.normalize_url('http://www.nytimes.com').should == 'http://www.nytimes.com' }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hit_counter-0.0.1 spec/lib/hit_counter_spec.rb
hit_counter-0.0.0 spec/lib/hit_counter_spec.rb