Skip to content
Browse files

Merge pull request #43 from jfirebaugh/singletask

Individual specs can now be run using the konacha:run task.
  • Loading branch information...
2 parents 78d4a19 + 040b455 commit 617380b2e34f9d8024ce492f75c824e12eaf06f2 @joliss joliss committed Jun 11, 2012
Showing with 28 additions and 2 deletions.
  1. +14 −1 README.md
  2. +5 −1 app/models/konacha/spec.rb
  3. +9 −0 spec/models/spec_spec.rb
View
15 README.md
@@ -68,12 +68,25 @@ describe "Array#sum", ->
[1,2,3].sum().should.equal(6)
```
+## Running (Rake Tasks)
+
+### `rake konacha:serve`
+
The `konacha:serve` rake task starts a server for your tests. You can go to the root
page to run all specs (e.g. `http://localhost:3500/`), a sub page to run an individual
spec file (e.g. `http://localhost:3500/array_sum_spec`), or a path to a subdirectory to
run a subset of specs (e.g. `http://localhost:3500/models`).
-Alternatively, you can run the specs in your shell with the `konacha:run` task.
+### `rake konacha:run`
+
+The `konacha:run` rake task will let you run your tests from the command line.
+
+To an individual spec, or specs, you can pass a comma seperated list of specs via the `SPEC` parameter
+
+```
+$ rake konacha:run SPEC=foo_spec
+$ rake konacha:run SPEC=foo_spec,bar_spec,etc_spec
+```
## Spec Helper
View
6 app/models/konacha/spec.rb
@@ -4,7 +4,11 @@ class NotFound < StandardError
end
def self.all
- Konacha.spec_paths.map { |path| new(path) }
+ paths = Konacha.spec_paths
+ if ENV["SPEC"]
+ paths = ENV["SPEC"].split(",")
+ end
+ paths.map {|path| new(path)}
end
def self.find(path)
View
9 spec/models/spec_spec.rb
@@ -28,6 +28,15 @@
all = described_class.all
all.length.should == 2
end
+
+ it "returns specs passed via the ENV['spec'] parameter" do
+ ENV["SPEC"] = "foo_spec,bar_spec,baz_spec"
+ all = described_class.all
+ all.length.should == 3
+ paths = all.map {|p| p.path}
+ paths =~ %w{foo_spec bar_spec baz_spec}
+ ENV["SPEC"] = nil
+ end
end
describe ".find" do

0 comments on commit 617380b

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