Skip to content

Commit 9ef4fbc

Browse files
author
Glenn Matthews
committedMar 10, 2016
Proper discovery of spec files
1 parent 4a0ec75 commit 9ef4fbc

File tree

6 files changed

+21
-29
lines changed

6 files changed

+21
-29
lines changed
 

‎Rakefile

+16-24
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,26 @@ task default: %w(rubocop spec build)
99

1010
RuboCop::RakeTask.new
1111

12+
RSpec::Core::RakeTask.new(:spec_common) do |t|
13+
t.pattern = 'spec/*_spec.rb'
14+
t.rspec_opts = '--format documentation'
15+
t.verbose = false
16+
end
17+
spec_tasks = [:spec_common]
18+
1219
# Because each of the below specs requires a clean Ruby environment,
1320
# they need to be run individually instead of as a single RSpec task.
14-
RSpec::Core::RakeTask.new(:spec_no_clients) do |t|
15-
t.pattern = 'spec/no_clients_spec.rb'
16-
end
17-
RSpec::Core::RakeTask.new(:spec_nxapi_only) do |t|
18-
t.pattern = 'spec/nxapi_only_spec.rb'
19-
end
20-
RSpec::Core::RakeTask.new(:spec_grpc_only) do |t|
21-
t.pattern = 'spec/grpc_only_spec.rb'
22-
end
23-
RSpec::Core::RakeTask.new(:spec_all_clients) do |t|
24-
t.pattern = 'spec/all_clients_spec.rb'
25-
end
26-
RSpec::Core::RakeTask.new(:spec_yaml) do |t|
27-
t.pattern = 'spec/yaml_spec.rb'
28-
end
29-
RSpec::Core::RakeTask.new(:spec_whitespace) do |t|
30-
t.pattern = 'spec/whitespace_spec.rb'
21+
Dir.glob('spec/isolate/*_spec.rb').each do |f|
22+
task = File.basename(f, '.rb').to_sym
23+
RSpec::Core::RakeTask.new(task) do |t|
24+
t.pattern = f
25+
t.rspec_opts = '--format documentation'
26+
t.verbose = false
27+
end
28+
spec_tasks << task
3129
end
3230

33-
task spec: [:spec_no_clients,
34-
:spec_nxapi_only,
35-
:spec_grpc_only,
36-
:spec_all_clients,
37-
:spec_yaml,
38-
:spec_whitespace,
39-
]
31+
task spec: spec_tasks
4032

4133
task :build do
4234
system 'gem build cisco_node_utils.gemspec'

‎bin/git/hooks/pre-commit/validate-yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Run the Kwalify YAML schema validation
77

88
step_name "Validating YAML files"
9-
rake spec_yaml
9+
rspec "$REPO_DIR"/spec/yaml_spec.rb
1010
check_rc "Please fix YAML schema validation failures before committing"
1111

1212
# Ensure that command_reference can parse all the YAML as well

‎spec/all_clients_spec.rb ‎spec/isolate/all_clients_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative 'spec_helper.rb'
1+
require_relative '../spec_helper.rb'
22

33
context 'when both clients are installed' do
44
it 'should have both clients' do

‎spec/grpc_only_spec.rb ‎spec/isolate/grpc_only_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative 'spec_helper.rb'
1+
require_relative '../spec_helper.rb'
22

33
context 'when only gRPC client is installed' do
44
let(:main_self) { TOPLEVEL_BINDING.eval('self') }

‎spec/no_clients_spec.rb ‎spec/isolate/no_clients_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative 'spec_helper.rb'
1+
require_relative '../spec_helper.rb'
22
require 'rspec/core'
33

44
context 'when no client implementations are installed' do

‎spec/nxapi_only_spec.rb ‎spec/isolate/nxapi_only_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative 'spec_helper.rb'
1+
require_relative '../spec_helper.rb'
22

33
context 'when only NXAPI client is installed' do
44
let(:main_self) { TOPLEVEL_BINDING.eval('self') }

0 commit comments

Comments
 (0)
Please sign in to comment.