Sha256: b6acbcfbf9de9cf0393c10a990fca5748810614d9d01cd9b0e2670d5b578d175

Contents?: true

Size: 1.69 KB

Versions: 14

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

class ClassMixedWithDSLHelpers
  include Beaker::DSL::Helpers
  include Beaker::DSL::Wrappers
  include Beaker::DSL::Roles
  include Beaker::DSL::Patterns

  def logger
    RSpec::Mocks::Double.new('logger').as_null_object
  end

end

describe ClassMixedWithDSLHelpers do

  def fetch_allows
    allow(subject).to receive( :logger ) { logger }
  end

  describe "#fetch_http_file" do
    let( :logger) { double("Beaker::Logger", :notify => nil , :debug => nil ) }

    before do
      fetch_allows
    end

    describe "given valid arguments" do

      it "returns its second and third arguments concatenated." do
        create_files(['destdir/name'])
        result = subject.fetch_http_file "http://beaker.tool", "name", "destdir"
        expect(result).to eq("destdir/name")
      end

    end

    describe 'given invalid arguments' do

      it 'chomps correctly when given a URL ending with a / character' do
        expect( subject ).to receive( :open ).with( 'http://beaker.tool/name', anything )
        subject.fetch_http_file( "http://beaker.tool/", "name", "destdir" )
      end

    end

  end

  describe "#fetch_http_dir" do
    let( :logger) { double("Beaker::Logger", :notify => nil , :debug => nil ) }
    let( :result) { double(:each_line => []) }

    before do
      fetch_allows
    end

    describe "given valid arguments" do

      it "returns basename of first argument concatenated to second." do
        expect(subject).to receive(:`).with(/^wget.*/).ordered { result }
        expect($?).to receive(:to_i).and_return(0)
        result = subject.fetch_http_dir "http://beaker.tool/beep", "destdir"
        expect(result).to eq("destdir/beep")
      end

    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
beaker-2.30.1 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.30.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.29.1 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.29.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.28.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.27.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.26.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.25.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.24.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.23.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.22.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.21.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.20.0 spec/beaker/dsl/helpers/web_helpers_spec.rb
beaker-2.19.0 spec/beaker/dsl/helpers/web_helpers_spec.rb