Sha256: a6509ce0d9c7d79b98e1e5fe513711a2f3a616815a4f78abbda02932c353243f

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe "#voting_for", type: :feature do
  class View < ActionView::Base.extend(Neutral::Helpers::ActionViewExtension)
    def current_voter;end
  end

  def view
    @view ||= View.new
  end

  let(:voteable) { FactoryGirl.create(:post) }

  context "when a valid object" do
    it "builds a voting" do
      Neutral::VotingBuilder::Builder.should_receive(:new).with(voteable, hash_including(:voter)).and_call_original
      Neutral::VotingBuilder::Builder.any_instance.should_receive(:build)
      view.voting_for voteable
    end
  end

  context "when an invalid object" do
    it "raises InvalidVoteableObject error" do
      expect { voting_for "not a voteable object" }.to raise_error
    end
  end

  context "with difference" do
    it "builds a voting with difference" do
      Neutral::VotingBuilder::Builder.should_receive(:new).with(voteable, hash_including(:voter, difference: true)).and_call_original
      Neutral::VotingBuilder::Builder.any_instance.should_receive(:build)
      view.voting_for voteable, difference: true
    end
  end

  context "with specific icon set" do
    let(:icons) { :operations }

    it "builds a voting with specific icon set" do
      Neutral::VotingBuilder::Builder.should_receive(:new).with(voteable, hash_including(:voter, icons: icons)).and_call_original
      Neutral::VotingBuilder::Builder.any_instance.should_receive(:build)
      view.voting_for voteable, icons: icons
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
neutral-0.0.6 spec/helpers/action_view_extension_spec.rb
neutral-0.0.5 spec/helpers/action_view_extension_spec.rb
neutral-0.0.4 spec/helpers/action_view_extension_spec.rb
neutral-0.0.3 spec/helpers/action_view_extension_spec.rb
neutral-0.0.2 spec/helpers/action_view_extension_spec.rb
neutral-0.0.1 spec/helpers/action_view_extension_spec.rb