Files
grecia/spec/helpers/votes_helper_spec.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

31 lines
822 B
Ruby

require "rails_helper"
describe VotesHelper do
describe "#voted_for?" do
it "returns true if voted for a proposal" do
proposal = create(:proposal)
votes = { proposal.id => true }
expect(voted_for?(votes, proposal)).to eq(true)
end
it "returns false if not voted for a proposals" do
proposal = create(:proposal)
votes = { proposal.id => nil }
expect(voted_for?(votes, proposal)).to eq(nil)
end
end
describe "#votes_percentage" do
it "alwayses sum 100%" do
debate = create(:debate)
create_list(:vote, 8, votable: debate, vote_flag: true)
create_list(:vote, 3, votable: debate, vote_flag: false)
expect(votes_percentage("likes", debate)).to eq("72%")
expect(votes_percentage("dislikes", debate)).to eq("28%")
end
end
end