Sha256: aaf236cf4910520fa97f3883f9583a254a0e6b5752ab7acfd9400a415de8df3e

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

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

module RubyHackernews
  describe VotingInfoParser do

    before :each do
      @voting_element    = ParserHelper.voting_node
      @score_element     = ParserHelper.second_line
      @correct_vote_link = "vote?for=1645686&dir=up&whence=%6e%65%77%73"
    end

    describe :parse do

      it "should assign link.href to upvote if element not nil" do
        parser = VotingInfoParser.new(@voting_element, @score_element)
        VotingInfo.should_receive(:new).with(anything, @correct_vote_link, anything)
        parser.parse
      end

      it "should assing nil to upvote if element nil" do
        parser = VotingInfoParser.new(ParserHelper.voting_node_no_upvote, @score_element)
        VotingInfo.should_receive(:new).with(anything, nil, anything)
        parser.parse
      end

      it "should assing link.href to downvote if element not nil" do
        parser = VotingInfoParser.new(@voting_element, @score_element)
        VotingInfo.should_receive(:new).with(anything, anything, @correct_vote_link)
        parser.parse
      end

      it "should assing nil to downvote if element nil" do
        parser = VotingInfoParser.new(ParserHelper.voting_node_no_downvote, @score_element)
        VotingInfo.should_receive(:new).with(anything, anything, nil)
        parser.parse
      end

      it "should assing correct score to score" do
        parser = VotingInfoParser.new(@voting_element, @score_element)
        VotingInfo.should_receive(:new).with(17, anything, anything)
        parser.parse
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-hackernews-1.4.0 spec/HNAPI/services/entries/parsers/voting_info_parser_spec.rb
ruby-hackernews-1.3.7 spec/HNAPI/services/entries/parsers/voting_info_parser_spec.rb
ruby-hackernews-1.3.6 spec/HNAPI/services/entries/parsers/voting_info_parser_spec.rb
ruby-hackernews-1.3.5 spec/HNAPI/services/entries/parsers/voting_info_parser_spec.rb