Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Module inclusion should only require matching one filter

  • Loading branch information...
commit 4e010e0a079d5b25414dd48303ab3ca4e9f125bf 1 parent d17dbec
@dchelimsky dchelimsky authored
View
9 lib/rspec/core/configuration.rb
@@ -308,14 +308,13 @@ def extend(mod, filters={})
def configure_group(group)
modules = {
- :include => [] + group.included_modules,
- :extend => [] + group.ancestors
+ :include => group.included_modules.dup,
+ :extend => group.ancestors.dup
}
include_or_extend_modules.each do |include_or_extend, mod, filters|
- next unless group.apply?(:all?, filters)
- next if modules[include_or_extend].include?(mod)
- modules[include_or_extend] << mod
+ next unless filters.empty? || group.apply?(:any?, filters)
+ next if self.class < mod
group.send(include_or_extend, mod)
end
end
View
13 spec/rspec/core/configuration_spec.rb
@@ -638,7 +638,7 @@ def that_thing
end
describe "#configure_group" do
- it "extends with modules" do
+ it "extends with 'extend'" do
mod = Module.new
group = ExampleGroup.describe("group", :foo => :bar)
@@ -647,7 +647,7 @@ def that_thing
group.should be_a(mod)
end
- it "includes modules" do
+ it "extends with 'module'" do
mod = Module.new
group = ExampleGroup.describe("group", :foo => :bar)
@@ -656,6 +656,15 @@ def that_thing
group.included_modules.should include(mod)
end
+ it "requires only one matching filter" do
+ mod = Module.new
+ group = ExampleGroup.describe("group", :foo => :bar)
+
+ config.include(mod, :foo => :bar, :baz => :bam)
+ config.configure_group(group)
+ group.included_modules.should include(mod)
+ end
+
it "includes each one before deciding whether to include the next" do
mod1 = Module.new do
def self.included(host)
Please sign in to comment.
Something went wrong with that request. Please try again.