File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 22
33RSpec . describe Bundler ::Plugin ::Events do
44 context "plugin events" do
5- before { Bundler ::Plugin ::Events . send :reset }
5+ before do
6+ @old_constants = Bundler ::Plugin ::Events . constants . map { |name | [ name , Bundler ::Plugin ::Events . const_get ( name ) ] }
7+ Bundler ::Plugin ::Events . send :reset
8+ end
9+
10+ after do
11+ Bundler ::Plugin ::Events . send ( :reset )
12+ Hash [ @old_constants ] . each do |name , value |
13+ Bundler ::Plugin ::Events . send ( :define , name , value )
14+ end
15+ end
616
717 describe "#define" do
818 it "raises when redefining a constant" do
Original file line number Diff line number Diff line change 279279 s . write "plugins.rb" , code
280280 end
281281
282+ @old_constants = Bundler ::Plugin ::Events . constants . map { |name | [ name , Bundler ::Plugin ::Events . const_get ( name ) ] }
282283 Bundler ::Plugin ::Events . send ( :reset )
283284 Bundler ::Plugin ::Events . send ( :define , :EVENT1 , "event-1" )
284285 Bundler ::Plugin ::Events . send ( :define , :EVENT2 , "event-2" )
291292 allow ( index ) . to receive ( :load_paths ) . with ( "foo-plugin" ) . and_return ( [ ] )
292293 end
293294
295+ after do
296+ Bundler ::Plugin ::Events . send ( :reset )
297+ Hash [ @old_constants ] . each do |name , value |
298+ Bundler ::Plugin ::Events . send ( :define , name , value )
299+ end
300+ end
301+
294302 let ( :code ) { <<-RUBY }
295303 Bundler::Plugin::API.hook("event-1") { puts "hook for event 1" }
296304 RUBY
You can’t perform that action at this time.
0 commit comments