Skip to content

Commit

Permalink
Do not run sudo required specs in guard.
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed May 21, 2014
1 parent b76875a commit 8b79e10
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 42 deletions.
4 changes: 4 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--require spec_helper
--format Fuubar
--order random
--color
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ group :docs do
end

group :development do
gem 'byebug', '~> 3.1.2', platforms: :ruby_20
gem 'guard', '~> 2.6.1'
gem 'guard-bundler', '~> 2.0.0'
gem 'guard-rspec', '~> 4.2.9'
gem 'guard-rubocop', '~> 1.1.0'
gem 'pry', '~> 0.9.12.6'
end

group :test do
Expand All @@ -23,6 +25,7 @@ group :test do
gem 'cucumber', '~> 1.3.15'
gem 'flay', '~> 2.4.0'
gem 'flog', '~> 4.2.0'
gem 'fuubar', '~> 1.3.3'
gem 'reek', '~> 1.3.7'
gem 'rspec', '~> 2.14.1'
gem 'rubocop', '~> 0.22.0', platforms: [:ruby_19, :ruby_20, :ruby_21]
Expand Down
12 changes: 5 additions & 7 deletions Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@

guard :bundler do
watch('Gemfile')
# Uncomment next line if your Gemfile contains the `gemspec' command.
watch(/^.+\.gemspec/)
end

guard :rubocop do
guard :rubocop, all_on_start: false do
watch(/.+\.rb$/)
watch(/.+\.rake$/)
watch(/(?:.+\/)?\.rubocop\.yml$/) { |m| File.dirname(m[0]) }
end

guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^ruby/trema/(.+)\.rb$}) { |m| "spec/trema/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
guard :rspec, cmd: 'bundle exec rspec --tag ~sudo' do
watch(/^spec\/.+_spec\.rb$/)
watch(%r{^ruby/trema/(.+)\.rb$}) { |m| "spec/trema/#{m[1]}_spec.rb" }
# watch('spec/spec_helper.rb') { 'spec' }
end

32 changes: 0 additions & 32 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -701,38 +701,6 @@ task :unittests => [:build_old_unittests, :build_unittests] do
end
end

################################################################################
# Tests
################################################################################

begin
require 'rspec/core'
require 'rspec/core/rake_task'

task :spec => :build_trema
RSpec::Core::RakeTask.new do | task |
task.verbose = $trace
task.pattern = FileList[ 'spec/**/*_spec.rb']
task.rspec_opts = '--format documentation --color'
end

task 'spec:actions' => :build_trema
RSpec::Core::RakeTask.new('spec:actions') do | task |
task.verbose = $trace
task.pattern = FileList[ 'spec/**/*_spec.rb']
task.rspec_opts = '--tag type:actions --format documentation --color'
end

task 'spec:travis' => :build_trema
RSpec::Core::RakeTask.new('spec:travis') do | task |
task.verbose = $trace
task.pattern = FileList[ 'spec/trema/hello_spec.rb', 'spec/trema/echo-*_spec.rb']
task.rspec_opts = '--tag ~sudo --format documentation --color'
end
rescue LoadError
$stderr.puts $ERROR_INFO.to_s
end

################################################################################
# TODO, FIXME etc.
################################################################################
Expand Down
4 changes: 2 additions & 2 deletions ruby/trema/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
require 'trema/default-logger'
require 'trema/monkey-patch/integer'
require 'trema/monkey-patch/string'
require 'trema/timers'
require 'trema/timer'

module Trema
#
# @abstract The base class of Trema controller. Subclass and override handlers to implement a custom OpenFlow controller.
#
class Controller < App
include DefaultLogger
include Trema::Timers
include Trema::Timer

#
# @private Just a placeholder for YARD.
Expand Down
2 changes: 1 addition & 1 deletion ruby/trema/timers.rb → ruby/trema/timer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

module Trema
module Timers
module Timer
def self.included(base)
base.send :include, TimerMethods
base.send :extend, TimerMethods
Expand Down
36 changes: 36 additions & 0 deletions tasks/rspec.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
begin
require 'rspec/core'
require 'rspec/core/rake_task'

task :spec => :build_trema
RSpec::Core::RakeTask.new do |task|
task.verbose = $trace
task.pattern = FileList['spec/**/*_spec.rb']
end

task 'spec:actions' => :build_trema
RSpec::Core::RakeTask.new('spec:actions') do |task|
task.verbose = $trace
task.pattern = FileList['spec/**/*_spec.rb']
task.rspec_opts = '--tag type:actions'
end

task 'spec:travis' => :build_trema
RSpec::Core::RakeTask.new('spec:travis') do |task|
task.verbose = $trace
task.pattern = FileList['spec/trema/hello_spec.rb', 'spec/trema/echo-*_spec.rb']
task.rspec_opts = '--tag ~sudo'
end
rescue LoadError
task :spec do
$stderr.puts 'RSpec is disabled'
end

task 'spec:actions' do
$stderr.puts 'RSpec is disabled'
end

task 'spec:travis' do
$stderr.puts 'RSpec is disabled'
end
end

0 comments on commit 8b79e10

Please sign in to comment.