Don't require ActiveResource tests under Rails 5

This commit is contained in:
Elliot Winkler 2016-09-03 21:35:13 -06:00
parent 26522c6b78
commit 98ef8f67da
4 changed files with 20 additions and 9 deletions

View File

@ -1,8 +1,8 @@
require 'active_resource'
module UnitTests module UnitTests
module ActiveResourceBuilder module ActiveResourceBuilder
def self.configure_example_group(example_group) def self.configure_example_group(example_group)
require 'active_resource'
example_group.include ActiveResourceBuilder example_group.include ActiveResourceBuilder
example_group.after do example_group.after do

View File

@ -1,5 +1,7 @@
module UnitTests module UnitTests
module RailsVersions module RailsVersions
extend self
def self.configure_example_group(example_group) def self.configure_example_group(example_group)
example_group.include(self) example_group.include(self)
example_group.extend(self) example_group.extend(self)
@ -16,6 +18,10 @@ module UnitTests
def rails_4_x? def rails_4_x?
rails_version =~ '~> 4.0' rails_version =~ '~> 4.0'
end end
j
def rails_lte_4?
rails_version <= 4
end
def rails_gte_4_1? def rails_gte_4_1?
rails_version >= 4.1 rails_version >= 4.1

View File

@ -291,12 +291,14 @@ raising a validation exception on failure.
end end
end end
context 'an active_resource model' do if rails_lte_4?
context 'with the validation context' do context 'an active_resource model' do
it 'does not raise an exception' do context 'with the validation context' do
expect { it 'does not raise an exception' do
expect(active_resource_model).to validate_presence_of(:attr) expect {
}.to_not raise_exception expect(active_resource_model).to validate_presence_of(:attr)
}.to_not raise_exception
end
end end
end end
end end

View File

@ -12,7 +12,6 @@ end
RSpec.configure do |config| RSpec.configure do |config|
UnitTests::ActiveModelHelpers.configure_example_group(config) UnitTests::ActiveModelHelpers.configure_example_group(config)
UnitTests::ActiveModelVersions.configure_example_group(config) UnitTests::ActiveModelVersions.configure_example_group(config)
UnitTests::ActiveResourceBuilder.configure_example_group(config)
UnitTests::ClassBuilder.configure_example_group(config) UnitTests::ClassBuilder.configure_example_group(config)
UnitTests::ControllerBuilder.configure_example_group(config) UnitTests::ControllerBuilder.configure_example_group(config)
UnitTests::I18nFaker.configure_example_group(config) UnitTests::I18nFaker.configure_example_group(config)
@ -25,6 +24,10 @@ RSpec.configure do |config|
UnitTests::ColumnTypeHelpers.configure_example_group(config) UnitTests::ColumnTypeHelpers.configure_example_group(config)
UnitTests::ValidationMatcherScenarioHelpers.configure_example_group(config) UnitTests::ValidationMatcherScenarioHelpers.configure_example_group(config)
if UnitTests::RailsVersions.rails_lte_4?
UnitTests::ActiveResourceBuilder.configure_example_group(config)
end
config.include UnitTests::Matchers config.include UnitTests::Matchers
config.infer_spec_type_from_file_location! config.infer_spec_type_from_file_location!