Permalink
Browse files

Add spec for BSD/kqueue.

  • Loading branch information...
1 parent 24b03d4 commit 0fc9c776f126e7a6d7f52a467e521ec0838357fa @mat813 mat813 committed Nov 1, 2012
@@ -21,6 +21,7 @@
before do
Listen::Adapters::Darwin.stub(:usable_and_works?) { false }
Listen::Adapters::Linux.stub(:usable_and_works?) { false }
+ Listen::Adapters::BSD.stub(:usable_and_works?) { false }
Listen::Adapters::Windows.stub(:usable_and_works?) { false }
end
@@ -40,6 +41,7 @@
before do
Listen::Adapters::Darwin.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
Listen::Adapters::Linux.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
+ Listen::Adapters::BSD.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
Listen::Adapters::Windows.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
end
@@ -96,6 +98,22 @@
end
end
+ context "on BSD" do
+ before { Listen::Adapters::BSD.stub(:usable_and_works?) { true } }
+
+ it "uses Listen::Adapters::BSD" do
+ Listen::Adapters::BSD.should_receive(:new).with('dir', {})
+ described_class.select_and_initialize('dir')
+ end
+
+ context 'when the use of the polling adapter is forced' do
+ it 'uses Listen::Adapters::Polling' do
+ Listen::Adapters::Polling.should_receive(:new).with('dir', {})
+ described_class.select_and_initialize('dir', :force_polling => true)
+ end
+ end
+ end
+
context "on Windows" do
before { Listen::Adapters::Windows.stub(:usable_and_works?) { true } }
@@ -113,7 +131,9 @@
end
end
- [Listen::Adapters::Darwin, Listen::Adapters::Linux, Listen::Adapters::Windows].each do |adapter_class|
+ [Listen::Adapters::Darwin, Listen::Adapters::Linux,
+ Listen::Adapters::BSD, Listen::Adapters::Windows].each do
+ |adapter_class|
if adapter_class.usable?
describe '.usable?' do
it 'checks the dependencies' do
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe Listen::Adapters::BSD do
+ if bsd?
+ if Listen::Adapters::BSD.usable?
+ it "is usable on BSD" do
+ described_class.should be_usable
+ end
+
+ it_should_behave_like 'a filesystem adapter'
+ it_should_behave_like 'an adapter that call properly listener#on_change'
+ else
+ it "isn't usable on BSD with #{RbConfig::CONFIG['RUBY_INSTALL_NAME']}" do
+ described_class.should_not be_usable
+ end
+ end
+ end
+
+ if linux?
+ it "isn't usable on Linux" do
+ described_class.should_not be_usable
+ end
+ end
+
+ if mac?
+ it "isn't usable on Mac OS X" do
+ described_class.should_not be_usable
+ end
+ end
+
+ if windows?
+ it "isn't usable on Windows" do
+ described_class.should_not be_usable
+ end
+ end
+end
@@ -28,4 +28,10 @@
described_class.should_not be_usable
end
end
+
+ if bsd?
+ it "isn't usable on BSD" do
+ described_class.should_not be_usable
+ end
+ end
end
@@ -27,6 +27,12 @@
end
end
+ if bsd?
+ it "isn't usable on BSD" do
+ described_class.should_not be_usable
+ end
+ end
+
if mac?
it "isn't usable on Mac OS X" do
described_class.should_not be_usable
@@ -16,6 +16,12 @@
end
end
+ if bsd?
+ it "isn't usable on BSD" do
+ described_class.should_not be_usable
+ end
+ end
+
if linux?
it "isn't usable on Linux" do
described_class.should_not be_usable
@@ -6,6 +6,10 @@ def linux?
RbConfig::CONFIG['target_os'] =~ /linux/i
end
+def bsd?
+ RbConfig::CONFIG['target_os'] =~ /freebsd/i
+end
+
def windows?
RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
end

0 comments on commit 0fc9c77

Please sign in to comment.