Skip to content

Please teach me how to monitoring unit test #49

Description

@onigra

Sorry, my english is terrible.

I want to monitoring test in rspec.
i tried below, but "create!" doesn't puts stdout.
Please teach me something wrong point.

Thanks.

https://github.com/onigra/fssm_test

# test.rb

require 'fssm'

module Foo
  def self.run
    FSSM.monitor(File.expand_path("./lib/tmp"), "**/*") do
      create { |monitoring_dir, new_file| puts "create!" }
    end
  end
end

# Foo.run
# test_spec.rb

require 'spec_helper'

describe Foo do
  before :all do
    @path = File.expand_path("./lib/tmp")
    @pid = fork { Foo.run }
  end

  after :all do
    Process.kill "KILL", @pid
    File.delete "#{@path}/file"
  end

  describe ".run" do
    it "puts create!" do
      FileUtils.touch "#{@path}/file"
    end
  end
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions