added tests
This commit is contained in:
@ -92,7 +92,19 @@ describe ExecutionEnvironmentsController do
|
||||
expect_template(:new)
|
||||
end
|
||||
|
||||
describe '#set_docker_images', docker: true do
|
||||
describe '#set_docker_images' do
|
||||
context 'when Docker is available' do
|
||||
let(:docker_images) { [1, 2, 3] }
|
||||
|
||||
before(:each) do
|
||||
expect(DockerClient).to receive(:check_availability!).at_least(:once)
|
||||
expect(DockerClient).to receive(:image_tags).and_return(docker_images)
|
||||
controller.send(:set_docker_images)
|
||||
end
|
||||
|
||||
expect_assigns(docker_images: :docker_images)
|
||||
end
|
||||
|
||||
context 'when Docker is unavailable' do
|
||||
let(:error_message) { 'Docker is unavailable' }
|
||||
|
||||
|
@ -35,6 +35,23 @@ describe ApplicationHelper do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#progress_bar' do
|
||||
let(:html) { progress_bar(value) }
|
||||
let(:value) { 42 }
|
||||
|
||||
it "builds nested 'div' tags" do
|
||||
expect(html).to have_css('div.progress div.progress-bar')
|
||||
end
|
||||
|
||||
it 'assigns the correct text' do
|
||||
expect(html).to have_text("#{value}%")
|
||||
end
|
||||
|
||||
it 'uses the correct width' do
|
||||
expect(html).to have_css("div.progress-bar[style='width: 42%;']")
|
||||
end
|
||||
end
|
||||
|
||||
describe '#row' do
|
||||
let(:html) { row(label: 'foo', value: 42) }
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
def expect_assigns(pairs)
|
||||
pairs.each_pair do |key, value|
|
||||
pairs.each do |key, value|
|
||||
it "assigns @#{key}" do
|
||||
if value.is_a?(Class)
|
||||
expect(assigns(key)).to be_a(value)
|
||||
else
|
||||
object = value.is_a?(Symbol) ? send(value) : value
|
||||
object = obtain_object(value)
|
||||
if object.is_a?(ActiveRecord::Relation) || object.is_a?(Array)
|
||||
expect(assigns(key)).to match_array(object)
|
||||
else
|
||||
@ -54,3 +54,14 @@ def expect_template(template)
|
||||
expect(controller).to render_template(template)
|
||||
end
|
||||
end
|
||||
|
||||
def obtain_object(value)
|
||||
case value
|
||||
when Proc
|
||||
value.call
|
||||
when Symbol
|
||||
send(value)
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user