Files
nairobi/spec/helpers/votes_helper_spec.rb
Bertocq ed16a78f42 Enables RSpec/ExampleWording and fixes all issues
Both avoiding 'should' and repiting 'it' on the tests description
improves reading them and also makes all descriptions consistent.

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWording
2018-01-07 01:03:45 +01:00

32 lines
819 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