@@ -306,7 +306,6 @@ def make_dummy_docs
306306 end
307307
308308 before do
309- skip "Skipped integration test" unless ENV [ "TOYS_TEST_INTEGRATION" ]
310309 fake_tool_context . prevent_real_exec_prefix ( [ "git" , "push" ] )
311310 end
312311
@@ -323,60 +322,64 @@ def make_dummy_docs
323322 assert_equal ( [ "custom_build" ] , ::Toys ::Release ::Steps ::PUSH_GH_PAGES . dependencies ( step_context ) )
324323 end
325324
326- it "aborts if docs exist" do
327- make_dummy_docs
328- step_context = make_context ( version : released_version )
329- assert_raises ( Toys ::Release ::Pipeline ::StepExit ) do
330- capture_subprocess_io do
331- ::Toys ::Release ::Steps ::PUSH_GH_PAGES . run ( step_context )
332- end
325+ describe "#run" do
326+ before do
327+ skip "Skipped integration test" unless ENV [ "TOYS_TEST_INTEGRATION" ]
328+ make_dummy_docs
333329 end
334- assert_equal ( 1 , @performer_result . successes . size )
335- assert_equal ( "Docs already published for toys #{ released_version } " , @performer_result . successes . first )
336- end
337330
338- it "does a dry run publish" do
339- make_dummy_docs
340- step_context = make_context ( dry_run : true )
341- capture_subprocess_io do
342- ::Toys ::Release ::Steps ::PUSH_GH_PAGES . run ( step_context )
343- end
344- assert_equal ( 1 , @performer_result . successes . size )
345- assert_equal ( "DRY RUN documentation published for toys #{ unreleased_version } ." , @performer_result . successes . first )
346- path = ::File . join ( step_context . temp_dir , "gems" , "toys" , "v#{ unreleased_version } " , "index.html" )
347- assert ( ::File . file? ( path ) , "Expected docs to be copied into gh-pages" )
348- content = ::File . read ( ::File . join ( step_context . temp_dir , "404.html" ) )
349- assert_includes ( content , "version_toys = #{ unreleased_version . inspect } ;" )
350- [ "index.html" , "latest/index.html" ] . each do |filename |
351- content = ::File . read ( ::File . join ( step_context . temp_dir , "gems" , "toys" , filename ) )
352- assert_includes ( content , "<a href=\" https://dazuma.github.io/toys/gems/toys/v#{ unreleased_version } \" >" )
353- assert_includes ( content , "<link rel=\" canonical\" href=\" https://dazuma.github.io/toys/gems/toys/v#{ unreleased_version } \" >" )
354- assert_includes ( content , "<meta http-equiv=\" refresh\" content=\" 0; url=https://dazuma.github.io/toys/gems/toys/v#{ unreleased_version } \" >" )
355- assert_includes ( content , "window.location.replace(\" https://dazuma.github.io/toys/gems/toys/v#{ unreleased_version } \" );" )
331+ it "aborts if docs exist" do
332+ step_context = make_context ( version : released_version )
333+ assert_raises ( Toys ::Release ::Pipeline ::StepExit ) do
334+ capture_subprocess_io do
335+ ::Toys ::Release ::Steps ::PUSH_GH_PAGES . run ( step_context )
336+ end
337+ end
338+ assert_equal ( 1 , @performer_result . successes . size )
339+ assert_equal ( "Docs already published for toys #{ released_version } " , @performer_result . successes . first )
356340 end
357- end
358341
359- it "does a real publish" do
360- make_dummy_docs
361- step_context = make_context ( dry_run : false )
362- fake_tool_context . stub_exec ( [ "git" , "push" , "origin" , "gh-pages" ] )
363- capture_subprocess_io do
364- ::Toys ::Release ::Steps ::PUSH_GH_PAGES . run ( step_context )
342+ it "does a dry run publish" do
343+ step_context = make_context ( dry_run : true )
344+ capture_subprocess_io do
345+ ::Toys ::Release ::Steps ::PUSH_GH_PAGES . run ( step_context )
346+ end
347+ assert_equal ( 1 , @performer_result . successes . size )
348+ assert_equal ( "DRY RUN documentation published for toys #{ unreleased_version } ." ,
349+ @performer_result . successes . first )
350+ path = ::File . join ( step_context . temp_dir , "gems" , "toys" , "v#{ unreleased_version } " , "index.html" )
351+ assert ( ::File . file? ( path ) , "Expected docs to be copied into gh-pages" )
352+ content = ::File . read ( ::File . join ( step_context . temp_dir , "404.html" ) )
353+ assert_includes ( content , "version_toys = #{ unreleased_version . inspect } ;" )
354+ [ "index.html" , "latest/index.html" ] . each do |filename |
355+ content = ::File . read ( ::File . join ( step_context . temp_dir , "gems" , "toys" , filename ) )
356+ assert_includes ( content , "<a href=\" https://dazuma.github.io/toys/gems/toys/v#{ unreleased_version } \" >" )
357+ assert_includes ( content , "<link rel=\" canonical\" href=\" https://dazuma.github.io/toys/gems/toys/v#{ unreleased_version } \" >" )
358+ assert_includes ( content , "<meta http-equiv=\" refresh\" content=\" 0; url=https://dazuma.github.io/toys/gems/toys/v#{ unreleased_version } \" >" )
359+ assert_includes ( content , "window.location.replace(\" https://dazuma.github.io/toys/gems/toys/v#{ unreleased_version } \" );" )
360+ end
365361 end
366- assert_equal ( 1 , @performer_result . successes . size )
367- assert_equal ( "Published documentation for toys #{ unreleased_version } ." , @performer_result . successes . first )
368- end
369362
370- it "fails to publish" do
371- make_dummy_docs
372- step_context = make_context ( dry_run : false )
373- fake_tool_context . stub_exec ( [ "git" , "push" , "origin" , "gh-pages" ] , result_code : 1 )
374- assert_raises ( Toys ::Release ::Pipeline ::PipelineExit ) do
363+ it "does a real publish" do
364+ step_context = make_context ( dry_run : false )
365+ fake_tool_context . stub_exec ( [ "git" , "push" , "origin" , "gh-pages" ] )
375366 capture_subprocess_io do
376367 ::Toys ::Release ::Steps ::PUSH_GH_PAGES . run ( step_context )
377368 end
369+ assert_equal ( 1 , @performer_result . successes . size )
370+ assert_equal ( "Published documentation for toys #{ unreleased_version } ." , @performer_result . successes . first )
371+ end
372+
373+ it "fails to publish" do
374+ step_context = make_context ( dry_run : false )
375+ fake_tool_context . stub_exec ( [ "git" , "push" , "origin" , "gh-pages" ] , result_code : 1 )
376+ assert_raises ( Toys ::Release ::Pipeline ::PipelineExit ) do
377+ capture_subprocess_io do
378+ ::Toys ::Release ::Steps ::PUSH_GH_PAGES . run ( step_context )
379+ end
380+ end
381+ assert_empty ( @performer_result . successes )
378382 end
379- assert_empty ( @performer_result . successes )
380383 end
381384 end
382385
0 commit comments