diff --git a/LICENSE.txt b/LICENSE.txt index 6bd491e8afd..d0f52376aa9 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -245,31 +245,6 @@ copyright and license notice: --- -spec/support/with_constants.rb copyright (c) 2010 Michael Portuesi -and released under the MIT license: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - ---- - - Portions of tools/dba.rb are covered by the following copyright and license notice: diff --git a/spec/migrations/20160127210624_convert_configurations_to_settings_changes_spec.rb b/spec/migrations/20160127210624_convert_configurations_to_settings_changes_spec.rb index e04b5074cb1..c00582e8098 100644 --- a/spec/migrations/20160127210624_convert_configurations_to_settings_changes_spec.rb +++ b/spec/migrations/20160127210624_convert_configurations_to_settings_changes_spec.rb @@ -56,9 +56,14 @@ "simple" => YAML.load_file(data_dir.join("simple.tmpl.yml")).deep_symbolize_keys, "vmdb" => YAML.load_file(data_dir.join("simple.tmpl.yml")).deep_symbolize_keys } - described_class.with_constants(:TEMPLATES => test_templates) do - migrate - end + + # capture stdout, because stub_const will trigger method_missing in active_record/migration.rb + # at https://github.com/rails/rails/blob/efcf71fb64319519784fe1c69fd66f36fb52e47a/activerecord/lib/active_record/migration.rb#L838 + # which calls `say_with_time` + $stdout = StringIO.new + stub_const('ConvertConfigurationsToSettingsChanges::TEMPLATES', test_templates) + migrate + $stdout = STDOUT expect(settings_change_stub.count).to eq(12) diff --git a/spec/support/with_constants.rb b/spec/support/with_constants.rb deleted file mode 100644 index af3b68a186d..00000000000 --- a/spec/support/with_constants.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# Allows temporarily overriding constants for a particular test. -# Gleaned from http://digitaldumptruck.jotabout.com/?p=551 -# -# Example: -# it "does not allow links to be added in production environment" do -# Object.with_constants :RAILS_ENV => 'production' do -# get :add, @nonexistent_link.url -# response.should_not be_success -# end -# end -# -class Module - def with_constants(constants, &block) - saved_constants = {} - constants.each do |constant, val| - saved_constants[constant] = const_get(constant) - Kernel.silence_warnings { const_set(constant, val) } - end - - begin - block.call - ensure - constants.each do |constant, _val| - Kernel.silence_warnings { const_set(constant, saved_constants[constant]) } - end - end - end -end