Sha256: 18f1a2ba5f1b7ea6ffa250c1778d95685024ca7e3110495e9679ae4a631e17b8

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

describe Neutral::VotingBuilder::Router do
  include Neutral::Engine.routes.url_helpers

  context "for a persisted vote" do
    let(:vote) { FactoryGirl.create(:vote) }

    subject { Neutral::VotingBuilder::Router.new(vote) }

    describe "#positive" do
      subject { super().positive }

      its([:path]) { should eq(vote_path(vote, value: 1)) }
      its([:method]) { should eq('patch') }
    end

    describe "#negative" do
      subject { super().negative }

      its([:path]) { should eq(vote_path(vote, value: 0)) }
      its([:method]) { should eq('patch') }
    end

    describe "#remove" do
      subject { super().remove }

      its([:path]) { should eq(vote_path(vote)) }
    end
  end

  context "for a not persisted vote" do
    let(:vote) { FactoryGirl.build(:vote) }

    subject { Neutral::VotingBuilder::Router.new(vote) }

    describe "#positive" do
      subject { super().positive }

      its([:path]) { should eq(votes_path(vote: vote.main_attributes.merge(value: 1))) }
      its([:method]) { should eq('post') }
    end

    describe "#negative" do
      subject { super().negative }

      its([:path]) { should eq(votes_path(vote: vote.main_attributes.merge(value: 0))) }
      its([:method]) { should eq('post') }
    end

    describe "#remove" do
      subject { -> { super().remove } }

      it { should raise_error }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
neutral-0.0.7 spec/voting_builder/router_spec.rb
neutral-0.0.6 spec/voting_builder/router_spec.rb
neutral-0.0.5 spec/voting_builder/router_spec.rb
neutral-0.0.4 spec/voting_builder/router_spec.rb
neutral-0.0.3 spec/voting_builder/router_spec.rb
neutral-0.0.2 spec/voting_builder/router_spec.rb
neutral-0.0.1 spec/voting_builder/router_spec.rb