Skip to content

Commit

Permalink
Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
rymai committed Nov 20, 2013
1 parent 10a520f commit 4373212
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Guardfile
@@ -1,4 +1,4 @@
guard :rspec, bundler: false do
guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^spec/support/*}) { 'spec' }
Expand Down
13 changes: 8 additions & 5 deletions spec/lib/listen/change_spec.rb
Expand Up @@ -2,14 +2,14 @@

describe Listen::Change do
let(:change) { Listen::Change.new(listener) }
let(:listener) { double(Listen::Listener, options: {}) }
let(:listener) { double('Listen::Listener', options: {}) }
let(:listener_changes) { double("listener_changes") }
before {
listener.stub(:changes) { listener_changes }
}

describe "#change" do
let(:silencer) { double(Listen::Silencer, silenced?: false) }
let(:silencer) { double('Listen::Silencer', silenced?: false) }
before { Celluloid::Actor.stub(:[]).with(:listen_silencer) { silencer } }

context "file path" do
Expand All @@ -20,14 +20,16 @@
end

it "doesn't notify to listener if path is silenced" do
expect(silencer).to receive(:silenced?).with('file_path') { true }
# expect(silencer).to receive(:silenced?).with('file_path', 'File').and_return(true)
expect(silencer).to receive(:silenced?).and_return(true)
expect(listener_changes).to_not receive(:<<)

change.change('file_path', type: 'File', change: :modified)
end
end

context "with unknown change" do
let(:file) { double(Listen::File) }
let(:file) { double('Listen::File') }
before { Listen::File.stub(:new) { file } }

it "calls Listen::File#change" do
Expand All @@ -37,8 +39,9 @@
end

it "doesn't call Listen::File#change if path is silenced" do
expect(silencer).to receive(:silenced?).with('file_path') { true }
expect(silencer).to receive(:silenced?).with('file_path', 'File').and_return(true)
expect(Listen::File).to_not receive(:new)

change.change('file_path', type: 'File')
end

Expand Down
4 changes: 2 additions & 2 deletions spec/support/acceptance_helper.rb
@@ -1,9 +1,9 @@
def listen
sleep 0.25 # wait for changes
sleep 0.5 # wait for changes
sleep_until_next_second
reset_changes
yield
sleep 0.25 # wait for changes
sleep 0.5 # wait for changes
@changes
end

Expand Down

0 comments on commit 4373212

Please sign in to comment.