Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport #383 #385

Merged
merged 2 commits into from Apr 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/listen/listener.rb
Expand Up @@ -63,11 +63,11 @@ def initialize(*dirs, &block)

state :initializing, to: :backend_started

state :backend_started, to: [:frontend_ready] do
state :backend_started, to: [:frontend_ready, :stopped] do
backend.start
end

state :frontend_ready, to: [:processing_events] do
state :frontend_ready, to: [:processing_events, :stopped] do
processor.setup
end

Expand Down
53 changes: 35 additions & 18 deletions spec/lib/listen/listener_spec.rb
Expand Up @@ -137,13 +137,43 @@
allow(backend).to receive(:start)
allow(processor).to receive(:setup)
allow(processor).to receive(:resume)
subject.start
end

it 'terminates' do
allow(backend).to receive(:stop)
allow(processor).to receive(:teardown)
subject.stop
context 'when fully started' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

before do
subject.start
end

it 'terminates' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

allow(backend).to receive(:stop)
allow(processor).to receive(:teardown)
subject.stop
end
end

context 'when frontend is ready' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

before do
subject.transition :backend_started
subject.transition :frontend_ready
end

it 'terminates' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

allow(backend).to receive(:stop)
allow(processor).to receive(:teardown)
subject.stop
end
end

context 'when only backend is already started' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

before do
subject.transition :backend_started
end

it 'terminates' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

allow(backend).to receive(:stop)
allow(processor).to receive(:teardown)
subject.stop
end
end
end

Expand Down Expand Up @@ -304,17 +334,4 @@
end
end
end

describe 'processing changes' do
before do
allow(backend).to receive(:start)
end
end

context 'when listener is stopped' do
before do
subject.stop
allow(silencer).to receive(:silenced?) { true }
end
end
end