Sha256: 6dffb9681e853a14435b95419e05854daa63766eb790255157051c2d62cd77e6

Contents?: true

Size: 836 Bytes

Versions: 3

Compression:

Stored size: 836 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/helper')

describe "AutoReload" do

  it "should autoreload a require of a require" do
    library1 = Pathname.new('tmp/library1.rb')
    library2 = Pathname.new('tmp/library2.rb')

    library1.write "require 'library2'"
    library2.write "def foo; 1; end"

    # setup the autoreload
    autoreload(:interval => 1) do #, :verbose=>true)
      require "library1"
    end

    # check the number
    foo.must_equal 1

    # wait is needed for time stamp to not be same with the next file.
    sleep 2

    # recreate the file
    library2.write "def foo; 2; end"

    # wait again for the autoreload loop to repeat.
    sleep 2

    # check the number again
    foo.must_equal 2

    # clean up
    library2.delete
    library1.delete
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
autoreload-1.2.0 spec/require_spec.rb
autoreload-1.1.0 spec/require_spec.rb
autoreload-1.0.0 spec/require_spec.rb