I am trying to execute rspec code passed in to a Ruby process as a string. How can I execute rspec from within a Ruby process rather than from the commandline and capture the results?
# 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