rubypath 0.3.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Path do
4
- describe 'Path Predicates' do
5
- describe '#absolute?' do
6
- subject { Path(path).absolute? }
7
-
8
- context 'with absolute path' do
9
- let(:path) { '/abs/path/to/file' }
10
- it { should be true }
11
- end
12
-
13
- context 'with relative path' do
14
- let(:path) { 'path/to/file' }
15
- it { should be false }
16
- end
17
- end
18
-
19
- describe '#relative?' do
20
- subject { Path(path).relative? }
21
-
22
- context 'with absolute path' do
23
- let(:path) { '/abs/path/to/file' }
24
- it { should be false }
25
- end
26
-
27
- context 'with relative path' do
28
- let(:path) { 'path/to/file' }
29
- it { should be true }
30
- end
31
- end
32
-
33
- describe '#mountpoint?' do
34
- let(:path) { Path('/tmp') }
35
-
36
- context 'without args' do
37
- it 'should invoke backend with current path' do
38
- expect(Path::Backend.instance).to receive(:mountpoint?).with('/tmp').and_return(false)
39
- path.mountpoint?
40
- end
41
- end
42
-
43
- context 'with args' do
44
- it 'should invoke backend with joined path' do
45
- expect(Path::Backend.instance).to receive(:mountpoint?).with('/tmp/fuu').and_return(false)
46
- path.mountpoint?('fuu')
47
- end
48
- end
49
- end
50
-
51
- describe_method :dotfile? do
52
- subject { path.dotfile? }
53
-
54
- context 'with dotfile' do
55
- let(:path) { Path '.abc' }
56
- it { should be true }
57
- end
58
-
59
- context 'with path to dotfile' do
60
- let(:path) { Path '/apth/to/.abc' }
61
- it { should be true }
62
- end
63
-
64
- context 'with normal file' do
65
- let(:path) { Path '/path/to/file' }
66
- it { should be false }
67
- end
68
-
69
- context 'with path to file within a dotdir' do
70
- let(:path) { Path '/home/user/.local/file' }
71
- it { should be false }
72
- end
73
- end
74
- end
75
- end
@@ -1,42 +0,0 @@
1
- require 'rspec'
2
-
3
- if ENV['CI'] || (defined?(:RUBY_ENGINE) && RUBY_ENGINE != 'rbx')
4
- require 'coveralls'
5
- Coveralls.wear! do
6
- add_filter 'spec'
7
- end
8
- end
9
-
10
- require 'bundler'
11
- Bundler.require :default, :test
12
-
13
- require 'rubypath'
14
-
15
- Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f}
16
-
17
- RSpec.configure do |config|
18
- # ## Mock Framework
19
- #
20
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
21
- #
22
- # config.mock_with :mocha
23
- # config.mock_with :flexmock
24
- # config.mock_with :rr
25
-
26
- # Run specs in random order to surface order dependencies. If you find an
27
- # order dependency and want to debug it, you can fix the order by providing
28
- # the seed, which is printed after each run.
29
- # --seed 1234
30
- config.order = 'random'
31
-
32
- # Raise error when using old :should expectation syntax.
33
- config.raise_errors_for_deprecations!
34
-
35
- config.around(:each) do |example|
36
- Path::Backend.mock root: :tmp, &example
37
- end
38
-
39
- config.after do
40
- Timecop.return
41
- end
42
- end
@@ -1,18 +0,0 @@
1
- module DescribeMethod
2
- def describe_aliases(*args, &block)
3
- args.each do |mth|
4
- name = (mth == args.first ? "##{mth}" : "##{mth} (alias of #{args.first})")
5
-
6
- describe(name) do
7
- let(:described_method) { mth }
8
- module_eval &block
9
- end
10
- end
11
- end
12
-
13
- def describe_method(mth, opts = {}, &block)
14
- describe_aliases *([mth] + (opts[:aliases] || []).to_ary), &block
15
- end
16
-
17
- RSpec.configure{|c| c.extend DescribeMethod }
18
- end
@@ -1,37 +0,0 @@
1
- #
2
- module WithBackend
3
- def with_backends(*args, &block)
4
- args.each do |backend|
5
- be = case backend
6
- when :mock
7
- ->(ex){ Path::Backend.mock(&ex) }
8
- when :sys
9
- ->(ex){ Path::Backend.mock(root: :tmp, &ex) }
10
- else
11
- raise ArgumentError.new 'Unknown backend.'
12
- end
13
-
14
- next if ENV["FS_#{backend.upcase}"] == '0'
15
-
16
- describe "with #{backend.upcase} FS" do
17
- let(:backend_type) { backend }
18
- around do |example|
19
- be.call(example)
20
- end
21
-
22
- module_eval(&block)
23
- end
24
- end
25
- end
26
- alias_method :with_backend, :with_backends
27
-
28
- def pending_backend(*args)
29
- before do
30
- if args.include? backend_type
31
- pending "Pending on #{backend_type} backend."
32
- end
33
- end
34
- end
35
-
36
- RSpec.configure{ |c| c.extend WithBackend }
37
- end