Skip to content

Instantly share code, notes, and snippets.

@costa
Created June 29, 2024 14:23
Show Gist options
  • Save costa/84b7dd4ec709350a308e3e5ba0305dc9 to your computer and use it in GitHub Desktop.
Save costa/84b7dd4ec709350a308e3e5ba0305dc9 to your computer and use it in GitHub Desktop.
vlog-youtuber's formal specification (with RSpec, excerpt)
# ...definitions...
describe "Automated publishing" do
# ...setup...
it "should happen whenever .pub.video is comitted to 'log' git repo" do
expect((channel_ids = api_get).length).to eq 1
expect(youtube_channel_url = api_get(channel_ids[0])[:pub_url].to_s).not_to be_empty
Dir.chdir LOG_PROJ_DIR do
sample_pub_video_path = File.join(TODAY_DATE_PATH, 'chang-wash-fun.pub.video')
sample_pub_ffmprb_path = File.join(TODAY_DATE_PATH, 'chang-wash-fun.pub.ffmprb')
sample_pub_video_text =
<<EOF
Chang Wash Fun, winter 2022, Chiang Mai, Thailand
src:
- media/#{SAMPLE_MEDIA_PATH}: https://icloud.com/photos
pub:
Hapless Tourists Washing Elephants in Thailand - this could be you if you weren't careful and didn't stay home instead!
#chiangmai, thailand, 2022, live
- #{youtube_channel_url}
EOF
sample_pub_video_ffmprb =
<<EOF
|o|
i = input('#{File.join MEDIA_DIR, SAMPLE_MEDIA_PATH}')
output o do
lay i
end
EOF
File.write sample_pub_video_path, sample_pub_video_text
File.write sample_pub_ffmprb_path, sample_pub_video_ffmprb
git! 'add .'
git! 'commit -m "another video FROM PARADISE for my friends and family to enjoy"'
expect(video_youtube_url =
ask("Do you see your new (Chang) video published? What's its YouTube URL? [...]")
).not_to be_empty
expect(File.read sample_pub_video_path).to eq sample_pub_video_text.sub(youtube_channel_url, video_youtube_url)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment