spec/runner_spec.rb in schema_dev-3.5.1 vs spec/runner_spec.rb in schema_dev-3.6.0

- old
+ new

@@ -1,6 +1,8 @@ require 'schema_dev/runner' +require 'which_works' +require 'pathname' describe SchemaDev::Runner do it "creates gemfiles" do config = get_config(ruby: "2.1.3", activerecord: "4.0", db: "sqlite3") @@ -19,23 +21,21 @@ expect(Pathname.new(".travis.yml")).to be_file end end Selectors = { - 'chruby-exec' => "SHELL=`which bash` chruby-exec ruby-#{RUBY_VERSION} --", + 'chruby-exec' => "SHELL=/usr/local/bin/bash chruby-exec ruby-#{RUBY_VERSION} --", 'rvm' => "rvm #{RUBY_VERSION} do", 'rbenv' => "RBENV_VERSION=#{RUBY_VERSION}" } Selectors.each do |selector, selection_command| describe "matrix (#{selector})" do before(:each) do - # mocking RubySelector to find selector + # mocking Which.which to find selector SchemaDev::RubySelector._reset - Selectors.keys.each do |k| - allow(SchemaDev::RubySelector).to receive(:system).with("which -s #{k}").and_return k == selector - end + allow(Which).to receive(:which) {|cmd| ["bash", selector].include?(cmd) ? "/usr/local/bin/#{cmd}" : nil } case selector when 'chruby-exec' expect_any_instance_of(Pathname).to receive(:entries).and_return [Pathname.new("ruby-#{RUBY_VERSION}")] when 'rbenv' expect_any_instance_of(SchemaDev::RubySelector::Rbenv).to receive(:`).with("rbenv versions --bare").and_return RUBY_VERSION