Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use metadata/filtering to filter out Ruby-version dependent examples.

  • Loading branch information...
commit a7a8b4faea2ce392f556ada2d4d259c0cea94159 1 parent 47f0b2a
@dchelimsky dchelimsky authored
View
4 lib/rspec/core/configuration.rb
@@ -2,10 +2,10 @@ module Rspec
module Core
class Configuration
# Control what examples are run by filtering
- attr_reader :filter
+ attr_accessor :filter
# Control what examples are not run by filtering
- attr_reader :exclusion_filter
+ attr_accessor :exclusion_filter
# Run all examples if the run is filtered, and no examples were found.
attr_writer :run_all_when_everything_filtered
View
13 spec/rspec/core/example_group_spec.rb
@@ -300,13 +300,12 @@ def stub_example_group
@before_all_top_level.should == 'before_all_top_level'
end
- it "should be able to access the before all ivars in the before_all_ivars hash" do
- with_ruby('1.8') do
- running_example.example_group.before_all_ivars.should include('@before_all_top_level' => 'before_all_top_level')
- end
- with_ruby('1.9') do
- running_example.example_group.before_all_ivars.should include(:@before_all_top_level => 'before_all_top_level')
- end
+ it "should be able to access the before all ivars in the before_all_ivars hash", :ruby => 1.8 do
+ running_example.example_group.before_all_ivars.should include('@before_all_top_level' => 'before_all_top_level')
+ end
+
+ it "should be able to access the before all ivars in the before_all_ivars hash", :ruby => 1.9 do
+ running_example.example_group.before_all_ivars.should include(:@before_all_top_level => 'before_all_top_level')
end
describe "but now I am nested" do
View
24 spec/rspec/core/shared_example_group_spec.rb
@@ -41,7 +41,7 @@ def cleanup_shared_example_groups
Rspec::Core.world.shared_example_groups.replace(original_shared_example_groups)
end
- it "should make any shared example_group available at the correct level" do
+ it "should make any shared example_group available at the correct level", :ruby => 1.8 do
group = ExampleGroup.create('fake group')
block = lambda {
def self.class_helper; end
@@ -49,14 +49,20 @@ def extra_helper; end
}
Rspec::Core.world.stub(:shared_example_groups).and_return({ :shared_example_group => block })
group.it_should_behave_like :shared_example_group
- with_ruby(1.8) do
- group.instance_methods.should include('extra_helper')
- group.singleton_methods.should include('class_helper')
- end
- with_ruby(1.9) do
- group.instance_methods.should include(:extra_helper)
- group.singleton_methods.should include(:class_helper)
- end
+ group.instance_methods.should include('extra_helper')
+ group.singleton_methods.should include('class_helper')
+ end
+
+ it "should make any shared example_group available at the correct level", :ruby => 1.9 do
+ group = ExampleGroup.create('fake group')
+ block = lambda {
+ def self.class_helper; end
+ def extra_helper; end
+ }
+ Rspec::Core.world.stub(:shared_example_groups).and_return({ :shared_example_group => block })
+ group.it_should_behave_like :shared_example_group
+ group.instance_methods.should include(:extra_helper)
+ group.singleton_methods.should include(:class_helper)
end
it "should raise when named shared example_group can not be found"
View
9 spec/spec_helper.rb
@@ -8,10 +8,6 @@
Rspec::Core::ExampleGroup.send(:include, Rspec::Matchers)
-def with_ruby(version)
- yield if RUBY_VERSION.to_s =~ Regexp.compile("^#{version}")
-end
-
module Rspec
module Core
module Matchers
@@ -40,7 +36,8 @@ def in_editor?
Rspec.configure do |c|
c.mock_framework = :rspec
- c.filter_run :focused => true
- c.run_all_when_everything_filtered = true
c.color_enabled = !in_editor?
+ c.exclusion_filter = { :ruby => lambda {|version|
+ !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
+ }}
end
Please sign in to comment.
Something went wrong with that request. Please try again.