Can Rspec take in a variable from the Command Line and use that variable in all tests?

I have a variable that comes in from the command line. . .
rspec spec spec/boxing/kata/boxing_kata_spec.rb <spec/fixtures/family_preferences.csv

The variable. . . family_file = $stdin. . .can be seen by the first test that uses it, but not by the second test. . .

it “load data” do
family_file = $stdin
csv_file = Boxing::Kata::LoadFamily.new
highest_err_level, family_data = csv_file.load_validate_family_preferences(family_file)
expect(family_data.length).to be > 0
end

it “member validation” do
family_file = $stdin
csv_file = Boxing::Kata::LoadFamily.new
highest_err_level, family_data = csv_file.load_validate_family_preferences(family_file)
expect(highest_err_level).to eql “None”
end

How can I code this so all tests have access to this variable?

Thanks,
George

I found that this is not an appropriate way to test with RSpec. No replies necessary.

Thanks,
George

That’s cool. But you can use ARGV and eval all the arguments.
I don’t know if this can help:

__b__, i = binding, 0
ARGV.filter { |x| x[/^[$@]?[a-zA-Z]+=.+$/] }.each(&__b__.method(:eval))
__b__.eval(%q(print("local_variables\t\t#{local_variables.reverse[3..-1]}\n")))

begin
	loop do
		printf "Evaluate %03d> ", i += 1
		STDIN.gets.to_s.strip.tap { |x| puts "#{x}\n# => #{__b__.eval(x).inspect}" }
	end
rescue Interrupt, SignalException, SystemExit
	puts
	exit! 0
rescue Exception => e
	puts e
	retry
end

It should work like this:

Remember you are running a shell in the command line, you have to quote (), “”, ‘’ etc.