How to use fixture method of DSL Package

Best Test-prof_ruby code snippet using DSL.fixture

load_spec.rb

Source:load_spec.rb Github

copy

Full Screen

...3 subject{ Eye::Controller.new }4 it "command load exclusive" do5 futures = []6 should_spend(1.2, 0.2) do7 futures << subject.future.command('load', fixture("dsl/just_sleep.eye"))8 futures << subject.future.command('load', fixture("dsl/just_sleep.eye"))9 futures.map(&:value).map{ |r| r.values.first[:error] }.should == [false, false]10 end11 end12 it "should set :current_config as Eye::Config class" do13 subject.load(fixture("dsl/load.eye"))14 cfg = subject.current_config15 cfg.class.should == Eye::Config16 cfg.applications.should_not be_empty17 cfg.settings.should == {}18 end19 it "benchmark" do20 100.times do21 subject.load(fixture("dsl/load.eye"))22 end23 end24 it "blank" do25 subject.load.should == {}26 end27 it "not exists file" do28 mock(subject).set_proc_line29 res = subject.load("/asdf/asd/fasd/fas/df/sfd")30 res["/asdf/asd/fasd/fas/df/sfd"][:error].should == true31 res["/asdf/asd/fasd/fas/df/sfd"][:message].should include("/asdf/asd/fasd/fas/df/sfd")32 end33 it "load 1 ok app" do34 res = subject.load(fixture("dsl/load.eye"))35 res.should_be_ok36 subject.short_tree.should == {37 "app1"=>{38 "gr1"=>{"p1"=>"/tmp/app1-gr1-p1.pid", "p2"=>"/tmp/app1-gr1-p2.pid"},39 "gr2"=>{"q3"=>"/tmp/app1-gr2-q3.pid"},40 "__default__"=>{"g4"=>"/tmp/app1-g4.pid", "g5"=>"/tmp/app1-g5.pid"}},41 "app2"=>{"__default__"=>{"z1"=>"/tmp/app2-z1.pid"}}}42 res.only_value.should == { :error => false, :config => nil }43 end44 it "can accept options" do45 subject.load(fixture("dsl/load.eye"), :some => 1).should_be_ok46 end47 it "work fine throught command" do48 subject.command(:load, fixture("dsl/load.eye")).should_be_ok49 end50 it "load correctly application, groups for full_names processes" do51 subject.load(fixture("dsl/load.eye")).should_be_ok52 p1 = subject.process_by_name('p1')53 p1[:application].should == 'app1'54 p1[:group].should == 'gr1'55 p1.name.should == 'p1'56 p1.full_name.should == 'app1:gr1:p1'57 gr1 = subject.group_by_name 'gr1'58 gr1.full_name.should == 'app1:gr1'59 subject.applications.detect{|c| c.name == 'app1'}.groups.should be_a(Eye::Utils::AliveArray)60 subject.applications.detect{|c| c.name == 'app1'}.groups.detect{|g| g.name == 'gr1'}.processes.should be_a(Eye::Utils::AliveArray)61 g4 = subject.process_by_name('g4')62 g4[:application].should == 'app1'63 g4[:group].should == '__default__'64 g4.name.should == 'g4'65 g4.full_name.should == 'app1:g4'66 end67 it "load + 1new app" do68 subject.load(fixture("dsl/load.eye")).should_be_ok69 subject.short_tree.should == {70 "app1"=>{71 "gr1"=>{"p1"=>"/tmp/app1-gr1-p1.pid", "p2"=>"/tmp/app1-gr1-p2.pid"},72 "gr2"=>{"q3"=>"/tmp/app1-gr2-q3.pid"},73 "__default__"=>{"g4"=>"/tmp/app1-g4.pid", "g5"=>"/tmp/app1-g5.pid"}},74 "app2"=>{"__default__"=>{"z1"=>"/tmp/app2-z1.pid"}}}75 subject.load(fixture("dsl/load2.eye")).should_be_ok76 subject.short_tree.should == {77 "app1"=>{78 "gr1"=>{"p1"=>"/tmp/app1-gr1-p1.pid", "p2"=>"/tmp/app1-gr1-p2.pid"},79 "gr2"=>{"q3"=>"/tmp/app1-gr2-q3.pid"},80 "__default__"=>{"g4"=>"/tmp/app1-g4.pid", "g5"=>"/tmp/app1-g5.pid"}},81 "app2"=>{"__default__"=>{"z1"=>"/tmp/app2-z1.pid"}},82 "app3"=>{"__default__"=>{"e1"=>"/tmp/app3-e1.pid"}}}83 end84 it "load 1 changed app" do85 subject.load(fixture("dsl/load.eye")).should_be_ok86 subject.load(fixture("dsl/load2.eye")).should_be_ok87 p = subject.process_by_name('e1')88 p[:daemonize].should == false89 proxy(p).schedule command: :update_config, args: is_a(Array)90 dont_allow(p).schedule :monitor91 p.logger.prefix.should == 'app3:e1'92 subject.load(fixture("dsl/load3.eye")).should_be_ok93 subject.short_tree.should == {94 "app1"=>{95 "gr1"=>{"p1"=>"/tmp/app1-gr1-p1.pid", "p2"=>"/tmp/app1-gr1-p2.pid"},96 "gr2"=>{"q3"=>"/tmp/app1-gr2-q3.pid"},97 "__default__"=>{"g4"=>"/tmp/app1-g4.pid", "g5"=>"/tmp/app1-g5.pid"}},98 "app2"=>{"__default__"=>{"z1"=>"/tmp/app2-z1.pid"}},99 "app3"=>{"wow"=>{"e1"=>"/tmp/app3-e1.pid"}}}100 sleep 0.1101 p2 = subject.process_by_name('e1')102 p2[:daemonize].should == true103 p.object_id.should == p2.object_id104 p.logger.prefix.should == 'app3:wow:e1'105 end106 it "load -> delete -> load" do107 subject.load(fixture("dsl/load.eye")).should_be_ok108 subject.load(fixture("dsl/load2.eye")).should_be_ok109 subject.command(:delete, 'app3')110 subject.load(fixture("dsl/load3.eye")).should_be_ok111 subject.short_tree.should == {112 "app1"=>{113 "gr1"=>{"p1"=>"/tmp/app1-gr1-p1.pid", "p2"=>"/tmp/app1-gr1-p2.pid"},114 "gr2"=>{"q3"=>"/tmp/app1-gr2-q3.pid"},115 "__default__"=>{"g4"=>"/tmp/app1-g4.pid", "g5"=>"/tmp/app1-g5.pid"}},116 "app2"=>{"__default__"=>{"z1"=>"/tmp/app2-z1.pid"}},117 "app3"=>{"wow"=>{"e1"=>"/tmp/app3-e1.pid"}}}118 end119 it "load + 1 app, and pid_file crossed" do120 subject.load(fixture("dsl/load2.eye")).should_be_ok121 subject.load(fixture("dsl/load4.eye")).only_value.should include(:error => true, :message => "duplicate pid_files: {\"/tmp/app3-e1.pid\"=>2}")122 subject.short_tree.should == {123 "app3"=>{"__default__"=>{"e1"=>"/tmp/app3-e1.pid"}}}124 end125 it "check syntax" do126 subject.command(:check, fixture("dsl/load_dup_ex_names3.eye")).only_value.should include(:error => true)127 end128 it "check explain" do129 res = subject.command(:explain, fixture("dsl/load2.eye")).only_value130 res[:error].should == false131 res[:config].is_a?(Hash).should == true132 end133 it "process and groups disappears" do134 subject.load(fixture("dsl/load.eye")).should_be_ok135 subject.group_by_name('gr1').processes.full_size.should == 2136 subject.load(fixture("dsl/load5.eye")).should_be_ok137 sleep 0.5138 group_actors = Celluloid::Actor.all.select{|c| c.class == Eye::Group }139 process_actors = Celluloid::Actor.all.select{|c| c.class == Eye::Process }140 subject.short_tree.should == {141 "app1"=>{"gr1"=>{"p1"=>"/tmp/app1-gr1-p1.pid"}},142 "app2"=>{"__default__"=>{"z1"=>"/tmp/app2-z1.pid"}}}143 group_actors.map{|a| a.name}.sort.should == %w{__default__ gr1}144 process_actors.map{|a| a.name}.sort.should == %w{p1 z1}145 subject.group_by_name('gr1').processes.full_size.should == 1146 # terminate 1 action147 subject.process_by_name('p1').terminate148 subject.info_data.should be_a(Hash)149 end150 it "swap groups" do151 subject.load(fixture("dsl/load.eye")).should_be_ok152 subject.load(fixture("dsl/load6.eye")).should_be_ok153 subject.short_tree.should == {154 "app1" => {155 "gr2"=>{"p1"=>"/tmp/app1-gr1-p1.pid", "p2"=>"/tmp/app1-gr1-p2.pid"},156 "gr1"=>{"q3"=>"/tmp/app1-gr2-q3.pid"},157 "__default__"=>{"g4"=>"/tmp/app1-g4.pid", "g5"=>"/tmp/app1-g5.pid"}},158 "app2"=>{"__default__"=>{"z1"=>"/tmp/app2-z1.pid"}}}159 end160 it "two configs with same pids (should validate final config)" do161 subject.load(fixture("dsl/load.eye")).should_be_ok162 res = subject.load(fixture("dsl/load2{,_dup_pid,_dup2}.eye"))163 res.ok_count.should == 2164 res.errors_count.should == 1165 res.only_match(/load2_dup_pid\.eye/).should include(:error => true, :message=>"duplicate pid_files: {\"/tmp/app3-e1.pid\"=>2}")166 end167 it "two configs with same pids (should validate final config)" do168 subject.load(fixture("dsl/load.eye")).should_be_ok169 subject.load(fixture("dsl/load2.eye")).should_be_ok170 res = subject.load(fixture("dsl/load2_*.eye"))171 res.size.should > 1172 res.errors_count.should == 1173 res.only_match(/load2_dup_pid\.eye/).should include(:error => true, :message=>"duplicate pid_files: {\"/tmp/app3-e1.pid\"=>2}")174 end175 it "dups of pid_files, but they different with expand" do176 subject.load(fixture("dsl/load2_dup2.eye")).should_be_ok177 end178 it "dups of names but in different scopes" do179 subject.load(fixture("dsl/load_dup_ex_names.eye")).should_be_ok180 end181 it "processes with same names in different scopes should not create new processes on just update" do182 subject.load(fixture("dsl/load_dup_ex_names.eye")).should_be_ok183 p1 = subject.process_by_full_name('app1:p1:server')184 p2 = subject.process_by_full_name('app1:p2:server')185 subject.load(fixture("dsl/load_dup_ex_names2.eye")).should_be_ok186 t = subject.short_tree187 t['app1']['p1']['server'].should match('server1.pid')188 t['app1']['p2']['server'].should match('server2.pid')189 p12 = subject.process_by_full_name('app1:p1:server')190 p22 = subject.process_by_full_name('app1:p2:server')191 p12.object_id.should == p1.object_id192 p22.object_id.should == p2.object_id193 end194 it "same processes crossed in apps duplicate pids" do195 subject.load(fixture("dsl/load_dup_ex_names3.eye")).errors_count.should == 1196 end197 it "same processes crossed in apps" do198 subject.load(fixture("dsl/load_dup_ex_names4.eye")).should_be_ok199 p1 = subject.process_by_full_name('app1:gr:server')200 p2 = subject.process_by_full_name('app2:gr:server')201 p1.object_id.should_not == p2.object_id202 subject.load(fixture("dsl/load_dup_ex_names4.eye")).should_be_ok203 p12 = subject.process_by_full_name('app1:gr:server')204 p22 = subject.process_by_full_name('app2:gr:server')205 p12.object_id.should == p1.object_id206 p22.object_id.should == p2.object_id207 end208 it "order of applications and groups" do209 subject.load_content(<<-F)210 Eye.app(:app2) { }211 Eye.app(:app1) {212 process("p"){ pid_file "1" }213 group(:gr3){}214 group(:gr2){}215 group(:gr1){}216 }217 F218 subject.applications.map(&:name).should == %w{app1 app2}219 app = subject.applications[0]220 app.groups.map(&:name).should == %w{gr1 gr2 gr3 __default__}221 end222 describe "configs" do223 after(:each){ set_glogger }224 it "load logger" do225 subject.load(fixture("dsl/load_logger.eye")).should_be_ok226 Eye::Logger.dev.should == "/tmp/1.loG"227 end228 it "set logger when load multiple configs" do229 subject.load(fixture("dsl/load_logger{,2}.eye")).should_be_ok(2)230 Eye::Logger.dev.should == "/tmp/1.loG"231 end232 it "load logger with rotation" do233 subject.load_content(<<-S)234 Eye.config { logger "/tmp/1.log", 7, 10000 }235 S236 Eye::Logger.dev.should == "/tmp/1.log"237 end238 it "not set bad logger" do239 subject.load(fixture("dsl/load_logger.eye")).should_be_ok240 Eye::Logger.dev.should == "/tmp/1.loG"241 res = subject.load_content(<<-S)242 Eye.config { logger "/tmp/asdfasdf/sd/f/sdf/sd/f/sdf/s" }243 S244 Eye::Logger.dev.should == "/tmp/1.loG"245 subject.current_config.settings.should == {:logger=>["/tmp/1.loG"], :logger_level => 0}246 end247 it "not set bad logger" do248 subject.load_content(" Eye.config { logger 1 } ")249 Eye::Logger.dev.should be250 end251 it "set custom logger" do252 subject.load_content(" Eye.config { logger Logger.new('/tmp/eye_temp.log') } ")253 Eye::Logger.dev.instance_variable_get(:@logdev).filename.should == '/tmp/eye_temp.log'254 end255 it "set syslog" do256 subject.load_content(" Eye.config { logger syslog } ")257 if RUBY_VERSION <= '1.9.3'258 Eye::Logger.dev.should be_a(String)259 else260 Eye::Logger.dev.should be_a(Syslog::Logger)261 end262 end263 it "should corrent load config section" do264 subject.load(fixture("dsl/configs/{1,2}.eye")).should_be_ok(2)265 Eye::Logger.dev.should == "/tmp/a.log"266 subject.current_config.settings.should == {:logger=>["/tmp/a.log"], :http=>{:enable=>true}}267 subject.load(fixture("dsl/configs/3.eye")).should_be_ok268 Eye::Logger.dev.should == "/tmp/a.log"269 subject.current_config.settings.should == {:logger=>["/tmp/a.log"], :http=>{:enable=>false}}270 subject.load(fixture("dsl/configs/4.eye")).should_be_ok271 Eye::Logger.dev.should == nil272 subject.current_config.settings.should == {:logger=>[nil], :http=>{:enable=>false}}273 subject.load(fixture("dsl/configs/2.eye")).should_be_ok274 Eye::Logger.dev.should == nil275 subject.current_config.settings.should == {:logger=>[nil], :http=>{:enable=>true}}276 end277 it "should load not settled config option" do278 subject.load(fixture("dsl/configs/5.eye")).should_be_ok279 end280 end281 it "load folder" do282 subject.load(fixture("dsl/load_folder/")).should_be_ok(2)283 subject.short_tree.should == {284 "app3" => {"wow"=>{"e1"=>"/tmp/app3-e1.pid"}},285 "app4" => {"__default__"=>{"e2"=>"/tmp/app4-e2.pid"}}286 }287 end288 it "load folder with error" do289 subject.load(fixture("dsl/load_error_folder/")).errors_count.should == 1290 end291 it "load files by mask" do292 subject.load(fixture("dsl/load_folder/*.eye")).should_be_ok(2)293 subject.short_tree.should == {294 "app3" => {"wow"=>{"e1"=>"/tmp/app3-e1.pid"}},295 "app4" => {"__default__"=>{"e2"=>"/tmp/app4-e2.pid"}}296 }297 end298 it "load files by mask with error" do299 subject.load(fixture("dsl/load_error_folder/*.eye")).errors_count.should == 1300 end301 it "load not files with mask" do302 subject.load(fixture("dsl/load_folder/*.bla")).errors_count.should == 1303 end304 it "bad mask" do305 s = " asdf asdf afd d"306 res = subject.load(s)307 res[s][:error].should == true308 res[s][:message].should include(s)309 end310 it "group update it settings" do311 subject.load(fixture("dsl/load.eye")).should_be_ok312 app = subject.application_by_name('app1')313 gr = subject.group_by_name('gr2')314 gr.config[:chain].should == {:restart => {:grace=>0.5, :action=>:restart}, :start => {:grace=>0.5, :action=>:start}}315 subject.load(fixture("dsl/load6.eye")).should_be_ok316 sleep 1317 gr.config[:chain].should == {:restart => {:grace=>1.0, :action=>:restart}, :start => {:grace=>1.0, :action=>:start}}318 end319 it "load multiple apps with cross constants" do320 subject.load(fixture('dsl/subfolder{2,3}.eye')).should_be_ok(2)321 subject.process_by_name('e1')[:working_dir].should == '/tmp'322 subject.process_by_name('e2')[:working_dir].should == '/var'323 subject.process_by_name('e3')[:working_dir].should == '/tmp'324 subject.process_by_name('e4')[:working_dir].should == '/'325 end326 it "raised load" do327 res = subject.load(fixture("dsl/load_error.eye")).only_value328 res[:error].should == true329 res[:message].should include("/asd/fasd/fas/df/asd/fas/df/d")330 set_glogger331 end332 describe "synchronize groups" do333 it "correctly schedule monitor for groups and processes" do334 subject.load(fixture("dsl/load_int.eye")).should_be_ok335 sleep 0.5336 p0 = subject.process_by_name 'p0'337 p1 = subject.process_by_name 'p1'338 p2 = subject.process_by_name 'p2'339 gr1 = subject.group_by_name 'gr1'340 gr_ = subject.group_by_name '__default__'341 p0.scheduler_history.states.should == [:monitor]342 p1.scheduler_history.states.should == [:monitor]343 p2.scheduler_history.states.should == [:monitor]344 gr1.scheduler_history.states.should == [:monitor]345 gr_.scheduler_history.states.should == [:monitor]346 subject.load(fixture("dsl/load_int2.eye")).should_be_ok347 sleep 0.5348 p1.alive?.should == false349 p0.alive?.should == false350 p01 = subject.process_by_name 'p0-1'351 p4 = subject.process_by_name 'p4'352 p5 = subject.process_by_name 'p5'353 gr2 = subject.group_by_name 'gr2'354 p2.scheduler_history.states.should == [:monitor, :update_config]355 gr1.scheduler_history.states.should == [:monitor, :update_config]356 gr_.scheduler_history.states.should == [:monitor, :update_config]357 p01.scheduler_history.states.should == [:monitor]358 p4.scheduler_history.states.should == [:monitor]359 p5.scheduler_history.states.should == [:monitor]360 gr2.scheduler_history.states.should == [:monitor]361 end362 end363 describe "load is exclusive" do364 it "run double in time" do365 subject.async.command(:load, fixture("dsl/long_load.eye"))366 subject.async.command(:load, fixture("dsl/long_load.eye"))367 sleep 2.5368 should_spend(0, 0.6) do369 subject.command(:info_data).should be_a(Hash)370 end371 end372 it "load with subloads" do373 silence_warnings{374 subject.command(:load, fixture("dsl/subfolder2.eye"))375 }376 sleep 0.5377 should_spend(0, 0.2) do378 subject.command(:info_data).should be_a(Hash)379 end380 end381 end382 describe "cleanup configs on delete" do383 it "load config, delete 1 process, load another config" do384 subject.load(fixture('dsl/load.eye'))385 subject.process_by_name('p1').should be386 subject.command(:delete, "p1"); sleep 0.1387 subject.process_by_name('p1').should be_nil388 subject.load(fixture('dsl/load2.eye'))389 subject.process_by_name('p1').should be_nil390 end391 it "load config, delete 1 group, load another config" do392 subject.load(fixture('dsl/load.eye'))393 subject.group_by_name('gr1').should be394 subject.command(:delete, "gr1"); sleep 0.1395 subject.group_by_name('p1').should be_nil396 subject.load(fixture('dsl/load2.eye'))397 subject.group_by_name('gr1').should be_nil398 end399 it "load config, then delete app, and load it with changed app-name" do400 subject.load(fixture('dsl/load3.eye'))401 subject.command(:delete, "app3"); sleep 0.1402 subject.load(fixture('dsl/load4.eye')).should_be_ok403 end404 it "delete from empty app (was an exception)" do405 subject.load_content(<<-F)406 Eye.app(:bla) { }407 Eye.app(:good) { group(:gr){}; process(:pr){ pid_file '1'} }408 F409 subject.command(:delete, "pr")410 subject.command(:delete, "gr")411 subject.command(:delete, "good")412 subject.command(:delete, "bla")413 end414 end415 it "should update only changed apps" do416 mock(subject).update_or_create_application('app1', is_a(Hash))417 mock(subject).update_or_create_application('app2', is_a(Hash))418 subject.load(fixture('dsl/load.eye'))419 mock(subject).update_or_create_application('app3', is_a(Hash))420 subject.load(fixture('dsl/load2.eye'))421 mock(subject).update_or_create_application('app3', is_a(Hash))422 subject.load(fixture('dsl/load3.eye'))423 end424 describe "load multiple" do425 after(:each){ set_glogger }426 it "ok load 2 configs" do427 subject.load(fixture("dsl/configs/1.eye"), fixture("dsl/configs/2.eye")).should_be_ok(2)428 end429 it "load 2 configs, 1 not exists" do430 res = subject.load(fixture("dsl/configs/1.eye"), fixture("dsl/configs/dddddd.eye"))431 res.size.should > 1432 res.errors_count.should == 1433 end434 it "multiple + folder" do435 res = subject.load(fixture("dsl/load.eye"), fixture("dsl/load_folder/"))436 res.ok_count.should == 3437 res.errors_count.should == 0438 end439 end440 describe "Load double processes with same names (was a bug)" do441 it "2 apps with procecesses with the same name" do442 cfg = <<-S443 Eye.app(:app) do444 group(:gr1) { process(:p) { pid_file "1.pid" } }445 group(:gr2) { process(:p) { pid_file "2.pid" } }446 end447 S448 subject.load_content(cfg)449 subject.load_content(cfg)450 Celluloid::Actor.all.select { |c| c.class == Eye::Process }.size.should == 2451 end452 it "2 process in different apps in __default__" do453 cfg = <<-S454 Eye.app(:app1) { process(:p) { pid_file "1.pid" } }455 Eye.app(:app2) { process(:p) { pid_file "2.pid" } }456 S457 subject.load_content(cfg)458 subject.load_content(cfg)459 Celluloid::Actor.all.select { |c| c.class == Eye::Process }.size.should == 2460 end461 it "2 process in different apps" do462 cfg = <<-S463 Eye.app(:app1) { group(:gr1) { process(:p) { pid_file "1.pid" } } }464 Eye.app(:app2) { group(:gr2) { process(:p) { pid_file "2.pid" } } }465 S466 subject.load_content(cfg)467 subject.load_content(cfg)468 Celluloid::Actor.all.select { |c| c.class == Eye::Process }.size.should == 2469 Celluloid::Actor.all.select { |c| c.class == Eye::Group }.size.should == 2470 end471 it "2 groups" do472 cfg = <<-S473 Eye.app(:app1) { group(:gr){} }474 Eye.app(:app2) { group(:gr){} }475 S476 subject.load_content(cfg)477 subject.load_content(cfg)478 Celluloid::Actor.all.select { |c| c.class == Eye::Group }.size.should == 2479 end480 end481 it "contacts bug #118" do482 subject.load(fixture("dsl/contact1.eye"), fixture("dsl/contact2.eye"))483 subject.settings[:contacts].keys.sort.should == %w{contact1 contact2}484 end485 it "using shared object" do486 cfg1 = <<-S487 Eye.shared.bla = {"1" => "2"}488 S489 cfg2 = <<-S2490 Eye.app(:app2) { process(:p) { pid_file "2.pid"; env Eye.shared.bla; env "3" => "4" } }491 S2492 subject.load_content(cfg1)493 subject.load_content(cfg2)494 subject.process_by_name('p').config[:environment].should == {"1" => "2", "3" => "4"}495 end496 describe "default app" do497 it "load in one config" do498 cfg1 = <<-S499 Eye.app :__default__ do500 env "A" => "B"501 end502 Eye.app :some do503 end504 S505 subject.load_content(cfg1)506 subject.application_by_name('some').config[:environment].should == {"A" => "B"}507 subject.application_by_name('__default__').should == nil508 subject.application_by_name('some').config[:application].should be_nil509 end510 it "should merge defaults in one config" do511 cfg1 = <<-S512 Eye.app :__default__ do513 env "A" => "B"514 end515 Eye.app :__default__ do516 env "C" => "D"517 end518 Eye.app :some do519 end520 S521 subject.load_content(cfg1)522 subject.application_by_name('some').config[:environment].should == {"A" => "B", "C" => "D"}523 subject.application_by_name('__default__').should == nil524 end525 it "should rewrite defaults in one config" do526 cfg1 = <<-S527 Eye.app :__default__ do528 stop_signals :term, 10529 end530 Eye.app :__default__ do531 stop_signals :term, 11532 end533 Eye.app :some do534 end535 S536 subject.load_content(cfg1)537 subject.application_by_name('some').config[:stop_signals].should == [:term, 11]538 end539 it "should rewrite defaults check in one config" do540 cfg1 = <<-S541 Eye.app :__default__ do542 check :memory, :below => 10543 end544 Eye.app :__default__ do545 check :memory, :below => 11546 end547 Eye.app :some do548 end549 S550 subject.load_content(cfg1)551 subject.application_by_name('some').config[:checks].should == {:memory=>{:below=>11, :type=>:memory}}552 end553 it "should not accept group and process inside __default__ app" do554 cfg1 = <<-S555 Eye.app :__default__ do556 stdall "/tmp/2"557 group :bla do558 process(:a) { pid_file '/tmp/1' }559 end560 end561 Eye.app :some do562 end563 S564 subject.load_content(cfg1)565 subject.application_by_name('some').config[:groups].should == nil566 subject.application_by_name('some').config[:stdall].should == '/tmp/2'567 end568 it "load two configs per one load" do569 subject.load(fixture('dsl/default1.eye'), fixture('dsl/default2.eye'))570 subject.application_by_name('some').config[:environment].should == {"A" => "B"}571 subject.application_by_name('__default__').should == nil572 end573 it "load in two configs" do574 subject.load(fixture('dsl/default1.eye'))575 subject.load(fixture('dsl/default2.eye'))576 subject.application_by_name('some').config[:environment].should == {"A" => "B"}577 subject.application_by_name('__default__').should == nil578 end579 it "load in two configs, with merge default" do580 subject.load(fixture('dsl/default1.eye'))581 subject.load(fixture('dsl/default3.eye'))582 subject.application_by_name('some').config[:environment].should == {"A" => "B", "C" => "D"}583 subject.application_by_name('__default__').should == nil584 end585 it "load in two configs, with merge default" do586 subject.load(fixture('dsl/default4.eye'))587 subject.load(fixture('dsl/default2.eye'))588 appcfg = subject.application_by_name('some').config589 subject.application_by_name('__default__').should == nil590 appcfg[:checks].keys.should == [:memory]591 appcfg[:triggers].keys.should == [:stop_children]592 end593 end594 describe "valiadate localize params" do595 it "validate correct working_dir" do596 conf = <<-E597 Eye.application("bla") do598 process("1") do599 pid_file "1.pid"600 working_dir "/tmp"601 end...

Full Screen

Full Screen

dsl_spec.rb

Source:dsl_spec.rb Github

copy

Full Screen

...3require 'vanagon/common'4require 'vanagon/platform'5describe 'Vanagon::Project::DSL' do6 let (:project_block) {7"project 'test-fixture' do |proj|8end" }9 let(:configdir) { '/a/b/c' }10 let(:platform) do11 OpenStruct.new(:settings => {})12 end13 describe '#version_from_git' do14 it 'sets the version based on the git describe' do15 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)16 proj.instance_eval(project_block)17 # Lying is bad. You shouldn't lie. But sometimes when you're18 # working with gross abstractions piled into the shape of19 # an indescribable cyclopean obelisk, you might have to lie20 # a little bit. Instead of trying to mock an entire Git instance,21 # we'll just instantiate a Double and allow it to receive calls22 # to .describe like it was a valid Git instance.23 repo = double("repo")24 expect(::Git)25 .to receive(:open)26 .and_return(repo)27 allow(repo)28 .to receive(:describe)29 .and_return('1.2.3-1234')30 proj.version_from_git31 expect(proj._project.version).to eq('1.2.3.1234')32 end33 it 'sets the version based on the git describe with multiple dashes' do34 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)35 proj.instance_eval(project_block)36 # See previous description of "indescribable cyclopean obelisk"37 repo = double("repo")38 expect(::Git)39 .to receive(:open)40 .and_return(repo)41 expect(repo)42 .to receive(:describe)43 .and_return('1.2.3---1234')44 proj.version_from_git45 expect(proj._project.version).to eq('1.2.3.1234')46 end47 end48 describe '#release_from_git' do49 it 'sets the release based on commits since last tag' do50 repo = double51 tag = double52 log = double53 diff = double54 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)55 proj.instance_eval(project_block)56 repo = double("repo")57 expect(::Git)58 .to receive(:open)59 .and_return(repo)60 expect(repo)61 .to receive(:describe)62 .and_return('1.2.3')63 expect(repo)64 .to receive(:rev_list)65 .with('1.2.3..HEAD', { :count => true })66 .and_return('999')67 proj.release_from_git68 expect(proj._project.release).to eq('999')69 end70 end71 describe '#version_from_branch' do72 it 'parses out versions from branch names' do73 branches = {74 'maint/3.8.x/fix-bugs' => '3.8',75 '2017.1.2.3-prep' => '2017.1.2.3',76 '3.8' => '3.8',77 }78 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)79 proj.instance_eval(project_block)80 branches.each do |branch, version|81 repo = double("repo")82 expect(::Git)83 .to receive(:open)84 .and_return(repo)85 allow(repo)86 .to receive(:current_branch)87 .and_return(branch)88 expect(proj.version_from_branch).to eq(version)89 end90 end91 it 'fails if there is none' do92 branches = [93 'PUP-12345',94 '200',95 'just-a-branch-name'96 ]97 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)98 proj.instance_eval(project_block)99 branches.each do |branch|100 repo = double("repo")101 expect(::Git)102 .to receive(:open)103 .and_return(repo)104 allow(repo)105 .to receive(:current_branch)106 .and_return(branch)107 expect(proj).to receive(:fail)108 proj.version_from_branch109 end110 end111 end112 describe '#directory' do113 it 'adds a directory to the list of directories' do114 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)115 proj.instance_eval(project_block)116 proj.directory('/a/b/c/d', mode: '0755')117 expect(proj._project.directories).to include(Vanagon::Common::Pathname.new('/a/b/c/d', mode: '0755'))118 end119 end120 describe '#user' do121 it 'sets a user for the project' do122 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)123 proj.instance_eval(project_block)124 proj.user('test-user')125 expect(proj._project.user).to eq(Vanagon::Common::User.new('test-user'))126 end127 end128 describe '#target_repo' do129 it 'sets the target_repo for the project' do130 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)131 proj.instance_eval(project_block)132 proj.target_repo "pc1"133 expect(proj._project.repo).to eq("pc1")134 end135 end136 describe '#noarch' do137 it 'sets noarch on the project to true' do138 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)139 proj.instance_eval(project_block)140 proj.noarch141 expect(proj._project.noarch).to eq(true)142 end143 end144 describe '#generate_source_artifacts' do145 it 'defaults to false' do146 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)147 proj.instance_eval(project_block)148 expect(proj._project.source_artifacts).to eq(false)149 end150 it 'sets source_artifacts to true' do151 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)152 proj.instance_eval(project_block)153 proj.generate_source_artifacts true154 expect(proj._project.source_artifacts).to eq(true)155 end156 it 'sets source_artifacts to false' do157 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)158 proj.instance_eval(project_block)159 proj.generate_source_artifacts false160 expect(proj._project.source_artifacts).to eq(false)161 end162 end163 describe '#identifier' do164 it 'sets the identifier for the project' do165 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)166 proj.instance_eval(project_block)167 proj.identifier "com.example"168 expect(proj._project.identifier).to eq("com.example")169 end170 end171 describe '#cleanup_during_build' do172 it 'sets @cleanup to true' do173 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)174 proj.instance_eval(project_block)175 proj.cleanup_during_build176 expect(proj._project.cleanup).to eq(true)177 end178 it 'defaults to nil' do179 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)180 proj.instance_eval(project_block)181 expect(proj._project.cleanup).to be_nil182 end183 end184 describe "#write_version_file" do185 let(:version_file) { '/opt/puppetlabs/puppet/VERSION' }186 it 'sets version_file for the project' do187 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)188 proj.instance_eval(project_block)189 proj.write_version_file(version_file)190 expect(proj._project.version_file.path).to eq(version_file)191 end192 end193 describe "#release" do194 it 'sets the release for the project' do195 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)196 proj.instance_eval(project_block)197 proj.release '12'198 expect(proj._project.release).to eq('12')199 end200 it 'defaults to 1' do201 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)202 proj.instance_eval(project_block)203 expect(proj._project.release).to eq('1')204 end205 end206 describe "#provides" do207 before do208 allow_any_instance_of(Vanagon::Project::DSL).to receive(:puts)209 @el_plat = Vanagon::Platform::DSL.new('el-6-x86_64')210 @el_plat.instance_eval("platform 'el-6-x86_64' do |plat| end")211 @deb_plat = Vanagon::Platform::DSL.new('ubuntu-18.04-amd64')212 @deb_plat.instance_eval("platform 'ubuntu-18.04-amd64' do |plat| end")213 end214 it 'adds the package provide to the list of provides' do215 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)216 proj.instance_eval(project_block)217 proj.provides('thing1')218 proj.provides('thing2')219 expect(proj._project.get_provides.count).to eq(2)220 expect(proj._project.get_provides.first.provide).to eq('thing1')221 expect(proj._project.get_provides.last.provide).to eq('thing2')222 end223 # we don't actually use deb versions for provides at this point, but224 # testing it works nonetheless225 it 'supports deb versioned provides' do226 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @deb_plat._platform, [])227 proj.instance_eval(project_block)228 proj.provides('thing1', '1.2.3')229 expect(proj._project.get_provides.count).to eq(1)230 expect(proj._project.get_provides.first.provide).to eq('thing1')231 expect(proj._project.get_provides.first.version).to eq('>= 1.2.3')232 end233 # we don't actually use deb versions for provides at this point, but234 # testing it works nonetheless235 it 'munges deb* versions' do236 operators = {237 '<' => '<<',238 '>' => '>>',239 '<=' => '<=',240 '>=' => '>=',241 '=' => '='242 }243 operators.each do |initial, munged|244 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @deb_plat._platform, [])245 proj.instance_eval(project_block)246 proj.provides('thing1', "#{initial}1.2.3")247 expect(proj._project.get_provides.count).to eq(1)248 expect(proj._project.get_provides.first.provide).to eq('thing1')249 expect(proj._project.get_provides.first.version).to eq("#{munged} 1.2.3")250 end251 end252 it 'adds whitespace for rpm versions' do253 operators=['<','>','<=','>=','=']254 operators.each do |operator|255 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])256 proj.instance_eval(project_block)257 proj.provides('thing1', "#{operator}1.2.3")258 expect(proj._project.get_provides.count).to eq(1)259 expect(proj._project.get_provides.first.provide).to eq('thing1')260 expect(proj._project.get_provides.first.version).to eq("#{operator} 1.2.3")261 end262 end263 it 'supports versioned provides' do264 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])265 proj.instance_eval(project_block)266 proj.provides('thing1', '1.2.3')267 expect(proj._project.get_provides.count).to eq(1)268 expect(proj._project.get_provides.first.provide).to eq('thing1')269 expect(proj._project.get_provides.first.version).to eq('>= 1.2.3')270 end271 it 'gets rid of duplicates' do272 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])273 proj.instance_eval(project_block)274 proj.provides('thing1', '1.2.3')275 proj.provides('thing1', '>=1.2.3')276 expect(proj._project.get_provides.count).to eq(1)277 expect(proj._project.get_provides.first.provide).to eq('thing1')278 expect(proj._project.get_provides.first.version).to eq('>= 1.2.3')279 end280 end281 describe "#replaces" do282 before do283 allow_any_instance_of(Vanagon::Project::DSL).to receive(:puts)284 @el_plat = Vanagon::Platform::DSL.new('el-6-x86_64')285 @el_plat.instance_eval("platform 'el-6-x86_64' do |plat| end")286 @deb_plat = Vanagon::Platform::DSL.new('ubuntu-18.04-amd64')287 @deb_plat.instance_eval("platform 'ubuntu-18.04-amd64' do |plat| end")288 end289 it 'adds the package replacement to the list of replacements' do290 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)291 proj.instance_eval(project_block)292 proj.replaces('thing1')293 proj.replaces('thing2')294 expect(proj._project.get_replaces.count).to eq(2)295 expect(proj._project.get_replaces.first.replacement).to eq('thing1')296 expect(proj._project.get_replaces.last.replacement).to eq('thing2')297 end298 it 'supports versioned replaces' do299 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])300 proj.instance_eval(project_block)301 proj.replaces('thing1', '1.2.3')302 expect(proj._project.get_replaces.count).to eq(1)303 expect(proj._project.get_replaces.first.replacement).to eq('thing1')304 expect(proj._project.get_replaces.first.version).to eq('< 1.2.3')305 end306 it 'supports deb versioned replaces' do307 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @deb_plat._platform, [])308 proj.instance_eval(project_block)309 proj.replaces('thing1', '1.2.3')310 expect(proj._project.get_replaces.count).to eq(1)311 expect(proj._project.get_replaces.first.replacement).to eq('thing1')312 expect(proj._project.get_replaces.first.version).to eq('<< 1.2.3')313 end314 it 'munges deb* versions' do315 operators = {316 '<' => '<<',317 '>' => '>>',318 '<=' => '<=',319 '>=' => '>=',320 '=' => '='321 }322 operators.each do |initial, munged|323 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @deb_plat._platform, [])324 proj.instance_eval(project_block)325 proj.replaces('thing1', "#{initial}1.2.3")326 expect(proj._project.get_replaces.count).to eq(1)327 expect(proj._project.get_replaces.first.replacement).to eq('thing1')328 expect(proj._project.get_replaces.first.version).to eq("#{munged} 1.2.3")329 end330 end331 it 'adds whitespace for rpm versions' do332 operators=['<','>','<=','>=','=']333 operators.each do |operator|334 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])335 proj.instance_eval(project_block)336 proj.replaces('thing1', "#{operator}1.2.3")337 expect(proj._project.get_replaces.count).to eq(1)338 expect(proj._project.get_replaces.first.replacement).to eq('thing1')339 expect(proj._project.get_replaces.first.version).to eq("#{operator} 1.2.3")340 end341 end342 it 'gets rid of duplicates' do343 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])344 proj.instance_eval(project_block)345 proj.replaces('thing1', '1.2.3')346 proj.replaces('thing1', '<1.2.3')347 expect(proj._project.get_replaces.count).to eq(1)348 expect(proj._project.get_replaces.first.replacement).to eq('thing1')349 expect(proj._project.get_replaces.first.version).to eq('< 1.2.3')350 end351 end352 describe "#conflicts" do353 before do354 allow_any_instance_of(Vanagon::Project::DSL).to receive(:puts)355 @el_plat = Vanagon::Platform::DSL.new('el-6-x86_64')356 @el_plat.instance_eval("platform 'el-6-x86_64' do |plat| end")357 @deb_plat = Vanagon::Platform::DSL.new('ubuntu-18.04-amd64')358 @deb_plat.instance_eval("platform 'ubuntu-18.04-amd64' do |plat| end")359 end360 it 'adds the package conflict to the list of conflicts' do361 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform)362 proj.instance_eval(project_block)363 proj.conflicts('thing1')364 proj.conflicts('thing2')365 expect(proj._project.get_conflicts.count).to eq(2)366 expect(proj._project.get_conflicts.first.pkgname).to eq('thing1')367 expect(proj._project.get_conflicts.last.pkgname).to eq('thing2')368 end369 it 'supports versioned conflicts' do370 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])371 proj.instance_eval(project_block)372 proj.conflicts('thing1', '1.2.3')373 expect(proj._project.get_conflicts.count).to eq(1)374 expect(proj._project.get_conflicts.first.pkgname).to eq('thing1')375 expect(proj._project.get_conflicts.first.version).to eq('< 1.2.3')376 end377 it 'supports deb versioned conflicts' do378 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @deb_plat._platform, [])379 proj.instance_eval(project_block)380 proj.conflicts('thing1', '1.2.3')381 expect(proj._project.get_conflicts.count).to eq(1)382 expect(proj._project.get_conflicts.first.pkgname).to eq('thing1')383 expect(proj._project.get_conflicts.first.version).to eq('<< 1.2.3')384 end385 it 'munges deb* versions' do386 operators = {387 '<' => '<<',388 '>' => '>>',389 '<=' => '<=',390 '>=' => '>=',391 '=' => '='392 }393 operators.each do |initial, munged|394 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @deb_plat._platform, [])395 proj.instance_eval(project_block)396 proj.conflicts('thing1', "#{initial}1.2.3")397 expect(proj._project.get_conflicts.count).to eq(1)398 expect(proj._project.get_conflicts.first.pkgname).to eq('thing1')399 expect(proj._project.get_conflicts.first.version).to eq("#{munged} 1.2.3")400 end401 end402 it 'adds whitespace for rpm versions' do403 operators=['<','>','<=','>=','=']404 operators.each do |operator|405 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])406 proj.instance_eval(project_block)407 proj.conflicts('thing1', "#{operator}1.2.3")408 expect(proj._project.get_conflicts.count).to eq(1)409 expect(proj._project.get_conflicts.first.pkgname).to eq('thing1')410 expect(proj._project.get_conflicts.first.version).to eq("#{operator} 1.2.3")411 end412 end413 it 'gets rid of duplicates' do414 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])415 proj.instance_eval(project_block)416 proj.conflicts('thing1', '1.2.3')417 proj.conflicts('thing1', '<1.2.3')418 expect(proj._project.get_conflicts.count).to eq(1)419 expect(proj._project.get_conflicts.first.pkgname).to eq('thing1')420 expect(proj._project.get_conflicts.first.version).to eq('< 1.2.3')421 end422 end423 describe "#package_override" do424 let(:project_block) {425"project 'test-fixture' do |proj|426 proj.package_override \"TEST_VAR='foo'\"427end"428 }429 before do430 allow_any_instance_of(Vanagon::Project::DSL).to receive(:puts)431 @el_plat = Vanagon::Platform::DSL.new('el-6-x86_64')432 @el_plat.instance_eval("platform 'el-6-x86_64' do |plat| end")433 @osx_plat = Vanagon::Platform::DSL.new('osx-10.10-x86_64')434 @osx_plat.instance_eval("platform 'osx-10.10-x86_64' do |plat| end")435 end436 it 'adds package_overrides on supported platforms' do437 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @el_plat._platform, [])438 proj.instance_eval(project_block)439 expect(proj._project.package_overrides).to include("TEST_VAR='foo'")440 end441 it 'fails on usupported platforms' do442 proj = Vanagon::Project::DSL.new('test-fixture', configdir, @osx_plat._platform, [])443 expect{ proj.instance_eval(project_block) }.to raise_error(RuntimeError)444 end445 end446 describe "#component" do447 let(:project_block) {448"project 'test-fixture' do |proj|449 proj.component 'some-component'450end"451 }452 let(:component) { double(Vanagon::Component) }453 before do454 allow_any_instance_of(Vanagon::Project::DSL).to receive(:puts)455 allow(Vanagon::Component).to receive(:load_component).with('some-component', any_args).and_return(component)456 end457 it 'stores the component in the project if the included components set is empty' do458 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform, [])459 proj.instance_eval(project_block)460 expect(proj._project.components).to include(component)461 end462 it 'stores the component in the project if the component name is listed in the included components set' do463 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform, ['some-component'])464 proj.instance_eval(project_block)465 expect(proj._project.components).to include(component)466 end467 it 'does not store the component if the included components set is not empty and does not include the component name' do468 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform, ['some-different-component'])469 proj.instance_eval(project_block)470 expect(proj._project.components).to_not include(component)471 end472 end473 describe "#fetch_artifact" do474 let(:project_block) {475 "project 'test-fixture' do |proj|476 proj.fetch_artifact 'foo/bar/baz.file'477 end"478 }479 let(:project_block_multiple) {480 "project 'test-fixture' do |proj|481 proj.fetch_artifact 'foo/bar/baz.file'482 proj.fetch_artifact 'foo/foobar/foobarbaz.file'483 end"484 }485 let(:empty_project_block) {486 "project 'test-fixture' do |proj|487 end"488 }489 it 'has an empty project.fetch_artifact when fetch_artifact is not called' do490 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform, [])491 proj.instance_eval(empty_project_block)492 expect(proj._project.artifacts_to_fetch).to eq([])493 end494 it 'Adds a path to project.fetch_artifact when fetch_artifact is called' do495 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform, [])496 proj.instance_eval(project_block)497 expect(proj._project.artifacts_to_fetch).to eq(['foo/bar/baz.file'])498 end499 it 'Adds multiple paths to project.fetch_artifact when fetch_artifact is called more than once' do500 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform, [])501 proj.instance_eval(project_block_multiple)502 expect(proj._project.artifacts_to_fetch).to eq(['foo/bar/baz.file', 'foo/foobar/foobarbaz.file'])503 end504 end505 describe "#no_packaging" do506 let(:project_block) {507 "project 'test-fixture' do |proj|508 proj.no_packaging true509 end"510 }511 let(:project_block_false) {512 "project 'test-fixture' do |proj|513 proj.no_packaging false514 end"515 }516 let(:empty_project_block) {517 "project 'test-fixture' do |proj|518 end"519 }520 it 'has no_packaging set to false by default' do521 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform, [])522 proj.instance_eval(empty_project_block)523 expect(proj._project.no_packaging).to eq(false)524 end525 it 'sets no_packaging to true when proj.no_packaging true is called' do526 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform, [])527 proj.instance_eval(project_block)528 expect(proj._project.no_packaging).to eq(true)529 end530 it 'sets no_packaging to false when proj.no_packaging false is called' do531 proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform, [])532 proj.instance_eval(project_block_false)533 expect(proj._project.no_packaging).to eq(false)534 end535 end536end...

Full Screen

Full Screen

job_spec.rb

Source:job_spec.rb Github

copy

Full Screen

2require 'bako/dsl'3require 'bako/dsl/context'4require 'bako/dsl/context/job_definition'5RSpec.describe Bako::DSL::Context::Job do6 let(:hello_fixture) { File.read(fixture_root.join('hello.rb')) }7 let(:hello_result) {8 Bako::DSL.parse(hello_fixture).result[:jobs]['hello']9 }10 let(:missing_def_fixture) { File.read(fixture_root.join('missing_def.rb')) }11 let(:missing_queue_fixture) { File.read(fixture_root.join('missing_queue.rb')) }12 let(:command_fixture) { File.read(fixture_root.join('command.rb')) }13 let(:command_result_space) {14 Bako::DSL.parse(command_fixture).result[:jobs]['command_space']15 }16 let(:command_result_int) {17 Bako::DSL.parse(command_fixture).result[:jobs]['command_int']18 }19 it 'can parse job context' do20 expect(hello_result.name).to eq('hello')21 expect(hello_result.result[:command]).to eq (['echo', 'hello'])22 expect(hello_result.result[:memory]).to eq (256)23 expect(hello_result.result[:vcpus]).to eq (4)24 end25 it 'raise when missing required params' do26 expect{Bako::DSL.parse(missing_def_fixture)}.to raise_error(Bako::InvalidArgumentError)27 expect{Bako::DSL.parse(missing_queue_fixture)}.to raise_error(Bako::InvalidArgumentError)28 end29 it 'can parse job commands' do30 expect(command_result_space.result[:command]).to eq(['echo', 'hello'])31 expect(command_result_int.result[:command]).to eq(['sleep', '10'])32 end33end

Full Screen

Full Screen

fixture

Using AI Code Generation

copy

Full Screen

1 def fixture(name)2 assert_equal 'fixture1', dsl.instance_variable_get(:@fixtures).last3 assert_equal 'fixture2', dsl.instance_variable_get(:@fixtures).last4Test::Unit::UI::Console::TestRunner.run(DSLTest)5test_fixture(DSLTest) [1.rb:24]:

Full Screen

Full Screen

fixture

Using AI Code Generation

copy

Full Screen

1fixture.add_property(property)2add_fixture(fixture)3fixture.add_property(property)4add_fixture(fixture)5fixture.add_property(property)6add_fixture(fixture)7fixture.add_property(property)8add_fixture(fixture)9fixture.add_property(property)10add_fixture(fixture)

Full Screen

Full Screen

fixture

Using AI Code Generation

copy

Full Screen

1def get_fixture_file (name)2 fixture_path = fixture(name)3 File.open(fixture_path, 'r')4def get_fixture_file (name)5 fixture_path = fixture(name)6 File.open(fixture_path, 'r')7def get_fixture_file (name)8 fixture_path = fixture(name)9 File.open(fixture_path, 'r')10def get_fixture_file (name)11 fixture_path = fixture(name)12 File.open(fixture_path, 'r')13def get_fixture_file (name)14 fixture_path = fixture(name)15 File.open(fixture_path, 'r')16def get_fixture_file (name)17 fixture_path = fixture(name)18 File.open(fixture_path, 'r')19def get_fixture_file (name)20 fixture_path = fixture(name)21 File.open(fixture_path, 'r')22def get_fixture_file (name)23 fixture_path = fixture(name)24 File.open(fixture_path, 'r')

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Test-prof_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful