require_relative '../lib/commands.rb' describe Commands do it "should be able to automatically generate commands for the gem-example directory" do dir='spec/gem-example' expect(File.exists?("#{dir}/rakefile.rb")).to eq(true) Dir.chdir(dir) do commands=Commands.new expect(commands.has_key?(:build)).to eq(true) commands[:build].update expect(commands[:build].length).to eq(1) expect(Command.exit_code('rake default')).to eq(0) expect(Command.exit_code('rake build')).to eq(0) expect(File.exists?('gem-example-0.0.0.gem')).to eq(true) expect(Command.exit_code('rake clobber')).to eq(0) expect(!File.exists?('gem-example-0.0.0.gem')).to eq(true) end end it "should be able to automatically generate commands for the sln-vs12-example directory" do dir='spec/sln-vs12-example' expect(File.exists?("#{dir}/rakefile.rb")).to eq(true) Dir.chdir(dir) do commands=Commands.new expect(commands.has_key?(:build)).to eq(true) commands[:build].update if(RUBY_PLATFORM.include?("mingw")) expect(Command.exit_code('rake default')).to eq(0) expect(Command.exit_code('rake build')).to eq(0) expect(File.exists?('csharp-library/bin/Debug/csharp-library.dll')).to eq(true) expect(File.exists?('csharp-library/bin/Release/csharp-library.dll')).to eq(true) expect(File.exists?('cpp-library/bin/Debug/cpp-library.dll')).to eq(true) expect(File.exists?('cpp-library/bin/Release/cpp-library.dll')).to eq(true) expect(Command.exit_code('rake clobber')).to eq(0) expect(File.exists?('csharp-library/bin/Debug/csharp-library.dll')).to eq(false) expect(File.exists?('csharp-library/bin/Release/csharp-library.dll')).to eq(false) expect(File.exists?('cpp-library/bin/Debug/cpp-library.dll')).to eq(false) expect(File.exists?('cpp-library/bin/Release/cpp-library.dll')).to eq(false) else expect(Command.exit_code('rake default')).not_to eq(0) expect(Command.exit_code('rake build')).not_to eq(0) end end end it "should be able to automatically generate commands for the sln-vs9-example directory" do dir='spec/sln-vs9-example' expect(File.exists?("#{dir}/rakefile.rb")).to eq(true) Dir.chdir(dir) do commands=Commands.new expect(commands.has_key?(:build)).to eq(true) commands[:build].update if(RUBY_PLATFORM.include?("mingw")) expect(Command.exit_code('rake default')).to eq(0) expect(Command.exit_code('rake build')).to eq(0) expect(File.exists?('csharp-library/bin/Debug/csharp-library.dll')).to eq(true) expect(File.exists?('csharp-library/bin/Release/csharp-library.dll')).to eq(true) expect(File.exists?('cpp-library/bin/Debug/cpp-library.dll')).to eq(true) expect(File.exists?('cpp-library/bin/Release/cpp-library.dll')).to eq(true) expect(Command.exit_code('rake clobber')).to eq(0) expect(File.exists?('csharp-library/bin/Debug/csharp-library.dll')).to eq(false) expect(File.exists?('csharp-library/bin/Release/csharp-library.dll')).to eq(false) expect(File.exists?('cpp-library/bin/Debug/cpp-library.dll')).to eq(false) expect(File.exists?('cpp-library/bin/Release/cpp-library.dll')).to eq(false) else expect(Command.exit_code('rake default')).not_to eq(0) expect(Command.exit_code('rake build')).not_to eq(0) end end end end