我正在尝试将作为字符串传递给Ruby进程的rspec代码执行。如何从Ruby进程中而不是从命令行执行rspec并捕获结果?
# Ruby code
code = '
#solution
class User
def in_role?(role)
true
end
end
#Tests to pass
describe User do
it "should be in any roles assigned to it" do
user = User.new
user.should be_in_role("assigned role")
end
end
'
# spec code
# numExamples = examples
# numFailures = failures