No randomness in reloading tests
This commit is contained in:
parent
5cefae6f21
commit
931c15e110
|
@ -42,46 +42,52 @@ describe "Pry::DefaultCommands::Introspection" do
|
||||||
|
|
||||||
describe do
|
describe do
|
||||||
before do
|
before do
|
||||||
@rand = rand(100)
|
Pad.counter = 0
|
||||||
Pry.config.editor = lambda { |file, line|
|
Pry.config.editor = lambda { |file, line|
|
||||||
File.open(file, 'w') { |f| f << "$rand = #{@rand.inspect}" }
|
File.open(file, 'w') { |f| f << "Pad.counter = Pad.counter + 1" }
|
||||||
nil
|
nil
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should reload the file if it is a ruby file" do
|
it "should reload the file if it is a ruby file" do
|
||||||
temp_file do |tf|
|
temp_file do |tf|
|
||||||
path = tf.path
|
counter = Pad.counter
|
||||||
|
path = tf.path
|
||||||
|
|
||||||
pry_eval "edit #{path}"
|
pry_eval "edit #{path}"
|
||||||
|
|
||||||
$rand.should == @rand
|
Pad.counter.should == counter + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not reload the file if it is not a ruby file" do
|
it "should not reload the file if it is not a ruby file" do
|
||||||
temp_file('.py') do |tf|
|
temp_file('.py') do |tf|
|
||||||
path = tf.path
|
counter = Pad.counter
|
||||||
|
path = tf.path
|
||||||
|
|
||||||
pry_eval "edit #{path}"
|
pry_eval "edit #{path}"
|
||||||
|
|
||||||
$rand.should.not == @rand
|
Pad.counter.should == counter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not reload a ruby file if -n is given" do
|
it "should not reload a ruby file if -n is given" do
|
||||||
temp_file do |tf|
|
temp_file do |tf|
|
||||||
path = tf.path
|
counter = Pad.counter
|
||||||
pry_eval "edit -n #{path}"
|
path = tf.path
|
||||||
|
|
||||||
$rand.should.not == @rand
|
Pad.counter.should == counter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should reload a non-ruby file if -r is given" do
|
it "should reload a non-ruby file if -r is given" do
|
||||||
temp_file('.pryrc') do |tf|
|
temp_file('.pryrc') do |tf|
|
||||||
path = tf.path
|
counter = Pad.counter
|
||||||
|
path = tf.path
|
||||||
|
|
||||||
pry_eval "edit -r #{path}"
|
pry_eval "edit -r #{path}"
|
||||||
|
|
||||||
$rand.should == @rand
|
Pad.counter.should == counter + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue