Sha256: 9e59f6bf97e50c6e6b754a3284ce5120e139a0cbbfb609a3460082275a81b34e

Contents?: true

Size: 1.63 KB

Versions: 10

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Neutral::VotingBuilder::Structure do
  let(:random) { [true, false].sample }

  describe "#to_a" do
    describe "spans" do
      context "when not difference" do
        subject { Neutral::VotingBuilder::Structure.new(random, false).to_a }

        it { should include("positive_span") }
        it { should include("negative_span") }
        it { should_not include("difference_span") }
      end

      context "when difference" do
        subject { Neutral::VotingBuilder::Structure.new(random, true).to_a }

        it { should_not include("positive_span") }
        it { should_not include("negative_span") }
        it { should include("difference_span") }
      end
    end

    describe "remove link" do
      context "when present" do
        before do
          Neutral.configure { |config| config.can_change = true }
        end

        subject { Neutral::VotingBuilder::Structure.new(true, random).to_a }

        it { should include("remove_link") }
      end

      context "when not present" do
        context "when vote is not persisted" do
          subject { Neutral::VotingBuilder::Structure.new(false, random).to_a }

          it { should_not include("remove_link") }
        end

        context "when voter cannot change his vote" do
          before do
            Neutral.configure { |config| config.can_change = false }
          end

          after do
            Neutral.configure { |config| config.can_change = true }
          end

          subject { Neutral::VotingBuilder::Structure.new(true, random).to_a }

          it { should_not include("remove_link") }
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
neutral-0.0.10 spec/voting_builder/structure_spec.rb
neutral-0.0.9 spec/voting_builder/structure_spec.rb
neutral-0.0.8 spec/voting_builder/structure_spec.rb
neutral-0.0.7 spec/voting_builder/structure_spec.rb
neutral-0.0.6 spec/voting_builder/structure_spec.rb
neutral-0.0.5 spec/voting_builder/structure_spec.rb
neutral-0.0.4 spec/voting_builder/structure_spec.rb
neutral-0.0.3 spec/voting_builder/structure_spec.rb
neutral-0.0.2 spec/voting_builder/structure_spec.rb
neutral-0.0.1 spec/voting_builder/structure_spec.rb