# frozen_string_literal: true
require_relative 'spec_helper'
module Danger
describe Danger::ViewChangesChecker do
it 'is a plugin' do
expect(described_class.new(nil)).to be_a Danger::Plugin
end
shared_examples 'PR with view code changes' do |modified_files|
before do
allow(@plugin.git).to receive(:modified_files).and_return(modified_files)
end
it 'warns when a PR with view code changes does not have screenshots' do
allow(@plugin.github).to receive(:pr_body).and_return('PR Body')
@plugin.check
expect(@dangerfile).to report_warnings([ViewChangesChecker::MESSAGE])
end
it 'does nothing when a PR with view code changes has screenshots defined in markdown' do
allow(@plugin.github).to receive(:pr_body)
.and_return('PR [![Alt text](https://myimages.com/boo)](https://digitalocean.com) Body')
@plugin.check
expect(@dangerfile).to not_report
end
it 'does nothing when a PR with view code changes has url to screenshots' do
allow(@plugin.github).to receive(:pr_body)
.and_return('see secreenshot Body')
@plugin.check
expect(@dangerfile).to not_report
end
it 'does nothing when a PR with view code changes has a screenshot defined with a html tag with different attributes before src' do
allow(@plugin.github).to receive(:pr_body)
.and_return("see screenshot:\n body body")
@plugin.check
expect(@dangerfile).to not_report
end
it 'does nothing when a PR with view code changes has a screenshot defined with a html tag' do
allow(@plugin.github).to receive(:pr_body)
.and_return("see screenshot:\n body body")
@plugin.check
expect(@dangerfile).to not_report
end
it 'does nothing when a PR with view code changes has a video defined with a html tag with different attributes before src' do
allow(@plugin.github).to receive(:pr_body)
.and_return("see video:\n