Skip to content

Commit

Permalink
Fix specs and ensure we reset lazy accessors on Guard.setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rymai committed Sep 18, 2013
1 parent 81344d6 commit 9a9deeb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/guard/setuper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module Setuper
# @return [Guard] the Guard singleton
#
def setup(opts = {})
_reset_lazy_accessors
@running = true
@lock = Mutex.new
@opts = opts
Expand Down Expand Up @@ -139,6 +140,11 @@ def evaluate_guardfile

private

def _reset_lazy_accessors
@options = nil
@evaluator = nil
end

# Sets up various debug behaviors:
#
# * Abort threads on exception;
Expand Down
9 changes: 6 additions & 3 deletions spec/guard/setuper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
expect(subject.groups[0].options).to eq({})
end

it "initializes the options" do
it 'lazily initializes the options' do
expect(subject.options.my_opts).to be_true
end

it 'lazily initializes the evaluator' do
expect(subject.evaluator).to be_kind_of(Guard::Guardfile::Evaluator)
end

it "initializes the listener" do
expect(subject.listener).to be_kind_of(Listen::Listener)
end
Expand All @@ -54,8 +58,7 @@
subject
end

it 'create the evaluator and evaluate the Guardfile' do
expect(Guard::Guardfile::Evaluator).to receive(:new).with(options)
it 'evaluates the Guardfile' do
expect(Guard).to receive(:evaluate_guardfile)

subject
Expand Down

0 comments on commit 9a9deeb

Please sign in to comment.