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:
@@ -6,7 +6,7 @@ describe Admin::Api::StatsController do
|
||||
let(:user) { create(:administrator).user }
|
||||
|
||||
context 'events or visits not present' do
|
||||
it 'should respond with bad_request' do
|
||||
it 'responds with bad_request' do
|
||||
sign_in user
|
||||
get :show
|
||||
|
||||
@@ -29,7 +29,7 @@ describe Admin::Api::StatsController do
|
||||
create :ahoy_event, name: 'bar', time: time_3
|
||||
end
|
||||
|
||||
it 'should return single events formated for working with c3.js' do
|
||||
it 'returns single events formated for working with c3.js' do
|
||||
sign_in user
|
||||
get :show, events: 'foo'
|
||||
|
||||
@@ -39,7 +39,7 @@ describe Admin::Api::StatsController do
|
||||
expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [2, 1]
|
||||
end
|
||||
|
||||
it 'should return combined comma separated events formated for working with c3.js' do
|
||||
it 'returns combined comma separated events formated for working with c3.js' do
|
||||
sign_in user
|
||||
get :show, events: 'foo,bar'
|
||||
|
||||
@@ -51,7 +51,7 @@ describe Admin::Api::StatsController do
|
||||
end
|
||||
|
||||
context 'visits present' do
|
||||
it 'should return visits formated for working with c3.js' do
|
||||
it 'returns visits formated for working with c3.js' do
|
||||
time_1 = DateTime.parse("2015-01-01").in_time_zone
|
||||
time_2 = DateTime.parse("2015-01-02").in_time_zone
|
||||
|
||||
@@ -70,7 +70,7 @@ describe Admin::Api::StatsController do
|
||||
end
|
||||
|
||||
context 'visits and events present' do
|
||||
it 'should return combined events and visits formated for working with c3.js' do
|
||||
it 'returns combined events and visits formated for working with c3.js' do
|
||||
time_1 = DateTime.parse("2015-01-01").in_time_zone
|
||||
time_2 = DateTime.parse("2015-01-02").in_time_zone
|
||||
|
||||
@@ -93,7 +93,7 @@ describe Admin::Api::StatsController do
|
||||
end
|
||||
|
||||
context 'budget investments present' do
|
||||
it 'should return budget investments formated for working with c3.js' do
|
||||
it 'returns budget investments formated for working with c3.js' do
|
||||
time_1 = DateTime.parse("2017-04-01").in_time_zone
|
||||
time_2 = DateTime.parse("2017-04-02").in_time_zone
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ describe CommentsController do
|
||||
@unverified_user = create(:user)
|
||||
end
|
||||
|
||||
it 'should create an comment if the comments are open' do
|
||||
it 'creates an comment if the comments are open' do
|
||||
sign_in @user
|
||||
|
||||
expect do
|
||||
@@ -18,7 +18,7 @@ describe CommentsController do
|
||||
end.to change { @question.reload.comments_count }.by(1)
|
||||
end
|
||||
|
||||
it 'should not create a comment if the comments are closed' do
|
||||
it 'does not create a comment if the comments are closed' do
|
||||
sign_in @user
|
||||
@process.update_attribute(:debate_end_date, Date.current - 1.day)
|
||||
|
||||
@@ -27,7 +27,7 @@ describe CommentsController do
|
||||
end.to_not change { @question.reload.comments_count }
|
||||
end
|
||||
|
||||
it 'should not create a comment for unverified users when the commentable requires it' do
|
||||
it 'does not create a comment for unverified users when the commentable requires it' do
|
||||
sign_in @unverified_user
|
||||
|
||||
expect do
|
||||
|
||||
@@ -11,7 +11,7 @@ describe DebatesController do
|
||||
InvisibleCaptcha.timestamp_enabled = true
|
||||
end
|
||||
|
||||
it 'should create an ahoy event' do
|
||||
it 'creates an ahoy event' do
|
||||
|
||||
sign_in create(:user)
|
||||
|
||||
@@ -26,7 +26,7 @@ describe DebatesController do
|
||||
Setting['max_ratio_anon_votes_on_debates'] = 50
|
||||
end
|
||||
|
||||
it 'should allow vote if user is allowed' do
|
||||
it 'allows vote if user is allowed' do
|
||||
Setting["max_ratio_anon_votes_on_debates"] = 100
|
||||
debate = create(:debate)
|
||||
sign_in create(:user)
|
||||
@@ -36,7 +36,7 @@ describe DebatesController do
|
||||
end.to change { debate.reload.votes_for.size }.by(1)
|
||||
end
|
||||
|
||||
it 'should not allow vote if user is not allowed' do
|
||||
it 'does not allow vote if user is not allowed' do
|
||||
Setting["max_ratio_anon_votes_on_debates"] = 0
|
||||
debate = create(:debate, cached_votes_total: 1000)
|
||||
sign_in create(:user)
|
||||
|
||||
@@ -10,7 +10,7 @@ describe Legislation::AnnotationsController do
|
||||
@user = create(:user, :level_two)
|
||||
end
|
||||
|
||||
it 'should create an ahoy event' do
|
||||
it 'creates an ahoy event' do
|
||||
sign_in @user
|
||||
|
||||
post :create, process_id: @process.id,
|
||||
@@ -24,7 +24,7 @@ describe Legislation::AnnotationsController do
|
||||
expect(Ahoy::Event.last.properties['legislation_annotation_id']).to eq Legislation::Annotation.last.id
|
||||
end
|
||||
|
||||
it 'should not create an annotation if the draft version is a final version' do
|
||||
it 'does not create an annotation if the draft version is a final version' do
|
||||
sign_in @user
|
||||
|
||||
post :create, process_id: @process.id,
|
||||
@@ -38,7 +38,7 @@ describe Legislation::AnnotationsController do
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
||||
it 'should create an annotation if the process allegations phase is open' do
|
||||
it 'creates an annotation if the process allegations phase is open' do
|
||||
sign_in @user
|
||||
|
||||
expect do
|
||||
@@ -52,7 +52,7 @@ describe Legislation::AnnotationsController do
|
||||
end.to change { @draft_version.annotations.count }.by(1)
|
||||
end
|
||||
|
||||
it 'should not create an annotation if the process allegations phase is not open' do
|
||||
it 'does not create an annotation if the process allegations phase is not open' do
|
||||
sign_in @user
|
||||
@process.update_attribute(:allegations_end_date, Date.current - 1.day)
|
||||
|
||||
@@ -67,7 +67,7 @@ describe Legislation::AnnotationsController do
|
||||
end.to_not change { @draft_version.annotations.count }
|
||||
end
|
||||
|
||||
it 'should create an annotation by parsing parameters in JSON' do
|
||||
it 'creates an annotation by parsing parameters in JSON' do
|
||||
sign_in @user
|
||||
|
||||
expect do
|
||||
@@ -81,7 +81,7 @@ describe Legislation::AnnotationsController do
|
||||
end.to change { @draft_version.annotations.count }.by(1)
|
||||
end
|
||||
|
||||
it 'should create a new comment on an existing annotation when range is the same' do
|
||||
it 'creates a new comment on an existing annotation when range is the same' do
|
||||
annotation = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation",
|
||||
ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
|
||||
range_start: "/p[1]", range_start_offset: 6, range_end: "/p[1]", range_end_offset: 11)
|
||||
|
||||
@@ -10,7 +10,7 @@ describe Legislation::AnswersController do
|
||||
@user = create(:user, :level_two)
|
||||
end
|
||||
|
||||
it 'should create an ahoy event' do
|
||||
it 'creates an ahoy event' do
|
||||
sign_in @user
|
||||
|
||||
post :create, process_id: @process.id, question_id: @question.id,
|
||||
@@ -19,7 +19,7 @@ describe Legislation::AnswersController do
|
||||
expect(Ahoy::Event.last.properties['legislation_answer_id']).to eq Legislation::Answer.last.id
|
||||
end
|
||||
|
||||
it 'should create an answer if the process debate phase is open' do
|
||||
it 'creates an answer if the process debate phase is open' do
|
||||
sign_in @user
|
||||
|
||||
expect do
|
||||
@@ -28,7 +28,7 @@ describe Legislation::AnswersController do
|
||||
end.to change { @question.reload.answers_count }.by(1)
|
||||
end
|
||||
|
||||
it 'should not create an answer if the process debate phase is not open' do
|
||||
it 'does not create an answer if the process debate phase is not open' do
|
||||
sign_in @user
|
||||
@process.update_attribute(:debate_end_date, Date.current - 1.day)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ describe Management::BaseController do
|
||||
|
||||
describe 'managed_user' do
|
||||
|
||||
it "should return existent user with session document info if present" do
|
||||
it "returns existent user with session document info if present" do
|
||||
session[:document_type] = "1"
|
||||
session[:document_number] = "333333333E"
|
||||
user = create(:user, :level_two, document_number: "333333333E")
|
||||
@@ -13,7 +13,7 @@ describe Management::BaseController do
|
||||
expect(managed_user).to eq user
|
||||
end
|
||||
|
||||
it "should return new user if no user have the session document info" do
|
||||
it "returns new user if no user have the session document info" do
|
||||
session[:document_type] = "1"
|
||||
session[:document_number] = "333333333E"
|
||||
managed_user = subject.send(:managed_user)
|
||||
|
||||
@@ -3,13 +3,13 @@ require 'rails_helper'
|
||||
describe Management::SessionsController do
|
||||
|
||||
describe 'Sign in' do
|
||||
it "should deny access if wrong manager credentials" do
|
||||
it "denies access if wrong manager credentials" do
|
||||
allow_any_instance_of(ManagerAuthenticator).to receive(:auth).and_return(false)
|
||||
expect { get :create, login: "nonexistent", clave_usuario: "wrong"}.to raise_error CanCan::AccessDenied
|
||||
expect(session[:manager]).to be_nil
|
||||
end
|
||||
|
||||
it "should redirect to management root path if authorized manager with right credentials" do
|
||||
it "redirects to management root path if authorized manager with right credentials" do
|
||||
manager = {login: "JJB033", user_key: "31415926", date: "20151031135905"}
|
||||
allow_any_instance_of(ManagerAuthenticator).to receive(:auth).and_return(manager)
|
||||
|
||||
@@ -18,7 +18,7 @@ describe Management::SessionsController do
|
||||
expect(session[:manager][:login]).to eq "JJB033"
|
||||
end
|
||||
|
||||
it "should redirect to management root path if user is admin" do
|
||||
it "redirects to management root path if user is admin" do
|
||||
user = create(:administrator).user
|
||||
sign_in user
|
||||
get :create
|
||||
@@ -26,7 +26,7 @@ describe Management::SessionsController do
|
||||
expect(session[:manager][:login]).to eq "admin_user_#{user.id}"
|
||||
end
|
||||
|
||||
it "should redirect to management root path if user is manager" do
|
||||
it "redirects to management root path if user is manager" do
|
||||
user = create(:manager).user
|
||||
sign_in user
|
||||
get :create
|
||||
@@ -34,7 +34,7 @@ describe Management::SessionsController do
|
||||
expect(session[:manager][:login]).to eq "manager_user_#{user.id}"
|
||||
end
|
||||
|
||||
it "should deny access if user is not admin or manager" do
|
||||
it "denies access if user is not admin or manager" do
|
||||
sign_in create(:user)
|
||||
expect { get :create}.to raise_error CanCan::AccessDenied
|
||||
expect(session[:manager]).to be_nil
|
||||
@@ -42,7 +42,7 @@ describe Management::SessionsController do
|
||||
end
|
||||
|
||||
describe 'Sign out' do
|
||||
it "should destroy the session data and redirect" do
|
||||
it "destroys the session data and redirect" do
|
||||
session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"}
|
||||
session[:document_type] = "1"
|
||||
session[:document_number] = "12345678Z"
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'rails_helper'
|
||||
describe Management::UsersController do
|
||||
|
||||
describe 'logout' do
|
||||
it "should remove user data from the session" do
|
||||
it "removes user data from the session" do
|
||||
session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"}
|
||||
session[:document_type] = "1"
|
||||
session[:document_number] = "12345678Z"
|
||||
|
||||
@@ -3,27 +3,27 @@ require 'rails_helper'
|
||||
describe PagesController do
|
||||
|
||||
describe 'Static pages' do
|
||||
it 'should include a privacy page' do
|
||||
it 'includes a privacy page' do
|
||||
get :show, id: :privacy
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'should include a conditions page' do
|
||||
it 'includes a conditions page' do
|
||||
get :show, id: :conditions
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'should include a general terms page' do
|
||||
it 'includes a general terms page' do
|
||||
get :show, id: :general_terms
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'should include a terms page' do
|
||||
it 'includes a terms page' do
|
||||
get :show, id: :census_terms
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'should include a accessibility page' do
|
||||
it 'includes a accessibility page' do
|
||||
get :show, id: :accessibility
|
||||
expect(response).to be_ok
|
||||
end
|
||||
@@ -31,24 +31,24 @@ describe PagesController do
|
||||
|
||||
describe 'More info pages' do
|
||||
|
||||
it 'should include a more info page' do
|
||||
it 'includes a more info page' do
|
||||
get :show, id: 'more_info/index'
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'should include a how_to_use page' do
|
||||
it 'includes a how_to_use page' do
|
||||
get :show, id: 'more_info/how_to_use/index'
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'should include a faq page' do
|
||||
it 'includes a faq page' do
|
||||
get :show, id: 'more_info/faq/index'
|
||||
expect(response).to be_ok
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Not found pages' do
|
||||
it 'should return a 404 message' do
|
||||
it 'returns a 404 message' do
|
||||
get :show, id: "nonExistentPage"
|
||||
expect(response).to be_missing
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ describe Users::RegistrationsController do
|
||||
end
|
||||
|
||||
context "when username is available" do
|
||||
it "should return true with no error message" do
|
||||
it "returns true with no error message" do
|
||||
get :check_username, username: "available username"
|
||||
|
||||
data = JSON.parse response.body, symbolize_names: true
|
||||
@@ -19,7 +19,7 @@ describe Users::RegistrationsController do
|
||||
end
|
||||
|
||||
context "when username is not available" do
|
||||
it "should return false with an error message" do
|
||||
it "returns false with an error message" do
|
||||
user = create(:user)
|
||||
get :check_username, username: user.username
|
||||
|
||||
|
||||
Reference in New Issue
Block a user