Reloading classes in RSpec August 11, 2008
Posted by John Dewey in Code, Example, RSpec, Ruby.trackback
I had a class where methods could change a class variable’s structure on load. However, RSpec doesn’t reload a class, so testing
these methods is difficult.
One can reload a class inside RSpec by adding a before task:
describe SimplyTabby, "remove_system_information class method" do
before(:each) do
Object.send(:remove_const, 'Clazz')
load 'clazz.rb'
end
it "should ..."
...
end
end
Comments»
No comments yet — be the first.