|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative '../../../../../spec_helper' |
| 4 | +require 'wpxf/modules' |
| 5 | + |
| 6 | +describe Wpxf::Auxiliary::ImdbProfileWidgetArbitraryFileDownload do |
| 7 | + let(:subject) { described_class.new } |
| 8 | + |
| 9 | + before :each, 'setup subject' do |
| 10 | + allow(subject).to receive(:check_plugin_version_from_readme) |
| 11 | + allow(subject).to receive(:emit_error) |
| 12 | + end |
| 13 | + |
| 14 | + it 'should return a {Wpxf::Module}' do |
| 15 | + expect(subject).to be_a Wpxf::Module |
| 16 | + end |
| 17 | + |
| 18 | + it 'should check the plugin is < 1.0.9' do |
| 19 | + subject.check |
| 20 | + expect(subject).to have_received(:check_plugin_version_from_readme) |
| 21 | + .with('imdb-widget', '1.0.9') |
| 22 | + .exactly(1).times |
| 23 | + end |
| 24 | + |
| 25 | + it 'should not require authentication' do |
| 26 | + expect(subject.requires_authentication).to be false |
| 27 | + end |
| 28 | + |
| 29 | + it 'should configure a default remote file path' do |
| 30 | + expected = '../../../wp-config.php' |
| 31 | + expect(subject.default_remote_file_path).to eql expected |
| 32 | + end |
| 33 | + |
| 34 | + it 'should configure the working directory' do |
| 35 | + expected = 'wp-content/plugins/imdb-widget/' |
| 36 | + expect(subject.working_directory).to eql expected |
| 37 | + end |
| 38 | + |
| 39 | + it 'should configure the downloader url' do |
| 40 | + url_pattern = %r{plugins/imdb-widget/pic\.php$} |
| 41 | + expect(subject.downloader_url).to match(url_pattern) |
| 42 | + end |
| 43 | + |
| 44 | + it 'should configure the request params' do |
| 45 | + subject.set_option_value('remote_file', 'test.php') |
| 46 | + expect(subject.download_request_params).to eql('url' => 'test.php') |
| 47 | + end |
| 48 | + |
| 49 | + it 'should GET the download request' do |
| 50 | + expect(subject.download_request_method).to eql :get |
| 51 | + end |
| 52 | +end |
0 commit comments