Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 9382fbd

Browse files
Matt Remsik and Ethan Gundersondchelimsky
Matt Remsik and Ethan Gunderson
authored andcommitted
Add use_transactional_examples to configuration
This is a temp solution to support making transactional examples configurable in rspec-rails, but we need a more generic solution for extensions to add their own config options.
1 parent 86413c8 commit 9382fbd

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

lib/rspec/core/configuration.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def default_options
2727
{
2828
:color_enabled => false,
2929
:mock_framework => nil,
30+
:use_transactional_examples => true,
3031
:profile_examples => false,
3132
:files_to_run => [],
3233
:filename_pattern => '**/*_spec.rb',
@@ -51,6 +52,14 @@ def backtrace_clean_patterns
5152
def mock_framework=(use_me_to_mock)
5253
@options[:mock_framework] = use_me_to_mock
5354
end
55+
56+
def use_transactional_examples(value)
57+
@options[:use_transactional_examples] = value
58+
end
59+
60+
def use_transactional_examples?
61+
@options[:use_transactional_examples]
62+
end
5463

5564
def require_mock_framework_adapter
5665
require case @options[:mock_framework].to_s

rspec-core.gemspec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99

1010
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
1111
s.authors = ["Chad Humphries", "David Chelimsky"]
12-
s.date = %q{2010-03-17}
12+
s.date = %q{2010-03-23}
1313
s.description = %q{Rspec runner and example group classes}
1414
1515
s.executables = ["rspec", "spec"]
@@ -111,6 +111,7 @@ Gem::Specification.new do |s|
111111
"lib/rspec/core/formatters/base_formatter.rb",
112112
"lib/rspec/core/formatters/base_text_formatter.rb",
113113
"lib/rspec/core/formatters/documentation_formatter.rb",
114+
"lib/rspec/core/formatters/helpers.rb",
114115
"lib/rspec/core/formatters/progress_formatter.rb",
115116
"lib/rspec/core/hooks.rb",
116117
"lib/rspec/core/kernel_extensions.rb",
@@ -139,7 +140,9 @@ Gem::Specification.new do |s|
139140
"spec/rspec/core/example_group_subject_spec.rb",
140141
"spec/rspec/core/example_spec.rb",
141142
"spec/rspec/core/formatters/base_formatter_spec.rb",
143+
"spec/rspec/core/formatters/base_text_formatter_spec.rb",
142144
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
145+
"spec/rspec/core/formatters/helpers_spec.rb",
143146
"spec/rspec/core/formatters/progress_formatter_spec.rb",
144147
"spec/rspec/core/kernel_extensions_spec.rb",
145148
"spec/rspec/core/metadata_spec.rb",
@@ -185,7 +188,9 @@ Gem::Specification.new do |s|
185188
"spec/rspec/core/example_group_subject_spec.rb",
186189
"spec/rspec/core/example_spec.rb",
187190
"spec/rspec/core/formatters/base_formatter_spec.rb",
191+
"spec/rspec/core/formatters/base_text_formatter_spec.rb",
188192
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
193+
"spec/rspec/core/formatters/helpers_spec.rb",
189194
"spec/rspec/core/formatters/progress_formatter_spec.rb",
190195
"spec/rspec/core/kernel_extensions_spec.rb",
191196
"spec/rspec/core/metadata_spec.rb",

spec/rspec/core/configuration_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,19 @@ def that_thing
237237
end
238238
end
239239

240+
241+
context "transactional examples" do
242+
it "defaults to use transactional examples" do
243+
config.use_transactional_examples?.should be_true
244+
end
245+
describe "#use_transactional_examples=" do
246+
it "remembers that I don't want transactional exmaples" do
247+
config.use_transactional_examples false
248+
config.use_transactional_examples?.should be_false
249+
end
250+
end
251+
end
252+
240253
end
241254

242255
end

0 commit comments

Comments
 (0)