Sha256: f3713c0f08a433385857cdcdc4e965c78e7f8815d37550333f0ec4ffd03982a3

Contents?: true

Size: 1.97 KB

Versions: 4

Compression:

Stored size: 1.97 KB

Contents

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

describe "Virility::PlusOne" do
  before(:each) do
    @url = "http://creativeallies.com"
  end

  describe "poll" do
    context "when there is not a valid result" do
      before(:each) do
        response = double("HTTParty::Response", :parsed_response => {"fake_return_value"=> "OICU812"})
        allow(Virility::PlusOne).to receive(:get) { response }
        @virility = Virility::PlusOne.new(@url)
      end

      it_should_behave_like "no context results"
    end

    context "when there is no result" do
      before(:each) do
        response = double("HTTParty::Response")
        allow(Virility::PlusOne).to receive(:get) { response }
        @virility = Virility::PlusOne.new(@url)
      end

      it_should_behave_like "no context results"
    end

    context "when there is a result but no specific hash value" do
      before(:each) do
        response = double("HTTParty::Response", :parsed_response => {})
        allow(Virility::PlusOne).to receive(:get) { response }
        @virility = Virility::PlusOne.new(@url)
      end

      it_should_behave_like "no context results"
    end

    context "when there is a result but parsed_response is weird" do
      before(:each) do
        response = double("HTTParty::Response", :parsed_response => Object.new)
        allow(Virility::PlusOne).to receive(:get) { response }
        @virility = Virility::PlusOne.new(@url)
      end

      it_should_behave_like "no context results"
    end

    context "when there is a valid result" do
      before(:each) do
        response = double("HTTParty::Response", :parsed_response => {"shares"=>"8"})
        allow(Virility::PlusOne).to receive(:get) { response }
        @virility = Virility::PlusOne.new(@url)
      end

      it "should not raise an error" do
        expect{ @virility.poll }.not_to raise_error
      end

      it "should return 8 for the count" do
        expect(@virility.count).to eq(8)
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
virility-0.4.0 spec/strategies/plus_one_spec.rb
virility-0.3.1 spec/strategies/plus_one_spec.rb
virility-0.3.0 spec/strategies/plus_one_spec.rb
virility-0.2.0 spec/strategies/plus_one_spec.rb