Running rspec from within ruby multiple times within the same process

29 views
Skip to first unread message

richa...@sellamachine.com

unread,
May 15, 2014, 6:44:54 PM5/15/14
to rs...@googlegroups.com

I am creating a test automation tool that runs a rspec test from within ruby, not from command line.

I run my test like this that runs and gives me a output hash with pass / fail etc.

config = RSpec.configuration

json_formatter = RSpec::Core::Formatters::JsonFormatter.new(config.out)
reporter =  RSpec::Core::Reporter.new(json_formatter)
config.instance_variable_set(:@reporter, reporter)

RSpec::Core::Runner.run(["#{Rails.root}/spec/test1_spec.rb"])

puts json_formatter.output_hash 

All is great until i run it again and i get the error

> undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_7:0x007ff3d343d978>

how do i reload / make sure all spec_helper and files are loaded before i run it again ?

thanks Rick

Robb Shecter

unread,
May 21, 2014, 2:58:01 AM5/21/14
to rs...@googlegroups.com
A potential clue for a workaround: I have code just like this that runs fine in a resque worker.
Reply all
Reply to author
Forward
0 new messages