file-spec 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require 'psych'
2
+
1
3
  begin
2
4
  require 'jeweler'
3
5
  Jeweler::Tasks.new do |gem|
@@ -7,10 +9,9 @@ begin
7
9
  gem.email = "kmandrup@gmail.com"
8
10
  gem.homepage = "http://github.com/kristianmandrup/file-spec"
9
11
  gem.authors = ["Kristian Mandrup"]
10
- gem.add_development_dependency "rspec", ">= 2.0.1"
11
-
12
- gem.add_dependency "rspec", ">= 2.0.1"
12
+ gem.add_dependency "rspec", ">= 2.4.1"
13
13
  gem.add_dependency "require_all", "~> 1.2.0"
14
+ gem.add_dependency "sugar-high", "~> 0.3.7"
14
15
  gem.add_dependency "activesupport", ">= 3.0.1"
15
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
17
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/file-spec.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{file-spec}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2010-11-28}
12
+ s.date = %q{2011-03-01}
13
13
  s.description = %q{RSpec 2 matchers for files, directories and symlinks}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  ]
44
44
  s.homepage = %q{http://github.com/kristianmandrup/file-spec}
45
45
  s.require_paths = ["lib"]
46
- s.rubygems_version = %q{1.3.7}
46
+ s.rubygems_version = %q{1.5.3}
47
47
  s.summary = %q{RSpec 2 matchers for files, directories and symlinks}
48
48
  s.test_files = [
49
49
  "spec/file-spec/matchers/multiple/have_directories_spec.rb",
@@ -56,24 +56,23 @@ Gem::Specification.new do |s|
56
56
  ]
57
57
 
58
58
  if s.respond_to? :specification_version then
59
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
60
59
  s.specification_version = 3
61
60
 
62
61
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
- s.add_development_dependency(%q<rspec>, [">= 2.0.1"])
64
- s.add_runtime_dependency(%q<rspec>, [">= 2.0.1"])
62
+ s.add_runtime_dependency(%q<rspec>, [">= 2.4.1"])
65
63
  s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
64
+ s.add_runtime_dependency(%q<sugar-high>, ["~> 0.3.7"])
66
65
  s.add_runtime_dependency(%q<activesupport>, [">= 3.0.1"])
67
66
  else
68
- s.add_dependency(%q<rspec>, [">= 2.0.1"])
69
- s.add_dependency(%q<rspec>, [">= 2.0.1"])
67
+ s.add_dependency(%q<rspec>, [">= 2.4.1"])
70
68
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
69
+ s.add_dependency(%q<sugar-high>, ["~> 0.3.7"])
71
70
  s.add_dependency(%q<activesupport>, [">= 3.0.1"])
72
71
  end
73
72
  else
74
- s.add_dependency(%q<rspec>, [">= 2.0.1"])
75
- s.add_dependency(%q<rspec>, [">= 2.0.1"])
73
+ s.add_dependency(%q<rspec>, [">= 2.4.1"])
76
74
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
75
+ s.add_dependency(%q<sugar-high>, ["~> 0.3.7"])
77
76
  s.add_dependency(%q<activesupport>, [">= 3.0.1"])
78
77
  end
79
78
  end
data/lib/file-spec.rb CHANGED
@@ -3,6 +3,7 @@ require 'require_all'
3
3
  require 'fileutils'
4
4
  require 'tmpdir'
5
5
  require 'active_support/inflector'
6
+ require 'sugar-high'
6
7
 
7
8
  module RSpec
8
9
  module FileMatchers
@@ -12,6 +12,10 @@ module FileHelper
12
12
  def test_dirs
13
13
  [test_dir, test_dir2]
14
14
  end
15
+
16
+ def nested_test_dirs
17
+ ['nested1', 'nested2']
18
+ end
15
19
  end
16
20
 
17
21
  module Make
@@ -27,10 +31,15 @@ module FileHelper
27
31
  test_dirs.each{|dir| make_dir dir}
28
32
  end
29
33
 
34
+ def make_nested_dirs
35
+ nested_test_dirs.each{|dir| make_dir dir}
36
+ end
37
+
38
+
30
39
  def make_nested_test_dirs
31
40
  make_test_dir
32
41
  FileUtils.chdir test_dir do
33
- make_test_dirs
42
+ make_nested_dirs
34
43
  make_test_files
35
44
  end
36
45
  end
@@ -16,6 +16,8 @@ module RSpec::FileMatchers
16
16
 
17
17
  loc = if args.size > 1
18
18
  dir, name = *args
19
+ dir = dir.kind_of?(Dir) ? dir.path : dir
20
+ name = name.kind_of?(File) ? name.path : name
19
21
  File.join(dir.to_s, name.to_s)
20
22
  else
21
23
  args[0].to_s
@@ -24,9 +26,12 @@ module RSpec::FileMatchers
24
26
 
25
27
  def matches? relative_path, &block
26
28
  case relative_path
27
- when File, Dir
29
+ when File
28
30
  @location = relative_path if !@location
29
31
  Dir.chdir File.dirname(location)
32
+ when Dir
33
+ @location = relative_path if !@location
34
+ Dir.chdir location
30
35
  when String
31
36
  if File.exist?(relative_path)
32
37
  @location = relative_path if !@location
@@ -49,8 +54,9 @@ module RSpec::FileMatchers
49
54
  if block && match
50
55
  case artifact
51
56
  when :directory
57
+ dir = location # Dir.new(location).path
52
58
  Dir.chdir location do
53
- yield Dir.new(location)
59
+ yield dir
54
60
  end
55
61
  when :file
56
62
  yield File.new(location)
@@ -1,3 +1,5 @@
1
+ require 'sugar-high/kind_of'
2
+
1
3
  module RSpec::FileMatchers
2
4
  class HaveFileItems
3
5
  attr_accessor :file_items, :location, :symlink_type
@@ -8,24 +10,27 @@ module RSpec::FileMatchers
8
10
  when Hash
9
11
  self.symlink_type = items.last[:type]
10
12
  end
11
- self.file_items = items.select{|item| !item.kind_of? Hash}
13
+ self.file_items = items.select{|item| !item.kind_of? Hash}.map {|f| f.any_kind_of?(File, Dir) ? f.path : f }
12
14
  end
13
15
 
14
16
  def matches? relative_path=nil, &block
15
17
  case relative_path
16
- when File, Dir
18
+ when File
17
19
  full_path = File.expand_path(relative_path.path)
18
20
  @location = File.dirname(full_path) if !@location
21
+ when Dir
22
+ full_path = File.expand_path(relative_path.path)
23
+ @location = full_path if !@location
19
24
  when String
20
25
  begin
21
- full_path = File.expand_path(relative_path)
26
+ full_path = File.expand_path(relative_path)
22
27
  if File.directory?(full_path)
23
28
  @location = full_path if !@location
24
29
  end
25
30
  rescue
26
31
  raise ArgumentError, "The path string #{relative_path} could not be resolved to an existing directory on this filesystem."
27
32
  end
28
- end
33
+ end
29
34
 
30
35
  file_item_names.each do |loc|
31
36
  path = location ? File.join(location, loc) : loc
@@ -26,6 +26,12 @@ module RSpec::FileMatchers
26
26
  make_test_dirs
27
27
  Dir.pwd.should have_dirs test_dirs
28
28
  end
29
+
30
+ it "should have 'test' dirs in the current Dir" do
31
+ make_test_dirs
32
+ dir = Dir.new(Dir.pwd)
33
+ dir.should have_dirs test_dirs
34
+ end
29
35
  end
30
36
  end
31
37
  end
@@ -36,16 +36,19 @@ module RSpec::FileMatchers
36
36
  remove_all_test
37
37
  end
38
38
 
39
- after :each do
40
- remove_all_test
41
- end
39
+ # after :each do
40
+ # remove_all_test
41
+ # end
42
42
 
43
43
  it "should have nested test dirs" do
44
44
  make_nested_test_dirs
45
45
  nil.should have_dir :test
46
46
  nil.should_not have_dir :test2
47
47
  nil.should have_dir test_dir do |dir|
48
- dir.should have_dirs test_dirs
48
+ # puts "directory: #{dir.path}"
49
+ # puts "directory: #{dir}"
50
+ # puts File.expand_path(dir.path)
51
+ dir.should have_dirs nested_test_dirs
49
52
  dir.should have_files test_files
50
53
  end
51
54
  test_dir.should have_files test_files
metadata CHANGED
@@ -1,92 +1,69 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: file-spec
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 4
9
- version: 0.1.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Kristian Mandrup
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-11-28 00:00:00 +01:00
12
+ date: 2011-03-01 00:00:00.000000000 +01:00
18
13
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2157426200 !ruby/object:Gem::Requirement
24
18
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 0
31
- - 1
32
- version: 2.0.1
33
- type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rspec
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 2.4.1
23
+ type: :runtime
37
24
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2157426200
26
+ - !ruby/object:Gem::Dependency
27
+ name: require_all
28
+ requirement: &2157425620 !ruby/object:Gem::Requirement
39
29
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- segments:
44
- - 2
45
- - 0
46
- - 1
47
- version: 2.0.1
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
48
34
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: require_all
52
35
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2157425620
37
+ - !ruby/object:Gem::Dependency
38
+ name: sugar-high
39
+ requirement: &2157425100 !ruby/object:Gem::Requirement
54
40
  none: false
55
- requirements:
41
+ requirements:
56
42
  - - ~>
57
- - !ruby/object:Gem::Version
58
- segments:
59
- - 1
60
- - 2
61
- - 0
62
- version: 1.2.0
43
+ - !ruby/object:Gem::Version
44
+ version: 0.3.7
63
45
  type: :runtime
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: activesupport
67
46
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2157425100
48
+ - !ruby/object:Gem::Dependency
49
+ name: activesupport
50
+ requirement: &2157424560 !ruby/object:Gem::Requirement
69
51
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- segments:
74
- - 3
75
- - 0
76
- - 1
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
77
55
  version: 3.0.1
78
56
  type: :runtime
79
- version_requirements: *id004
57
+ prerelease: false
58
+ version_requirements: *2157424560
80
59
  description: RSpec 2 matchers for files, directories and symlinks
81
60
  email: kmandrup@gmail.com
82
61
  executables: []
83
-
84
62
  extensions: []
85
-
86
- extra_rdoc_files:
63
+ extra_rdoc_files:
87
64
  - LICENSE
88
65
  - README.markdown
89
- files:
66
+ files:
90
67
  - .document
91
68
  - .rspec
92
69
  - LICENSE
@@ -113,36 +90,29 @@ files:
113
90
  has_rdoc: true
114
91
  homepage: http://github.com/kristianmandrup/file-spec
115
92
  licenses: []
116
-
117
93
  post_install_message:
118
94
  rdoc_options: []
119
-
120
- require_paths:
95
+ require_paths:
121
96
  - lib
122
- required_ruby_version: !ruby/object:Gem::Requirement
97
+ required_ruby_version: !ruby/object:Gem::Requirement
123
98
  none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- segments:
128
- - 0
129
- version: "0"
130
- required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
104
  none: false
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- segments:
136
- - 0
137
- version: "0"
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
138
109
  requirements: []
139
-
140
110
  rubyforge_project:
141
- rubygems_version: 1.3.7
111
+ rubygems_version: 1.5.3
142
112
  signing_key:
143
113
  specification_version: 3
144
114
  summary: RSpec 2 matchers for files, directories and symlinks
145
- test_files:
115
+ test_files:
146
116
  - spec/file-spec/matchers/multiple/have_directories_spec.rb
147
117
  - spec/file-spec/matchers/multiple/have_files_spec.rb
148
118
  - spec/file-spec/matchers/multiple/have_symlinks_spec.rb