@@ -146,16 +146,17 @@ class RubyExeSpecs
146146
147147 @script = RubyExeSpecs . new
148148 allow ( @script ) . to receive ( :` )
149- allow ( $?) . to receive ( :success? ) . and_return ( true )
149+ status_successful = double ( Process ::Status , success? : true )
150+ allow ( Process ) . to receive ( :last_status ) . and_return ( status_successful )
150151 end
151152
152153 it "returns command STDOUT when given command" do
153154 code = "code"
154155 options = { }
155156 output = "output"
156- @script . stub ( :` ) { output }
157+ allow ( @script ) . to receive ( :` ) . and_return ( output )
157158
158- @script . ruby_exe ( code , options ) . should == output
159+ expect ( @script . ruby_exe ( code , options ) ) . to eq output
159160 end
160161
161162 it "returns an Array containing the interpreter executable and flags when given no arguments" do
@@ -174,14 +175,12 @@ class RubyExeSpecs
174175 code = "code"
175176 options = { }
176177
177- @script . stub ( :` ) do
178- $?. stub ( :success? ) { false }
179- $?. stub ( :inspect ) { "#<Process::Status: pid 75873 exit 4>" }
180- end
178+ status_failed = double ( Process ::Status , success? : false , inspect : "#<Process::Status: pid 75873 exit 4>" )
179+ allow ( Process ) . to receive ( :last_status ) . and_return ( status_failed )
181180
182- -> {
181+ expect {
183182 @script . ruby_exe ( code , options )
184- } . should raise_error ( %r{ruby_exe\( .+\) failed: #<Process::Status: pid 75873 exit 4>} )
183+ } . to raise_error ( %r{ruby_exe\( .+\) failed: #<Process::Status: pid 75873 exit 4>} )
185184 end
186185
187186 describe "with :dir option" do
@@ -225,20 +224,21 @@ class RubyExeSpecs
225224 describe "with :exception option" do
226225 context "when Ruby command fails" do
227226 before do
228- $?. stub ( :success? ) { false }
227+ status_failed = double ( Process ::Status , success? : false )
228+ allow ( Process ) . to receive ( :last_status ) . and_return ( status_failed )
229229 end
230230
231231 it "raises exception when exception: true" do
232- -> {
232+ expect {
233233 @script . ruby_exe ( "path" , exception : true )
234- } . should raise_error ( %r{ruby_exe\( .+\) failed:} )
234+ } . to raise_error ( %r{ruby_exe\( .+\) failed:} )
235235 end
236236
237237 it "does not raise exception when exception: false" do
238238 output = "output"
239- @script . stub ( :` ) { output }
239+ allow ( @script ) . to receive ( :` ) . and_return ( output )
240240
241- @script . ruby_exe ( "path" , exception : false ) . should == output
241+ expect ( @script . ruby_exe ( "path" , exception : false ) ) . to eq output
242242 end
243243 end
244244 end
0 commit comments