I have this spec file which is trying to run a script which will run the dotnet cli program:
require 'spec_helper'
RSpec.describe 'Integration test', type: :aruba do
let(:command) { run "dotnet-test" }
it "test" do
command.write("test\n")
stop_all_commands
expect(command.output).to end_with("success\n")
end
end
dotnet-test
script:
dotnet run --project ../SomeProject/src/SomeProject.Console/SomeProject.Console.csproj -- $1
But I get the error :
Failure/Error: expect(command.output).to end_with("success\n")
expected "MSBUILD : error MSB1009: Project file does not exist.\nSwitch: ../SomeProject/src/SomeProject.Console/SomeProject.Console.csproj\n\nThe build failed. Please fix the build errors and run again.\n" to end with "success\n"
But if I run the script from that directory then program runs fine. Cannot figure out what could be the difference between the two. Help is really appreciated.
It sounds like the script you're trying to run relies on a relative path to execute correctly. In that case you may need to cd
within your spec.
See https://relishapp.com/cucumber/aruba/docs/filesystem/change-current-working-directory
Try to use the absolute path of the file instead of
../SomeProject/src/SomeProject.Console/SomeProject.Console.csproj
Can you put the full path, something like:
/Users/yourusername/pathtosomeproject/SomeProject/src/SomeProject.Console/SomeProject.Console.csproj
Obviously you'll need to replace pathtosomeproject
to where it is actually located.