Skip to content
Browse files

specs and features files are called from working directory

  • Loading branch information...
1 parent ff24774 commit 62a25a7b392e0d47719486894a1c11d24e235f5d pierre-o13 committed
Showing with 25 additions and 25 deletions.
  1. +4 −4 lib/specjour/loader.rb
  2. +21 −21 spec/specjour/loader_spec.rb
View
8 lib/specjour/loader.rb
@@ -38,9 +38,9 @@ def start
def spec_files
@spec_files ||= file_collector(spec_paths) do |path|
if path == project_path
- Dir["#{path}/spec/**/*_spec.rb"]
+ Dir["spec/**/*_spec.rb"]
else
- Dir["#{path}/**/*_spec.rb"]
+ Dir["**/*_spec.rb"]
end
end
end
@@ -48,9 +48,9 @@ def spec_files
def feature_files
@feature_files ||= file_collector(feature_paths) do |path|
if path == project_path
- Dir["#{path}/features/**/*.feature"]
+ Dir["features/**/*.feature"]
else
- Dir["#{path}/**/*.feature"]
+ Dir["**/*.feature"]
end
end
end
View
42 spec/specjour/loader_spec.rb
@@ -8,62 +8,62 @@
end
it "finds all specs in spec/ by default" do
- mock(Dir).[]("/myproject/spec/**/*_spec.rb") { ["/myproject/spec/foo_spec.rb"] }
+ mock(Dir).[]("spec/**/*_spec.rb") { ["spec/foo_spec.rb"] }
loader = described_class.new :project_path => "/myproject", :test_paths => ["/myproject"]
- loader.spec_files.should =~ ["/myproject/spec/foo_spec.rb"]
+ loader.spec_files.should =~ ["spec/foo_spec.rb"]
end
it "finds all specs in spec directory" do
- mock(File).expand_path("spec", "/myproject") { "/myproject/spec" }
- stub(File).directory?("/myproject/spec") { true }
- mock(Dir).[]("/myproject/spec/**/*_spec.rb") { ["/myproject/spec/foo_spec.rb"] }
+ mock(File).expand_path("spec", "/myproject") { "spec" }
+ stub(File).directory?("spec") { true }
+ mock(Dir).[]("**/*_spec.rb") { ["spec/foo_spec.rb"] }
loader = described_class.new :project_path => "/myproject", :test_paths => ["spec"]
- loader.spec_files.should =~ ["/myproject/spec/foo_spec.rb"]
+ loader.spec_files.should =~ ["spec/foo_spec.rb"]
end
it "doesn't include feature files" do
mock(File).expand_path(anything, "/myproject") { |p| "/myproject/#{p}" }
stub(File).directory?("/myproject/spec") { true }
- mock(Dir).[]("/myproject/spec/**/*_spec.rb") { ["/myproject/spec/foo_spec.rb"] }
+ mock(Dir).[]("**/*_spec.rb") { ["spec/foo_spec.rb"] }
loader = described_class.new :project_path => "/myproject", :test_paths => ["spec", "features/sign_up.feature"]
- loader.spec_files.should =~ ["/myproject/spec/foo_spec.rb"]
+ loader.spec_files.should =~ ["spec/foo_spec.rb"]
end
it "finds one spec file in addition to a directory of specs" do
- mock(File).expand_path(anything, "/myproject") { |p| "/myproject/#{p}" }.times(2)
+ mock(File).expand_path(anything, "/myproject") { |p| "#{p}" }.times(2)
stub(File).directory? { |d| d =~ /helpers/ }
- mock(Dir).[]("/myproject/spec/helpers/**/*_spec.rb") do
+ mock(Dir).[]("**/*_spec.rb") do
[
- "/myproject/spec/helpers/application_helper_spec.rb",
- "/myproject/spec/helpers/phone_number_helper_spec.rb"
+ "spec/helpers/application_helper_spec.rb",
+ "spec/helpers/phone_number_helper_spec.rb"
]
end
loader = described_class.new :project_path => "/myproject", :test_paths => ["spec/models/user_spec.rb", "spec/helpers"]
loader.spec_files.should =~ [
- "/myproject/spec/models/user_spec.rb",
- "/myproject/spec/helpers/application_helper_spec.rb",
- "/myproject/spec/helpers/phone_number_helper_spec.rb"
+ "spec/models/user_spec.rb",
+ "spec/helpers/application_helper_spec.rb",
+ "spec/helpers/phone_number_helper_spec.rb"
]
end
it "finds a unique set of specs" do
- mock(File).expand_path(anything, "/myproject") { |p| "/myproject/#{p}" }.times(2)
+ mock(File).expand_path(anything, "/myproject") { |p| "#{p}" }.times(2)
stub(File).directory? { |d| d =~ /helpers$/ }
- mock(Dir).[]("/myproject/spec/helpers/**/*_spec.rb") do
+ mock(Dir).[]("**/*_spec.rb") do
[
- "/myproject/spec/helpers/application_helper_spec.rb",
- "/myproject/spec/helpers/phone_number_helper_spec.rb"
+ "spec/helpers/application_helper_spec.rb",
+ "spec/helpers/phone_number_helper_spec.rb"
]
end
loader = described_class.new :project_path => "/myproject", :test_paths => ["spec/helpers/phone_number_helper_spec.rb", "spec/helpers"]
loader.spec_files.should =~ [
- "/myproject/spec/helpers/application_helper_spec.rb",
- "/myproject/spec/helpers/phone_number_helper_spec.rb"
+ "spec/helpers/application_helper_spec.rb",
+ "spec/helpers/phone_number_helper_spec.rb"
]
end
end

0 comments on commit 62a25a7

Please sign in to comment.
Something went wrong with that request. Please try again.