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
This commit is contained in:
Bertocq
2018-01-07 00:57:50 +01:00
parent 971f2e308a
commit ed16a78f42
73 changed files with 482 additions and 479 deletions

View File

@@ -3,19 +3,19 @@ require 'rails_helper'
describe ApplicationHelper do
describe "#author_of?" do
it "should be true if user is the author" do
it "is true if user is the author" do
user = create(:user)
proposal = create(:proposal, author: user)
expect(author_of?(proposal, user)).to eq true
end
it "should be false if user is not the author" do
it "is false if user is not the author" do
user = create(:user)
proposal = create(:proposal)
expect(author_of?(proposal, user)).to eq false
end
it "should be false if user or authorable is nil" do
it "is false if user or authorable is nil" do
user = create(:user)
proposal = create(:proposal)

View File

@@ -3,43 +3,43 @@ require 'rails_helper'
describe ProposalsHelper do
describe "#progress_bar_percentage" do
it "should be 0 if no votes" do
it "is 0 if no votes" do
proposal = create(:proposal)
expect(progress_bar_percentage(proposal)).to eq 0
end
it "should be a between 1 and 100 if there are votes but less than needed" do
it "is between 1 and 100 if there are votes but less than needed" do
proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success / 2)
expect(progress_bar_percentage(proposal)).to eq 50
end
it "should be 100 if there are more votes than needed" do
it "is 100 if there are more votes than needed" do
proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success * 2)
expect(progress_bar_percentage(proposal)).to eq 100
end
end
describe "#supports_percentage" do
it "should be 0 if no votes" do
it "is 0 if no votes" do
proposal = create(:proposal)
expect(supports_percentage(proposal)).to eq "0%"
end
it "should be a between 0.1 from 1 to 0.1% of needed votes" do
it "is between 0.1 from 1 to 0.1% of needed votes" do
proposal = create(:proposal, cached_votes_up: 1)
expect(supports_percentage(proposal)).to eq "0.1%"
end
it "should be a between 1 and 100 if there are votes but less than needed" do
it "is between 1 and 100 if there are votes but less than needed" do
proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success / 2)
expect(supports_percentage(proposal)).to eq "50%"
end
it "should be 100 if there are more votes than needed" do
it "is 100 if there are more votes than needed" do
proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success * 2)
expect(supports_percentage(proposal)).to eq "100%"
end
end
end
end

View File

@@ -3,12 +3,12 @@ require 'rails_helper'
describe TextHelper do
describe "#first_paragraph" do
it "should return the first paragraph of a text" do
it "returns the first paragraph of a text" do
text = "\n\nThis is the first paragraph\n\nThis is the second paragraph\n"
expect(first_paragraph(text)).to eq("This is the first paragraph")
end
it "should return blank if the text is blank" do
it "returns blank if the text is blank" do
expect(first_paragraph("")).to eq("")
expect(first_paragraph(nil)).to eq("")
end

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
describe UsersHelper do
describe '#humanize_document_type' do
it "should return a humanized document type" do
it "returns a humanized document type" do
expect(humanize_document_type("1")).to eq "DNI"
expect(humanize_document_type("2")).to eq "Passport"
expect(humanize_document_type("3")).to eq "Residence card"
@@ -11,7 +11,7 @@ describe UsersHelper do
end
describe '#deleted_commentable_text' do
it "should return the appropriate message for deleted debates" do
it "returns the appropriate message for deleted debates" do
debate = create(:debate)
comment = create(:comment, commentable: debate)
@@ -21,7 +21,7 @@ describe UsersHelper do
'</del> <span class="small">(This debate has been deleted)</span>')
end
it "should return the appropriate message for deleted proposals" do
it "returns the appropriate message for deleted proposals" do
proposal = create(:proposal)
comment = create(:comment, commentable: proposal)
@@ -31,7 +31,7 @@ describe UsersHelper do
'</del> <span class="small">(This proposal has been deleted)</span>')
end
it "should return the appropriate message for deleted budget investment" do
it "returns the appropriate message for deleted budget investment" do
investment = create(:budget_investment)
comment = create(:comment, commentable: investment)
@@ -43,12 +43,12 @@ describe UsersHelper do
end
describe '#comment_commentable_title' do
it "should return a link to the comment" do
it "returns a link to the comment" do
comment = create(:comment)
expect(comment_commentable_title(comment)).to eq link_to comment.commentable.title, comment
end
it "should return a hint if the commentable has been deleted" do
it "returns a hint if the commentable has been deleted" do
comment = create(:comment)
comment.commentable.hide
expect(comment_commentable_title(comment)).to eq('<del>' + comment.commentable.title +

View File

@@ -3,18 +3,18 @@ require 'rails_helper'
describe VerificationHelper do
describe "#mask_phone" do
it "should mask a phone" do
it "masks a phone" do
expect(mask_phone("612345678")).to eq("******678")
end
end
describe "#mask_email" do
it "should mask a long email address" do
it "masks a long email address" do
expect(mask_email("isabel@example.com")).to eq("isa***@example.com")
expect(mask_email("antonio.perez@example.com")).to eq("ant**********@example.com")
end
it "should mask a short email address" do
it "masks a short email address" do
expect(mask_email("an@example.com")).to eq("an@example.com")
expect(mask_email("ana@example.com")).to eq("ana@example.com")
expect(mask_email("aina@example.com")).to eq("ain*@example.com")

View File

@@ -3,14 +3,14 @@ require 'rails_helper'
describe VotesHelper do
describe "#voted_for?" do
it "should return true if voted for a proposal" 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 "should return false if not voted for a proposals" do
it "returns false if not voted for a proposals" do
proposal = create(:proposal)
votes = {proposal.id => nil}
@@ -19,7 +19,7 @@ describe VotesHelper do
end
describe "#votes_percentage" do
it "should always sum 100%" 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)