0

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.

3
  • What actually happens when you run that linux command? Doe it fail silently or is there an error? Commented Aug 9, 2016 at 10:35
  • 1
    exec replaces your process with the given command, so it's actually the expected behavior. You might want to use `...` or system instead. Commented Aug 9, 2016 at 10:42
  • There is no error, it just stops executing. Actually I found other way. Commented Aug 9, 2016 at 12:00

1 Answer 1

1

You can use back tick for this inside your rspec file:

`sudo gsutil cp test_object.txt gs://sample-bucket1`
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.