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

Commit 137a9af

Browse files
committed
Fix our specs
1 parent 07c0a55 commit 137a9af

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

spec/rspec/core/example_group_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ def metadata_hash(*args)
5656
end
5757

5858
it 'does not treat the first argument as a metadata key even if it is a symbol' do
59-
group = RSpec.describe(:symbol)
59+
group = with_an_expected_warning { RSpec.describe(:symbol) }
6060
expect(group.metadata).not_to include(:symbol)
6161
end
6262

6363
it 'treats the first argument as part of the description when it is a symbol' do
64-
group = RSpec.describe(:symbol)
64+
group = with_an_expected_warning { RSpec.describe(:symbol) }
6565
expect(group.description).to eq("symbol")
6666
end
6767

spec/rspec/core/hooks_filtering_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ module RSpec::Core
313313
c.after(:each, :match => false) { filters << "after each in config"}
314314
c.after(:all, :match => false) { filters << "after all in config"}
315315
end
316-
group = RSpec.describe(:match => true)
316+
group = RSpec.describe('example group', :match => true)
317317
group.example("example") {}
318318
group.run
319319
expect(filters).to eq([])

spec/rspec/core/memoized_helpers_spec.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module RSpec::Core
55
before(:each) { RSpec.configuration.configure_expectation_framework }
66

77
def subject_value_for(describe_arg, &block)
8-
example_group = RSpec.describe(describe_arg, &block)
8+
example_group = with_an_expected_warning { RSpec.describe(describe_arg, &block) }
99
subject_value = nil
1010
example_group.example { subject_value = subject }
1111
example_group.run
@@ -340,10 +340,16 @@ def not_ok?; false; end
340340
end
341341

342342
it 'supports a new expect-based syntax' do
343-
group = RSpec.describe([1, 2, 3]) do
344-
it { is_expected.to be_an Array }
345-
it { is_expected.not_to include 4 }
343+
math_class = Class.new do
344+
def easy?
345+
false
346+
end
346347
end
348+
group =
349+
RSpec.describe(math_class) do
350+
it { is_expected.to be_a math_class }
351+
it { is_expected.to_not be_easy }
352+
end
347353

348354
expect(group.run).to be true
349355
end

spec/rspec/core/metadata_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,24 +381,24 @@ def metadata_for(*args)
381381

382382
context "with a String" do
383383
it "returns nil" do
384-
expect(value_for "group").to be_nil
384+
expect(value_for("group")).to be_nil
385385
end
386386
end
387387

388388
context "with a Symbol" do
389389
it "returns the symbol" do
390-
expect(value_for :group).to be(:group)
390+
expect(with_an_expected_warning { value_for(:group) }).to be(:group)
391391
end
392392
end
393393

394394
context "with a class" do
395395
it "returns the class" do
396-
expect(value_for String).to be(String)
396+
expect(value_for(String)).to be(String)
397397
end
398398

399399
context "when the class is Regexp" do
400400
it "returns the class" do
401-
expect(value_for Regexp).to be(Regexp)
401+
expect(value_for(Regexp)).to be(Regexp)
402402
end
403403
end
404404
end
@@ -636,7 +636,7 @@ def group_value_for(*args)
636636
it "finds the first non-rspec lib file in the caller array" do
637637
value = nil
638638

639-
RSpec.describe(:caller => ["./lib/rspec/core/foo.rb", "#{__FILE__}:#{__LINE__}"]) do
639+
RSpec.describe('example group', :caller => ["./lib/rspec/core/foo.rb", "#{__FILE__}:#{__LINE__}"]) do
640640
value = metadata[:file_path]
641641
end
642642

spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def handle_current_dir_change
6262
ensure
6363
RSpec::Core::Metadata.instance_variable_set(:@relative_path_regex, nil)
6464
end
65+
66+
def with_an_expected_warning
67+
with_isolated_stderr { yield }
68+
end
6569
end
6670

6771
RSpec.configure do |c|

0 commit comments

Comments
 (0)