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

Commit 16888f9

Browse files
committed
Enable verify_partial_doubles config option.
1 parent 5eebff7 commit 16888f9

File tree

6 files changed

+15
-22
lines changed

6 files changed

+15
-22
lines changed

spec/rspec/core/configuration_spec.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,14 @@ def absolute_path_to(dir)
164164

165165
shared_examples "a configurable framework adapter" do |m|
166166
it "yields a config object if the framework_module supports it" do
167-
custom_config = Struct.new(:custom_setting).new
168167
mod = Module.new
169-
allow(mod).to receive_messages(:configuration => custom_config)
168+
def mod.configuration; @config ||= Struct.new(:custom_setting).new; end
170169

171170
config.send m, mod do |mod_config|
172171
mod_config.custom_setting = true
173172
end
174173

175-
expect(custom_config.custom_setting).to be_truthy
174+
expect(mod.configuration.custom_setting).to be_truthy
176175
end
177176

178177
it "raises if framework module doesn't support configuration" do
@@ -236,8 +235,7 @@ def absolute_path_to(dir)
236235

237236
it 'raises an error since this setting must be applied before any groups are defined' do
238237
allow(RSpec.world).to receive(:example_groups).and_return([double.as_null_object])
239-
mocha = stub_const("RSpec::Core::MockingAdapters::Mocha", Module.new)
240-
allow(mocha).to receive_messages(:framework_name => :mocha)
238+
class_double("RSpec::Core::MockingAdapters::Mocha", :framework_name => :mocha).as_stubbed_const
241239

242240
expect {
243241
config.mock_with :mocha
@@ -251,8 +249,7 @@ def absolute_path_to(dir)
251249
end
252250

253251
it 'does not raise an error if re-setting the same config' do
254-
mocha = stub_const("RSpec::Core::MockingAdapters::Mocha", Module.new)
255-
allow(mocha).to receive_messages(:framework_name => :mocha)
252+
class_double("RSpec::Core::MockingAdapters::Mocha", :framework_name => :mocha).as_stubbed_const
256253

257254
groups = []
258255
allow(RSpec.world).to receive_messages(:example_groups => groups)

spec/rspec/core/example_group_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ def ascending_numbers
494494
context "with no filters" do
495495
it "returns all" do
496496
group = RSpec.describe
497-
allow(group).to receive(:world) { self.world }
498497
example = group.example("does something")
499498
expect(group.filtered_examples).to eq([example])
500499
end
@@ -506,7 +505,6 @@ def ascending_numbers
506505
filter_manager.include :awesome => false
507506
allow(self.world).to receive_messages(:filter_manager => filter_manager)
508507
group = RSpec.describe
509-
allow(group).to receive(:world) { self.world }
510508
group.example("does something")
511509
expect(group.filtered_examples).to eq([])
512510
end

spec/rspec/core/formatters/documentation_formatter_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module RSpec::Core::Formatters
66

77
before do
88
send_notification :start, start_notification(2)
9-
allow(formatter).to receive(:color_enabled?).and_return(false)
109
end
1110

1211
def execution_result(values)

spec/rspec/core/formatters/progress_formatter_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
before do
77
send_notification :start, start_notification(2)
8-
allow(formatter).to receive(:color_enabled?).and_return(false)
98
end
109

1110
it 'prints a . on example_passed' do

spec/rspec/core/memoized_helpers_spec.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,14 @@ def working_with?(double)
113113
[false, nil].each do |falsy_value|
114114
context "with a value of #{falsy_value.inspect}" do
115115
it "is evaluated once per example" do
116-
example_group = RSpec.describe(Array)
117-
example_group.before do
118-
expect(Object).to receive(:this_question?).once.and_return(falsy_value)
119-
end
120-
example_group.subject do
121-
Object.this_question?
122-
end
123-
example_group.example do
124-
subject
125-
subject
116+
subject_calls = 0
117+
118+
describe_successfully do
119+
subject { subject_calls += 1; falsy_value }
120+
example { subject; subject }
126121
end
127-
expect(example_group.run).to be_truthy, "expected subject block to be evaluated only once"
122+
123+
expect(subject_calls).to eq(1)
128124
end
129125
end
130126
end

spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ def handle_current_dir_change
9595
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
9696
end
9797

98+
c.mock_with :rspec do |mocks|
99+
mocks.verify_partial_doubles = true
100+
end
101+
98102
c.around(:example, :simulate_shell_allowing_unquoted_ids) do |ex|
99103
with_env_vars('SHELL' => '/usr/local/bin/bash', &ex)
100104
end

0 commit comments

Comments
 (0)