Skip to content

Instantly share code, notes, and snippets.

@feifanzhou
Created June 14, 2014 23:30
Show Gist options
  • Save feifanzhou/704209c70b1d97bb59ac to your computer and use it in GitHub Desktop.
Save feifanzhou/704209c70b1d97bb59ac to your computer and use it in GitHub Desktop.
Working Spork config for RSpec 3
require 'rspec/core/version'
class Spork::TestFramework::RSpec < Spork::TestFramework
DEFAULT_PORT = 8989
HELPER_FILE = File.join(Dir.pwd, "spec/spec_helper.rb")
def run_tests(argv, stderr, stdout)
if rspec1?
::Spec::Runner::CommandLine.run(
::Spec::Runner::OptionParser.parse(argv, stderr, stdout)
)
elsif rspec3?
options = ::RSpec::Core::ConfigurationOptions.new(argv)
::RSpec::Core::Runner.new(options).run(stderr, stdout)
else
::RSpec::Core::CommandLine.new(argv).run(stderr, stdout)
end
end
def rspec3?
return false if !defined?(::RSpec::Core::Version::STRING)
::RSpec::Core::Version::STRING =~ /^3\./
end
def rspec1?
defined?(Spec) && !defined?(RSpec)
end
end
@feifanzhou
Copy link
Author

Thanks to @CodeCarson: https://github.com/codecarson/spork/blob/38c79dcedb246daacbadb9f18d09f50cc837de51/lib/spork/test_framework/rspec.rb

Creating a Gist for my own reference. File location with rbenv: ~ ▸ .rbenv ▸ versions ▸ 2.1.2 ▸ lib ▸ ruby ▸ gems ▸ 2.1.0 ▸ gems ▸ spork-1.0.0rc4 ▸ lib ▸ spork ▸ test_framework

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment