Sha256: fe0e93110ddeba5ddc61c2f671ad23426b887d737722847cf38ce7df8b3cd1ef

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'acts_as_votable'
require 'spec_helper'

describe ActsAsVotable::Alias do

  before(:each) do
    clean_database
  end

  describe "votable models" do

    before(:each) do
      clean_database
      @votable = Votable.new(:name => 'votable with aliases')
      @votable.save

      @voter = Voter.new(:name => 'a voter')
      @voter.save
    end

    it "should alias a bunch of functions" do
      
      # voting
      @votable.respond_to?(:disliked_by).should be true
      @votable.respond_to?(:up_from).should be true

      # results
      @votable.respond_to?(:upvotes).should be true
      @votable.respond_to?(:ups).should be true
      @votable.respond_to?(:dislikes).should be true

    end

    it "should add callable functions" do
      @votable.vote :voter => @voter
      @votable.likes.size.should == 1
    end
  end

  describe "voter models" do

    before(:each) do
      clean_database
      @votable = Votable.new(:name => 'a votable')
      @votable.save

      @voter = Voter.new(:name => 'a voter with aliases')
      @voter.save
    end

    it "should alias a bunch of functions" do
      @voter.respond_to?(:upvotes).should be true
      @voter.respond_to?(:dislikes).should be true
    end

    it "should add callable functions" do
      @voter.likes @votable
      @votable.likes.size.should == 1
    end
  end



end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_votable-0.1.0 spec/alias_spec.rb