soundcheck 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +4 -0
- data/VERSION +1 -1
- data/bin/soundcheck +7 -3
- data/features/soundcheck.feature +7 -1
- data/fixtures/node-expresso/package.json +0 -0
- data/fixtures/node-expresso/test/expresso.js +0 -0
- data/fixtures/ruby-cucumber/features/cucumber.feature +0 -0
- data/fixtures/ruby-cucumber-rspec/features/cucumber.feature +0 -0
- data/fixtures/ruby-cucumber-rspec/spec/spec_helper.rb +0 -0
- data/fixtures/ruby-cucumber-rspec/spec/with_spec_helper_spec.rb +1 -0
- data/fixtures/ruby-cucumber-rspec/spec/without_spec_helper_spec.rb +0 -0
- data/fixtures/ruby-rspec-exception/spec/spec_helper.rb +0 -0
- data/fixtures/ruby-rspec-exception/spec/with_spec_helper_spec.rb +7 -0
- data/fixtures/ruby-rspec-exception/spec/without_spec_helper_spec.rb +0 -0
- data/lib/soundcheck/frameworks.rb +117 -0
- data/lib/soundcheck/languages.rb +40 -0
- data/lib/soundcheck/logging.rb +8 -0
- data/lib/soundcheck/project.rb +48 -0
- data/lib/soundcheck.rb +15 -17
- data/soundcheck.gemspec +27 -3
- data/spec/soundcheck/frameworks/cucumber_spec.rb +33 -0
- data/spec/soundcheck/frameworks/expresso_spec.rb +33 -0
- data/spec/soundcheck/frameworks/rspec_spec.rb +65 -0
- data/spec/soundcheck/frameworks_spec.rb +35 -0
- data/spec/soundcheck/languages_spec.rb +23 -0
- data/spec/soundcheck/project_spec.rb +26 -0
- data/spec/soundcheck_spec.rb +6 -6
- data/spec/spec_helper.rb +8 -0
- metadata +43 -11
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
|
-
|
4
|
+
gem "activesupport", "~> 3.0"
|
5
5
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
data/Gemfile.lock
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
activesupport (3.1.1)
|
5
|
+
multi_json (~> 1.0)
|
4
6
|
builder (3.0.0)
|
5
7
|
cucumber (1.1.0)
|
6
8
|
builder (>= 2.1.2)
|
@@ -17,6 +19,7 @@ GEM
|
|
17
19
|
git (>= 1.2.5)
|
18
20
|
rake
|
19
21
|
json (1.6.1)
|
22
|
+
multi_json (1.0.3)
|
20
23
|
rake (0.9.2.2)
|
21
24
|
rcov (0.9.11)
|
22
25
|
rspec (2.7.0)
|
@@ -33,6 +36,7 @@ PLATFORMS
|
|
33
36
|
ruby
|
34
37
|
|
35
38
|
DEPENDENCIES
|
39
|
+
activesupport (~> 3.0)
|
36
40
|
cucumber
|
37
41
|
jeweler (~> 1.6.4)
|
38
42
|
rcov
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/soundcheck
CHANGED
@@ -6,11 +6,15 @@ options = {}
|
|
6
6
|
option_parser = OptionParser.new do |opts|
|
7
7
|
opts.banner = "Usage: soundcheck [options] [file or path]"
|
8
8
|
|
9
|
-
opts.on("--fast", "Run fast specs only") do
|
10
|
-
options[:fast] =
|
9
|
+
opts.on("--fast", "Run fast specs only") do
|
10
|
+
options[:fast] = true
|
11
11
|
end
|
12
12
|
|
13
|
-
opts.on("--
|
13
|
+
opts.on("--trace", "Shows backtrace") do
|
14
|
+
options[:trace] = true
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("--help", "Show this info") do
|
14
18
|
puts opts
|
15
19
|
exit
|
16
20
|
end
|
data/features/soundcheck.feature
CHANGED
@@ -9,4 +9,10 @@ Feature: Soundcheck
|
|
9
9
|
Scenario: Ruby and RSpec
|
10
10
|
Given the "ruby-bundler-rspec" fixture
|
11
11
|
When I run "soundcheck spec"
|
12
|
-
Then it should have passed
|
12
|
+
Then it should have passed
|
13
|
+
|
14
|
+
Scenario: Ruby and RSpec backtraces
|
15
|
+
Given the "ruby-rspec-exception" fixture
|
16
|
+
When I run "soundcheck --trace spec"
|
17
|
+
Then I should see "1 failure"
|
18
|
+
And I should see "gems/rspec-core"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'spec_helper'
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Frameworks
|
4
|
+
module Base
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
attr_accessor :project
|
9
|
+
attr_accessor :options
|
10
|
+
|
11
|
+
define_method :initialize do |project|
|
12
|
+
self.project = project
|
13
|
+
self.options = {}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module InstanceMethods
|
18
|
+
def filter_with(args, filters)
|
19
|
+
args.select do |arg|
|
20
|
+
filters.any? do |key, value|
|
21
|
+
case value
|
22
|
+
when Regexp
|
23
|
+
arg =~ value
|
24
|
+
when Proc
|
25
|
+
value.call(arg)
|
26
|
+
else
|
27
|
+
raise "Unknown filter type for #{value}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
self.class.name.split("::").last
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class RSpec
|
40
|
+
include Frameworks::Base
|
41
|
+
|
42
|
+
def present?
|
43
|
+
project.has_file?("spec")
|
44
|
+
end
|
45
|
+
|
46
|
+
def filter(*args)
|
47
|
+
filter_with(args, {
|
48
|
+
:is_spec_file => /_spec\.rb$/,
|
49
|
+
:is_in_spec_dir => /spec/,
|
50
|
+
:is_dir => lambda {|arg| project.has_dir?(arg) }
|
51
|
+
})
|
52
|
+
end
|
53
|
+
|
54
|
+
def command(*args)
|
55
|
+
args = (args.empty? ? ["spec"] : filter(*args))
|
56
|
+
return nil if args.empty?
|
57
|
+
|
58
|
+
to_run = []
|
59
|
+
to_run << "bundle exec" if has_gemfile? and requires_spec_helper?(*args)
|
60
|
+
to_run << "rspec"
|
61
|
+
to_run << "-b" if options[:trace]
|
62
|
+
to_run << args.join(" ")
|
63
|
+
to_run.join(" ").strip
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def requires_spec_helper?(*args)
|
69
|
+
output, status = project.execute("grep -r 'spec_helper' #{args.join(" ")}")
|
70
|
+
status.exitstatus == 0 # matched
|
71
|
+
end
|
72
|
+
|
73
|
+
def has_gemfile?
|
74
|
+
project.has_file?("Gemfile")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Cucumber
|
79
|
+
include Frameworks::Base
|
80
|
+
|
81
|
+
def present?
|
82
|
+
project.has_file?("features")
|
83
|
+
end
|
84
|
+
|
85
|
+
def filter(*args)
|
86
|
+
args.select { |arg| arg =~ /\.feature$/ }
|
87
|
+
end
|
88
|
+
|
89
|
+
def command(*args)
|
90
|
+
args = (args.empty? ? ["features"] : filter(*args))
|
91
|
+
return nil if args.empty?
|
92
|
+
|
93
|
+
"cucumber #{args.join(" ")}".strip
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class Expresso
|
98
|
+
include Frameworks::Base
|
99
|
+
|
100
|
+
def present?
|
101
|
+
project.has_file?("test/*.js")
|
102
|
+
end
|
103
|
+
|
104
|
+
def filter(*args)
|
105
|
+
filter_with(args, {
|
106
|
+
:is_js_file => /\.js$/
|
107
|
+
})
|
108
|
+
end
|
109
|
+
|
110
|
+
def command(*args)
|
111
|
+
args = (args.empty? ? ["test/*"] : filter(*args))
|
112
|
+
return nil if args.empty?
|
113
|
+
|
114
|
+
"expresso --include lib #{args.join(" ")}"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
require 'soundcheck/frameworks'
|
3
|
+
|
4
|
+
module Languages
|
5
|
+
module Base
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
attr_accessor(:project)
|
10
|
+
|
11
|
+
define_method(:initialize) do |project|
|
12
|
+
self.project = project
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module InstanceMethods
|
17
|
+
def frameworks
|
18
|
+
known_frameworks.select do |framework|
|
19
|
+
framework.new(project).present?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Ruby
|
26
|
+
include Base
|
27
|
+
|
28
|
+
def known_frameworks
|
29
|
+
[ Frameworks::RSpec, Frameworks::Cucumber ]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class NodeJS
|
34
|
+
include Base
|
35
|
+
|
36
|
+
def known_frameworks
|
37
|
+
[ Frameworks::Expresso ]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'soundcheck/logging'
|
2
|
+
require 'soundcheck/languages'
|
3
|
+
|
4
|
+
class Project
|
5
|
+
class UnknownLanguage < StandardError; end
|
6
|
+
attr_accessor :root
|
7
|
+
|
8
|
+
def initialize(root)
|
9
|
+
self.root = root
|
10
|
+
end
|
11
|
+
|
12
|
+
def has_dir?(dirname)
|
13
|
+
Dir.chdir(root) do
|
14
|
+
Dir.exist?(dirname)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def has_file?(filename)
|
19
|
+
Dir.chdir(root) do
|
20
|
+
not Dir.glob(filename).empty?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def has_files?(*paths)
|
25
|
+
paths.any? { |path| has_file?(path) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def language
|
29
|
+
return Languages::Ruby.new(self) if has_file?("Gemfile")
|
30
|
+
return Languages::Ruby.new(self) if has_file?("spec/*.rb")
|
31
|
+
return Languages::NodeJS.new(self) if has_file?("package.json")
|
32
|
+
raise UnknownLanguage
|
33
|
+
end
|
34
|
+
|
35
|
+
def frameworks
|
36
|
+
language.frameworks.map do |framework_class|
|
37
|
+
framework_class.new(self)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def execute(command)
|
42
|
+
logger.debug "Executing #{command}"
|
43
|
+
Dir.chdir(root) do
|
44
|
+
output = `#{command}`
|
45
|
+
[output, $?]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/soundcheck.rb
CHANGED
@@ -1,32 +1,30 @@
|
|
1
|
+
require 'soundcheck/logging'
|
2
|
+
require 'soundcheck/project'
|
3
|
+
|
1
4
|
class Soundcheck
|
5
|
+
attr_accessor :project
|
2
6
|
attr_accessor :path
|
7
|
+
attr_accessor :options
|
3
8
|
|
4
9
|
def initialize(path = "spec", options = {})
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@path = `grep -r -L 'spec_helper' #{path || "spec"} | grep '_spec.rb'`.strip.gsub("\n", " ")
|
9
|
-
else
|
10
|
-
@path = path || "spec"
|
11
|
-
end
|
10
|
+
self.project = Project.new(Dir.pwd)
|
11
|
+
self.path = path
|
12
|
+
self.options = options
|
12
13
|
end
|
13
14
|
|
14
15
|
def command_to_run
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
16
|
+
commands = []
|
17
|
+
project.frameworks.each do |framework|
|
18
|
+
framework.options = options
|
19
|
+
command = framework.command(*path)
|
20
|
+
commands << command if command
|
21
21
|
end
|
22
|
-
|
23
|
-
# Assume rspec
|
24
|
-
"rspec --drb #{@path}"
|
22
|
+
commands.first
|
25
23
|
end
|
26
24
|
|
27
25
|
def requires_spec_helper?
|
28
26
|
`grep -r 'spec_helper' #{@path}`
|
29
|
-
$?.exitstatus ==
|
27
|
+
$?.exitstatus == 0 # matched
|
30
28
|
end
|
31
29
|
|
32
30
|
def has_gemfile?
|
data/soundcheck.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "soundcheck"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marten Veldthuis"]
|
12
|
-
s.date = "2011-
|
12
|
+
s.date = "2011-11-06"
|
13
13
|
s.description = "Soundcheck tries to figure out what kind of project you're working on, what test file you're trying to run, and what the fastest way is to run that."
|
14
14
|
s.email = "marten@veldthuis.com"
|
15
15
|
s.executables = ["soundcheck"]
|
@@ -29,17 +29,38 @@ Gem::Specification.new do |s|
|
|
29
29
|
"bin/soundcheck",
|
30
30
|
"features/soundcheck.feature",
|
31
31
|
"features/step_definitions/steps.rb",
|
32
|
+
"fixtures/node-expresso/package.json",
|
33
|
+
"fixtures/node-expresso/test/expresso.js",
|
32
34
|
"fixtures/ruby-bundler-rspec/Gemfile",
|
33
35
|
"fixtures/ruby-bundler-rspec/Gemfile.lock",
|
34
36
|
"fixtures/ruby-bundler-rspec/spec/spec_helper.rb",
|
35
37
|
"fixtures/ruby-bundler-rspec/spec/with_spec_helper_spec.rb",
|
36
38
|
"fixtures/ruby-bundler-rspec/spec/without_spec_helper_spec.rb",
|
39
|
+
"fixtures/ruby-cucumber-rspec/features/cucumber.feature",
|
40
|
+
"fixtures/ruby-cucumber-rspec/spec/spec_helper.rb",
|
41
|
+
"fixtures/ruby-cucumber-rspec/spec/with_spec_helper_spec.rb",
|
42
|
+
"fixtures/ruby-cucumber-rspec/spec/without_spec_helper_spec.rb",
|
43
|
+
"fixtures/ruby-cucumber/features/cucumber.feature",
|
44
|
+
"fixtures/ruby-rspec-exception/spec/spec_helper.rb",
|
45
|
+
"fixtures/ruby-rspec-exception/spec/with_spec_helper_spec.rb",
|
46
|
+
"fixtures/ruby-rspec-exception/spec/without_spec_helper_spec.rb",
|
37
47
|
"fixtures/ruby-rspec/spec/spec_helper.rb",
|
38
48
|
"fixtures/ruby-rspec/spec/with_spec_helper_spec.rb",
|
39
49
|
"fixtures/ruby-rspec/spec/without_spec_helper_spec.rb",
|
40
50
|
"lib/soundcheck.rb",
|
51
|
+
"lib/soundcheck/frameworks.rb",
|
52
|
+
"lib/soundcheck/languages.rb",
|
53
|
+
"lib/soundcheck/logging.rb",
|
54
|
+
"lib/soundcheck/project.rb",
|
41
55
|
"soundcheck.gemspec",
|
42
|
-
"spec/
|
56
|
+
"spec/soundcheck/frameworks/cucumber_spec.rb",
|
57
|
+
"spec/soundcheck/frameworks/expresso_spec.rb",
|
58
|
+
"spec/soundcheck/frameworks/rspec_spec.rb",
|
59
|
+
"spec/soundcheck/frameworks_spec.rb",
|
60
|
+
"spec/soundcheck/languages_spec.rb",
|
61
|
+
"spec/soundcheck/project_spec.rb",
|
62
|
+
"spec/soundcheck_spec.rb",
|
63
|
+
"spec/spec_helper.rb"
|
43
64
|
]
|
44
65
|
s.homepage = "http://github.com/marten/soundcheck"
|
45
66
|
s.licenses = ["MIT"]
|
@@ -51,17 +72,20 @@ Gem::Specification.new do |s|
|
|
51
72
|
s.specification_version = 3
|
52
73
|
|
53
74
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
75
|
+
s.add_runtime_dependency(%q<activesupport>, ["~> 3.0"])
|
54
76
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
55
77
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
56
78
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
57
79
|
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
58
80
|
else
|
81
|
+
s.add_dependency(%q<activesupport>, ["~> 3.0"])
|
59
82
|
s.add_dependency(%q<rspec>, [">= 0"])
|
60
83
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
61
84
|
s.add_dependency(%q<rcov>, [">= 0"])
|
62
85
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
63
86
|
end
|
64
87
|
else
|
88
|
+
s.add_dependency(%q<activesupport>, ["~> 3.0"])
|
65
89
|
s.add_dependency(%q<rspec>, [">= 0"])
|
66
90
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
67
91
|
s.add_dependency(%q<rcov>, [">= 0"])
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'soundcheck/project'
|
3
|
+
require 'soundcheck/frameworks'
|
4
|
+
|
5
|
+
describe "Frameworks" do
|
6
|
+
let(:project) { Project.new(fixture("null-project")) }
|
7
|
+
|
8
|
+
describe "Cucumber" do
|
9
|
+
let(:framework) { Frameworks::Cucumber.new(project) }
|
10
|
+
|
11
|
+
it "should find the cucumber framework" do
|
12
|
+
project.stub!(:root => fixture("ruby-cucumber"))
|
13
|
+
framework.present?.should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not find when not there" do
|
17
|
+
project.stub(:root => fixture("null-project"))
|
18
|
+
framework.present?.should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should run with no args" do
|
22
|
+
framework.command.should == "cucumber features"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should not run when args contain no cucumber files" do
|
26
|
+
framework.command("spec/foo_spec.rb").should == nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should run with args" do
|
30
|
+
framework.command("features/a.feature").should == "cucumber features/a.feature"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'soundcheck/project'
|
3
|
+
require 'soundcheck/frameworks'
|
4
|
+
|
5
|
+
describe "Frameworks" do
|
6
|
+
let(:project) { Project.new(fixture("null-project")) }
|
7
|
+
|
8
|
+
describe "Expresso" do
|
9
|
+
let(:framework) { Frameworks::Expresso.new(project) }
|
10
|
+
|
11
|
+
it "should find the expresso framework" do
|
12
|
+
project.stub(:root => fixture("node-expresso"))
|
13
|
+
framework.present?.should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not find when not there" do
|
17
|
+
project.stub(:root => fixture("null-project"))
|
18
|
+
framework.present?.should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should run with no args" do
|
22
|
+
framework.command.should == "expresso --include lib test/*"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should not run when args contain no expresso files" do
|
26
|
+
framework.command("spec/foo_spec.rb").should == nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should run with args" do
|
30
|
+
framework.command("test/foo.js").should == "expresso --include lib test/foo.js"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'soundcheck/project'
|
3
|
+
require 'soundcheck/frameworks'
|
4
|
+
|
5
|
+
describe "Frameworks" do
|
6
|
+
let(:project) { Project.new(fixture("null-project")) }
|
7
|
+
|
8
|
+
describe "RSpec" do
|
9
|
+
let(:framework) { Frameworks::RSpec.new(project) }
|
10
|
+
|
11
|
+
it "should find the rspec framework" do
|
12
|
+
project.stub!(:root => fixture("ruby-rspec"))
|
13
|
+
framework.present?.should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not find when not there" do
|
17
|
+
framework.present?.should be_false
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should work with no args" do
|
21
|
+
framework.command().should == "rspec spec"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should not do anything when args contain no spec files" do
|
25
|
+
framework.command("features/a.feature").should == nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should require spec helper" do
|
29
|
+
project.stub!(:root => fixture("ruby-bundler-rspec"))
|
30
|
+
framework.command.should == "bundle exec rspec spec"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not use bundler when not needed" do
|
34
|
+
project.stub!(:root => fixture("ruby-bundler-rspec"))
|
35
|
+
cmd = framework.command("spec/without_spec_helper_spec.rb")
|
36
|
+
cmd.should == "rspec spec/without_spec_helper_spec.rb"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should show backtraces when requested" do
|
40
|
+
framework.options[:trace] = true
|
41
|
+
framework.command("spec/a_spec.rb").should == "rspec -b spec/a_spec.rb"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should only run fast specs when requested" do pending
|
45
|
+
project.stub!(:root => fixture("ruby-bundler-rspec"))
|
46
|
+
framework.options[:fast] = true
|
47
|
+
|
48
|
+
# Old implementation:
|
49
|
+
#
|
50
|
+
# if options[:fast]
|
51
|
+
# @path = `grep -r -L 'spec_helper' #{path || "spec"} | grep '_spec.rb'`.strip.gsub("\n", " ")
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
it "should work with args" do
|
56
|
+
cmd = framework.command("spec/a_spec.rb", "spec/b_spec.rb")
|
57
|
+
cmd.should == "rspec spec/a_spec.rb spec/b_spec.rb"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should filter invalid non-spec args" do
|
61
|
+
cmd = framework.command("spec/a_spec.rb", "features/a.feature")
|
62
|
+
cmd.should == "rspec spec/a_spec.rb"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'soundcheck/project'
|
3
|
+
require 'soundcheck/frameworks'
|
4
|
+
|
5
|
+
describe "Frameworks" do
|
6
|
+
let(:project) { Project.new(fixture("null-project")) }
|
7
|
+
|
8
|
+
describe "Base" do
|
9
|
+
let(:framework) do
|
10
|
+
framework = Class.new
|
11
|
+
framework.instance_eval { include Frameworks::Base }
|
12
|
+
framework.new(stub)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#filter_with" do
|
16
|
+
it "should filter with regexes" do
|
17
|
+
framework.filter_with(["asdf", "aoeu", "qwer"],
|
18
|
+
{:begins_with_a => /^a/}).should == ["asdf", "aoeu"]
|
19
|
+
framework.filter_with(["asdf", "aoeu", "qwer", "1234"],
|
20
|
+
{:begins_with_a => /^a/,
|
21
|
+
:contains_r => /r/}).should == ["asdf", "aoeu", "qwer"]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should filter with lambdas" do
|
25
|
+
framework.filter_with(["a", "b"], {:equals_a => lambda {|arg| arg == "a"}}).should == ["a"]
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should raise when given unknown filter type" do
|
29
|
+
expect do
|
30
|
+
framework.filter_with(["a"], {:unknown => nil})
|
31
|
+
end.to raise_error
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
require 'soundcheck/languages'
|
3
|
+
|
4
|
+
describe "Languages" do
|
5
|
+
describe "Base" do
|
6
|
+
let(:language) do
|
7
|
+
language = Class.new
|
8
|
+
language.instance_eval { include(Languages::Base) }
|
9
|
+
language.new(stub)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#frameworks" do
|
13
|
+
it "should ask known frameworks for presence" do
|
14
|
+
framework_instance = stub
|
15
|
+
framework = stub(:new => framework_instance)
|
16
|
+
language.stub(:known_frameworks => [framework])
|
17
|
+
|
18
|
+
framework_instance.should_receive(:present?)
|
19
|
+
language.frameworks
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
require "soundcheck/project"
|
3
|
+
|
4
|
+
describe Project do
|
5
|
+
it "should be initialized" do
|
6
|
+
project = Project.new(fixture("ruby-rspec"))
|
7
|
+
project.root.should == fixture("ruby-rspec")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should determine the language used" do
|
11
|
+
Project.new(fixture("ruby-rspec")).language.should be_a(Languages::Ruby)
|
12
|
+
Project.new(fixture("node-expresso")).language.should be_a(Languages::NodeJS)
|
13
|
+
|
14
|
+
expect {
|
15
|
+
Project.new(fixture("null-project")).language
|
16
|
+
}.to raise_error(Project::UnknownLanguage)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should ask the language to determine the frameworks used" do
|
20
|
+
project = Project.new(stub)
|
21
|
+
language = stub
|
22
|
+
language.should_receive(:frameworks).and_return([])
|
23
|
+
project.stub!(:language => language)
|
24
|
+
project.frameworks
|
25
|
+
end
|
26
|
+
end
|
data/spec/soundcheck_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
+
require_relative 'spec_helper'
|
1
2
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/soundcheck')
|
2
3
|
|
3
4
|
CURRENT_PWD = Dir.pwd
|
4
|
-
FIXTURES_ROOT = File.expand_path(File.dirname(__FILE__) + '/../fixtures')
|
5
5
|
|
6
6
|
def cmd_for(path = nil, options = {})
|
7
7
|
Soundcheck.new(path, options).command_to_run
|
@@ -13,26 +13,26 @@ describe "Soundcheck" do
|
|
13
13
|
before(:all) { Dir.chdir(FIXTURES_ROOT + '/ruby-rspec') }
|
14
14
|
|
15
15
|
it "should not use bundler when no Gemfile exists" do
|
16
|
-
cmd_for.should == "rspec
|
16
|
+
cmd_for.should == "rspec spec"
|
17
17
|
end
|
18
18
|
|
19
19
|
context "using bundler" do
|
20
20
|
before(:all) { Dir.chdir(FIXTURES_ROOT + '/ruby-bundler-rspec') }
|
21
21
|
|
22
22
|
it "should return 'bundle exec rspec spec' when run with no arguments" do
|
23
|
-
cmd_for.should == "bundle exec rspec
|
23
|
+
cmd_for.should == "bundle exec rspec spec"
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should run only fast specs" do
|
27
|
-
cmd_for("spec", fast: true).should == "rspec
|
27
|
+
cmd_for("spec", fast: true).should == "rspec spec/without_spec_helper_spec.rb"
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should return 'bundle exec rspec spec/with_spec_helper_spec.rb'" do
|
31
|
-
cmd_for('spec/with_spec_helper_spec.rb').should == "bundle exec rspec
|
31
|
+
cmd_for('spec/with_spec_helper_spec.rb').should == "bundle exec rspec spec/with_spec_helper_spec.rb"
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should return 'rspec spec/without_spec_helper_spec.rb'" do
|
35
|
-
cmd_for('spec/without_spec_helper_spec.rb').should == "rspec
|
35
|
+
cmd_for('spec/without_spec_helper_spec.rb').should == "rspec spec/without_spec_helper_spec.rb"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soundcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: &14479940 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *14479940
|
14
25
|
- !ruby/object:Gem::Dependency
|
15
26
|
name: rspec
|
16
|
-
requirement: &
|
27
|
+
requirement: &14477860 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ! '>='
|
@@ -21,10 +32,10 @@ dependencies:
|
|
21
32
|
version: '0'
|
22
33
|
type: :development
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *14477860
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: jeweler
|
27
|
-
requirement: &
|
38
|
+
requirement: &14476980 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ~>
|
@@ -32,10 +43,10 @@ dependencies:
|
|
32
43
|
version: 1.6.4
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *14476980
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: rcov
|
38
|
-
requirement: &
|
49
|
+
requirement: &14476100 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: '0'
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *14476100
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: cucumber
|
49
|
-
requirement: &
|
60
|
+
requirement: &14474440 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,7 +65,7 @@ dependencies:
|
|
54
65
|
version: '0'
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *14474440
|
58
69
|
description: Soundcheck tries to figure out what kind of project you're working on,
|
59
70
|
what test file you're trying to run, and what the fastest way is to run that.
|
60
71
|
email: marten@veldthuis.com
|
@@ -76,17 +87,38 @@ files:
|
|
76
87
|
- bin/soundcheck
|
77
88
|
- features/soundcheck.feature
|
78
89
|
- features/step_definitions/steps.rb
|
90
|
+
- fixtures/node-expresso/package.json
|
91
|
+
- fixtures/node-expresso/test/expresso.js
|
79
92
|
- fixtures/ruby-bundler-rspec/Gemfile
|
80
93
|
- fixtures/ruby-bundler-rspec/Gemfile.lock
|
81
94
|
- fixtures/ruby-bundler-rspec/spec/spec_helper.rb
|
82
95
|
- fixtures/ruby-bundler-rspec/spec/with_spec_helper_spec.rb
|
83
96
|
- fixtures/ruby-bundler-rspec/spec/without_spec_helper_spec.rb
|
97
|
+
- fixtures/ruby-cucumber-rspec/features/cucumber.feature
|
98
|
+
- fixtures/ruby-cucumber-rspec/spec/spec_helper.rb
|
99
|
+
- fixtures/ruby-cucumber-rspec/spec/with_spec_helper_spec.rb
|
100
|
+
- fixtures/ruby-cucumber-rspec/spec/without_spec_helper_spec.rb
|
101
|
+
- fixtures/ruby-cucumber/features/cucumber.feature
|
102
|
+
- fixtures/ruby-rspec-exception/spec/spec_helper.rb
|
103
|
+
- fixtures/ruby-rspec-exception/spec/with_spec_helper_spec.rb
|
104
|
+
- fixtures/ruby-rspec-exception/spec/without_spec_helper_spec.rb
|
84
105
|
- fixtures/ruby-rspec/spec/spec_helper.rb
|
85
106
|
- fixtures/ruby-rspec/spec/with_spec_helper_spec.rb
|
86
107
|
- fixtures/ruby-rspec/spec/without_spec_helper_spec.rb
|
87
108
|
- lib/soundcheck.rb
|
109
|
+
- lib/soundcheck/frameworks.rb
|
110
|
+
- lib/soundcheck/languages.rb
|
111
|
+
- lib/soundcheck/logging.rb
|
112
|
+
- lib/soundcheck/project.rb
|
88
113
|
- soundcheck.gemspec
|
114
|
+
- spec/soundcheck/frameworks/cucumber_spec.rb
|
115
|
+
- spec/soundcheck/frameworks/expresso_spec.rb
|
116
|
+
- spec/soundcheck/frameworks/rspec_spec.rb
|
117
|
+
- spec/soundcheck/frameworks_spec.rb
|
118
|
+
- spec/soundcheck/languages_spec.rb
|
119
|
+
- spec/soundcheck/project_spec.rb
|
89
120
|
- spec/soundcheck_spec.rb
|
121
|
+
- spec/spec_helper.rb
|
90
122
|
homepage: http://github.com/marten/soundcheck
|
91
123
|
licenses:
|
92
124
|
- MIT
|
@@ -102,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
134
|
version: '0'
|
103
135
|
segments:
|
104
136
|
- 0
|
105
|
-
hash:
|
137
|
+
hash: 1143988248935752491
|
106
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
139
|
none: false
|
108
140
|
requirements:
|