From 9aecfedc1bc610dd8a10e0b54076d51386abdf9b Mon Sep 17 00:00:00 2001 From: Hauke Klement Date: Thu, 5 Mar 2015 10:49:08 +0100 Subject: [PATCH] added specs --- spec/models/execution_environment_spec.rb | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/spec/models/execution_environment_spec.rb b/spec/models/execution_environment_spec.rb index f4e75f8c..ad603741 100644 --- a/spec/models/execution_environment_spec.rb +++ b/spec/models/execution_environment_spec.rb @@ -46,6 +46,40 @@ describe ExecutionEnvironment do expect(execution_environment.errors[:user_type]).to be_present end + describe '#valid_test_setup?' do + context 'with a test command and a testing framework' do + before(:each) { execution_environment.update(test_command: FactoryGirl.attributes_for(:ruby)[:test_command], testing_framework: FactoryGirl.attributes_for(:ruby)[:testing_framework]) } + + it 'is valid' do + expect(execution_environment.errors[:test_command]).to be_blank + end + end + + context 'with a test command but no testing framework' do + before(:each) { execution_environment.update(test_command: FactoryGirl.attributes_for(:ruby)[:test_command], testing_framework: nil) } + + it 'is invalid' do + expect(execution_environment.errors[:test_command]).to be_present + end + end + + context 'with no test command but a testing framework' do + before(:each) { execution_environment.update(test_command: nil, testing_framework: FactoryGirl.attributes_for(:ruby)[:testing_framework]) } + + it 'is invalid' do + expect(execution_environment.errors[:test_command]).to be_present + end + end + + context 'with no test command and no testing framework' do + before(:each) { execution_environment.update(test_command: nil, testing_framework: nil) } + + it 'is valid' do + expect(execution_environment.errors[:test_command]).to be_blank + end + end + end + describe '#validate_docker_image?' do it 'is false in the test environment' do expect(Rails.env.test?).to be true