I’ve got something like this :
class Something
def some_method
%x{xyz}
end
end
And in the spec :
describe Something do
describe "#some_method" do
it "should execute xyz command in a subshell" do
x = Something.new
#What should come here?
x.some_method
end
end
end
I know how I can mock “system” . But my question is specific to “%x” . So how to mock %x ?
The line you are looking for is
the backticks are actually a method being called and whatever is put between them is passed as a String argument.
%x{...}is just a syntax variation to the backticks and thus cause the same method invocation.