sprout 1.0.8.pre → 1.0.9.pre
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sprout might be problematic. Click here for more details.
- data/lib/sprout/test/sprout_test_case.rb +17 -1
- data/lib/sprout/version.rb +1 -1
- data/test/unit/sprout_test.rb +29 -1
- metadata +2 -2
@@ -174,9 +174,12 @@ module SproutTestCase # :nodoc:[all]
|
|
174
174
|
# path by checking each parent directory.
|
175
175
|
def find_fixtures path
|
176
176
|
# Return nil if path is nil or is not a file:
|
177
|
-
|
177
|
+
find_fixtures_error(path) if(find_reached_root?(path))
|
178
178
|
# Get the parent directory if path is a file:
|
179
179
|
path = File.dirname(path) if !File.directory? path
|
180
|
+
if(should_create_fixtures_for?(path))
|
181
|
+
FileUtils.makedirs File.join(path, FIXTURES_NAME)
|
182
|
+
end
|
180
183
|
# Check for a folder at "#{path}/fixtures":
|
181
184
|
fixture_path = File.join(path, FIXTURES_NAME)
|
182
185
|
# Return the fixtures folder if found:
|
@@ -185,6 +188,19 @@ module SproutTestCase # :nodoc:[all]
|
|
185
188
|
return find_fixtures File.dirname(path) unless File.dirname(path) == path
|
186
189
|
end
|
187
190
|
|
191
|
+
def should_create_fixtures_for? path
|
192
|
+
basename = File.basename path
|
193
|
+
return basename == 'test' || basename == 'tests'
|
194
|
+
end
|
195
|
+
|
196
|
+
def find_fixtures_error path
|
197
|
+
raise Sprout::Errors::UsageError.new "Request to find a fixtures folder failed at: #{path}"
|
198
|
+
end
|
199
|
+
|
200
|
+
def find_reached_root? path
|
201
|
+
return (path.nil? || !File.exists?(path) || File.dirname(path) == path)
|
202
|
+
end
|
203
|
+
|
188
204
|
end
|
189
205
|
|
190
206
|
# TODO: Consider adding these:
|
data/lib/sprout/version.rb
CHANGED
data/test/unit/sprout_test.rb
CHANGED
@@ -3,6 +3,34 @@ require File.dirname(__FILE__) + '/test_helper'
|
|
3
3
|
class SproutTest < Test::Unit::TestCase
|
4
4
|
include SproutTestCase
|
5
5
|
|
6
|
+
context "The SproutTestCase" do
|
7
|
+
|
8
|
+
context "find_fixtures" do
|
9
|
+
|
10
|
+
setup do
|
11
|
+
@from = File.join(fixtures, 'sprout_test_case', 'test', 'other')
|
12
|
+
@expected_fixtures = File.join(fixtures, 'sprout_test_case', 'test', 'fixtures')
|
13
|
+
FileUtils.makedirs @from
|
14
|
+
end
|
15
|
+
|
16
|
+
teardown do
|
17
|
+
remove_file File.join(fixtures, 'sprout_test_case')
|
18
|
+
end
|
19
|
+
|
20
|
+
should "find_fixtures within a test folder" do
|
21
|
+
result = find_fixtures @from
|
22
|
+
assert_equal @expected_fixtures, result
|
23
|
+
end
|
24
|
+
|
25
|
+
should "throw if reaches system root" do
|
26
|
+
assert_raises Sprout::Errors::UsageError do
|
27
|
+
find_fixtures File.dirname(File.dirname(File.dirname(__FILE__)))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
6
34
|
context "Errors" do
|
7
35
|
include Sprout::Errors
|
8
36
|
|
@@ -20,7 +48,7 @@ class SproutTest < Test::Unit::TestCase
|
|
20
48
|
VersionRequirementNotMetError
|
21
49
|
].each do |error|
|
22
50
|
|
23
|
-
should "be available to
|
51
|
+
should "be available to instantiate a #{error.to_s}" do
|
24
52
|
error.new
|
25
53
|
end
|
26
54
|
end
|