I am having a rspec ruby file named test_spec.rb . I want to add below command inside the file so to make it run when I run the rspec file.
exec("sudo gsutil cp test_object.txt gs://sample-bucket1")
But when I am running my code as soon as above command runs it stops the further execution. How can I prevent it.
Below is my Rspec code.
A=C.new
context "Bucket Resource : " do
#setup data
before('The Original should create object') do
#some code here
exec("sudo gsutil cp test_object.txt gs://sample-bucket1")
end
#Positive Test cases
describe "The Original should create object" do
it "Should execute successfully and return an instance " do
#define namevar
entity = "[email protected]"
#define build params
build_params = {
entity: "[email protected]",
role: "OWNER",
}
expect(A.create_instance(build_params)).to be_an_instance_of(B)
end
end
after('The Original should create object') do
#some code here
end
end
After running the above code, after hook is not called.
execreplaces your process with the given command, so it's actually the expected behavior. You might want to use`...`orsysteminstead.