On Apr 23, 2011, at 11:45 AM, David Chelimsky wrote:
> On Apr 23, 2011, at 10:26 AM, Matthew Van Horn wrote:
>
>> On Apr 23, 2011, at 10:40 AM, Matthew Van Horn wrote:
>>
>>> def self.nullify_contextually?(other)
>>> rspec_root = defined?(RSpec) ? RSpec : Spec
>>> if defined? rspec_root::Rails::RailsExampleGroup
>>> other.ancestors.include?(rspec_root::Rails::RailsExampleGroup)
>>> else
>>> other.ancestors.include?(rspec_root::Rails::ModelExampleGroup) ||
>>> other.ancestors.include?(rspec_root::Rails::ControllerExampleGroup)
>>> ||
>>> other.ancestors.include?(rspec_root::Rails::ViewExampleGroup) ||
>>> other.ancestors.include?(rspec_root::Rails::HelperExampleGroup)
>>> end
>>> end
>>
>> Changing 'ancestors' to 'included_modules' seems to make this work for me.
>> ancestors is returning a one-element array with an anonymous class in it.
>> included_modules is returning what I'd expect
>> [NullDB::RSpec::NullifiedDatabase, RSpec::Rails::ModelExampleGroup,
>> RSpec::Rails::RailsExampleGroup... etc]
>> Could this be a ruby version thing?
>> I'm using ree 1.8.7 for the moment.
>
> More likely an execution order issue than a Ruby version issue. RSpec tells
> each example group to include the modules listed in included_modules. If
> nullify_contextually? is invoked before that happens, the modules will be in
> the included_modules Array, but will be included yet, so ancestors would not
> return them. Make sense?
Probably makes more sense to Myron, but I understand what you're saying.
-- matt
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users