Skip to content

Commit

Permalink
Add knapsack binary
Browse files Browse the repository at this point in the history
  • Loading branch information
strika committed Jul 20, 2015
1 parent bb0ac2a commit 6eb21e6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
11 changes: 11 additions & 0 deletions bin/knapsack
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby

require "knapsack"

runner = ARGV[0]
arguments = ARGV[1]

case runner
when "rspec"
Knapsack::Runners::RSpecRunner.run(arguments)
end
1 change: 1 addition & 0 deletions lib/knapsack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
require_relative 'knapsack/adapters/rspec_adapter'
require_relative 'knapsack/adapters/cucumber_adapter'
require_relative 'knapsack/adapters/minitest_adapter'
require_relative 'knapsack/runners/rspec_runner'

module Knapsack
class << self
Expand Down
23 changes: 23 additions & 0 deletions lib/knapsack/runners/rspec_runner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Knapsack
module Runners
class RSpecRunner
def self.run(args)
allocator = Knapsack::AllocatorBuilder.new(Knapsack::Adapters::RspecAdapter).allocator

puts
puts 'Report specs:'
puts allocator.report_node_tests
puts
puts 'Leftover specs:'
puts allocator.leftover_node_tests
puts

cmd = %Q[bundle exec rspec #{args} --default-path #{allocator.test_dir} -- #{allocator.stringify_node_tests}]

system(cmd)
exit($?.exitstatus)

end
end
end
end
15 changes: 1 addition & 14 deletions lib/tasks/knapsack_rspec.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@ require 'knapsack'

namespace :knapsack do
task :rspec, [:rspec_args] do |_, args|
allocator = Knapsack::AllocatorBuilder.new(Knapsack::Adapters::RspecAdapter).allocator

puts
puts 'Report specs:'
puts allocator.report_node_tests
puts
puts 'Leftover specs:'
puts allocator.leftover_node_tests
puts

cmd = %Q[bundle exec rspec #{args[:rspec_args]} --default-path #{allocator.test_dir} -- #{allocator.stringify_node_tests}]

system(cmd)
exit($?.exitstatus)
Knapsack::Runners::RSpecRunner.run(args[:rspec_args])
end
end

0 comments on commit 6eb21e6

Please sign in to comment.