Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add knapsack binary #21

Merged
merged 1 commit into from
Jul 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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