sped up some tests

This commit is contained in:
Hauke Klement
2015-01-30 10:50:44 +01:00
parent 76ceae54b0
commit b08bc8aef2
14 changed files with 65 additions and 46 deletions

View File

@ -61,7 +61,7 @@ describe ErrorsController do
end
describe 'GET #index' do
let!(:errors) { FactoryGirl.create_pair(:error) }
before(:all) { FactoryGirl.create_pair(:error) }
before(:each) { get :index, execution_environment_id: execution_environment.id }
expect_assigns(execution_environment: :execution_environment)

View File

@ -72,7 +72,7 @@ describe ExecutionEnvironmentsController do
end
describe 'GET #index' do
let!(:execution_environments) { FactoryGirl.create_pair(:ruby) }
before(:all) { FactoryGirl.create_pair(:ruby) }
before(:each) { get :index }
expect_assigns(execution_environments: ExecutionEnvironment.all)

View File

@ -1,12 +1,12 @@
require 'rails_helper'
describe ExercisesController do
let(:exercise) { FactoryGirl.create(:fibonacci) }
let(:exercise) { FactoryGirl.create(:dummy) }
let(:user) { FactoryGirl.create(:admin) }
before(:each) { allow(controller).to receive(:current_user).and_return(user) }
describe 'POST #create' do
let(:exercise_attributes) { FactoryGirl.build(:fibonacci).attributes }
let(:exercise_attributes) { FactoryGirl.build(:dummy).attributes }
context 'with a valid exercise' do
let(:request) { Proc.new { post :create, exercise: exercise_attributes } }
@ -61,7 +61,7 @@ describe ExercisesController do
expect_assigns(exercise: :exercise)
it 'destroys the exercise' do
exercise = FactoryGirl.create(:fibonacci)
exercise = FactoryGirl.create(:dummy)
expect { delete :destroy, id: exercise.id }.to change(Exercise, :count).by(-1)
end
@ -102,8 +102,8 @@ describe ExercisesController do
end
describe 'GET #index' do
let!(:exercises) { FactoryGirl.create_pair(:fibonacci) }
let(:scope) { Pundit.policy_scope!(user, Exercise) }
before(:all) { FactoryGirl.create_pair(:dummy) }
before(:each) { get :index }
expect_assigns(exercises: :scope)
@ -195,7 +195,7 @@ describe ExercisesController do
describe 'PUT #update' do
context 'with a valid exercise' do
let(:exercise_attributes) { FactoryGirl.build(:fibonacci).attributes }
let(:exercise_attributes) { FactoryGirl.build(:dummy).attributes }
before(:each) { put :update, exercise: exercise_attributes, id: exercise.id }
expect_assigns(exercise: Exercise)

View File

@ -53,7 +53,7 @@ describe FileTypesController do
end
describe 'GET #index' do
let!(:file_types) { FactoryGirl.create_pair(:dot_rb) }
before(:all) { FactoryGirl.create_pair(:dot_rb) }
before(:each) { get :index }
expect_assigns(file_types: FileType.all)

View File

@ -55,7 +55,7 @@ describe HintsController do
end
describe 'GET #index' do
let!(:hints) { FactoryGirl.create_pair(:ruby_syntax_error) }
before(:all) { FactoryGirl.create_pair(:ruby_syntax_error) }
before(:each) { get :index, execution_environment_id: execution_environment.id }
expect_assigns(execution_environment: :execution_environment)

View File

@ -27,7 +27,7 @@ describe SessionsController do
end
describe 'POST #create_through_lti' do
let(:exercise) { FactoryGirl.create(:fibonacci) }
let(:exercise) { FactoryGirl.create(:dummy) }
let(:nonce) { SecureRandom.hex }
context 'without OAuth parameters' do
@ -125,7 +125,7 @@ describe SessionsController do
describe 'GET #destroy_through_lti' do
let(:request) { Proc.new { get :destroy_through_lti, consumer_id: consumer.id, submission_id: submission.id } }
let(:submission) { FactoryGirl.create(:submission) }
let(:submission) { FactoryGirl.create(:submission, exercise: FactoryGirl.create(:dummy)) }
before(:each) do
session[:consumer_id] = consumer.id

View File

@ -57,7 +57,7 @@ describe SubmissionsController do
end
describe 'GET #index' do
let!(:submissions) { FactoryGirl.create_pair(:submission) }
before(:all) { FactoryGirl.create_pair(:submission) }
before(:each) { get :index }
expect_assigns(submissions: Submission.all)

View File

@ -50,7 +50,7 @@ describe TeamsController do
end
describe 'GET #index' do
let!(:teams) { FactoryGirl.create_pair(:team) }
before(:all) { FactoryGirl.create_pair(:team) }
before(:each) { get :index }
expect_assigns(teams: Team.all)