Sha256: e22efb33f822056292cf81f0cd274b390f66feef6443a46ac7afc22773cdaf6d

Contents?: true

Size: 719 Bytes

Versions: 3

Compression:

Stored size: 719 Bytes

Contents

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

describe "AutoReload" do

  it "should autoreload" do
    # create a library
    library = Pathname.new('tmp/library.rb')
    library.write 'def foo; 1; end'

    # setup the autoreload
    autoreload(:interval => 1) do #, :verbose=>true)
      require "library"
    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
    library.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
    library.delete
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

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