Permalink
Browse files

support line number appended to path

  • Loading branch information...
1 parent 5f754c6 commit 500ec9a8b64b193ae02b8f655928effbd35a0c2e @dchelimsky dchelimsky committed Jan 26, 2010
@@ -1,56 +0,0 @@
-Feature: Spec and test together
-
- As an RSpec user
- I want to run one example identified by the line number
-
- Background:
- Given a file named "example.rb" with:
- """
- describe "a group" do
-
- it "has a first example" do
-
- end
-
- it "has a second example" do
-
- end
-
- end
- """
-
- Scenario: two examples - first example on declaration line
- When I run "spec example.rb:3 --format nested"
- Then the stdout should match "1 example, 0 failures"
- And the stdout should match "has a first example"
- But the stdout should not match "has a second example"
-
- Scenario: two examples - first example from line inside declaration
- When I run "spec example.rb:4 --format nested"
- Then the stdout should match "1 example, 0 failures"
- And the stdout should match "has a first example"
- But the stdout should not match "has a second example"
-
- Scenario: two examples - first example from line below declaration
- When I run "spec example.rb:6 --format nested"
- Then the stdout should match "1 example, 0 failures"
- And the stdout should match "has a first example"
- But the stdout should not match "has a second example"
-
- Scenario: two examples - second example from line below declaration
- When I run "spec example.rb:7 --format nested"
- Then the stdout should match "1 example, 0 failures"
- And the stdout should match "has a second example"
- But the stdout should not match "has a first example"
-
- Scenario: two examples - both examples from the group declaration
- When I run "spec example.rb:1 --format nested"
- Then the stdout should match "2 examples, 0 failures"
- And the stdout should match "has a second example"
- And the stdout should match "has a first example"
-
- Scenario: two examples - both examples from above the first example declaration
- When I run "spec example.rb:2 --format nested"
- Then the stdout should match "2 examples, 0 failures"
- And the stdout should match "has a second example"
- And the stdout should match "has a first example"
@@ -0,0 +1,39 @@
+Feature: line number appended to file path
+
+ As an RSpec user
+ I want to run one example identified by the
+ line number appended to the filepath
+
+ Background:
+ Given a file named "example_spec.rb" with:
+ """
+ describe "a group" do
+
+ it "has a first example" do
+
+ end
+
+ it "has a second example" do
+
+ end
+
+ end
+ """
+
+ Scenario: two examples - both examples from the group declaration
+ When I run "spec example_spec.rb:1 --format doc"
+ Then the stdout should match "2 examples, 0 failures"
+ And the stdout should match "has a second example"
+ And the stdout should match "has a first example"
+
+ Scenario: two examples - first example on declaration line
+ When I run "spec example_spec.rb:3 --format doc"
+ Then the stdout should match "1 example, 0 failures"
+ And the stdout should match "has a first example"
+ But the stdout should not match "has a second example"
+
+ Scenario: two examples - second example on declaration line
+ When I run "spec example_spec.rb:7 --format doc"
+ Then the stdout should match "1 example, 0 failures"
+ And the stdout should match "has a second example"
+ But the stdout should not match "has a first example"
@@ -137,13 +137,16 @@ def files_to_run
end
def files_or_directories_to_run=(*files)
+ p files
options[:files_to_run] = files.flatten.inject([]) do |result, file|
if File.directory?(file)
filename_pattern.split(",").each do |pattern|
result += Dir[File.expand_path("#{file}/#{pattern.strip}")]
end
else
- result << file
+ file =~ /([^:]*):?(\d+)?/
+ self.line_number = $2 if $2
+ result << $1
end
result
end
@@ -102,6 +102,15 @@
end
+ context "with line number" do
+
+ it "assigns the line number as the filter" do
+ @config.files_or_directories_to_run = "path/to/a_spec.rb:37"
+ @config.filter.should == {:line_number => 37}
+ end
+
+ end
+
end
describe "include" do

0 comments on commit 500ec9a

Please sign in to comment.