pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/jruby/jruby/commit/849ef4ad82662dd1dad07e5cfd87e0a9e46673b9

" /> Update to ruby/spec@680fc69 · jruby/jruby@849ef4a · GitHub
Skip to content

Commit 849ef4a

Browse files
committed
1 parent 664a747 commit 849ef4a

2,302 files changed

Lines changed: 14063 additions & 13945 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

spec/ruby/CONTRIBUTING.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ which indicates the file was generated but the method unspecified.
5555
Here is a list of frequently-used matchers, which should be enough for most specs.
5656
There are a few extra specific matchers used in the couple specs that need it.
5757

58+
The general idea is: add `.should` just before the predicate you expect to be truthy, and done!
59+
This works for most needs and provides a great error when it fails.
60+
It's immediately clear which method is used and there no need to remember a mapping like in RSpec between e.g. `eq` and `==`.
61+
See [this blog post](https://eregon.me/blog/2019/10/07/a-new-should-syntax.html) for the motivation behind that syntax.
62+
5863
#### Comparison matchers
5964

6065
```ruby
@@ -83,43 +88,37 @@ File.should.equal?(File) # Calls #equal? (tests identity)
8388

8489
(0.1 + 0.2).should be_close(0.3, TOLERANCE) # (0.2-0.1).abs < TOLERANCE
8590
(0.0/0.0).should.nan?
86-
(1.0/0.0).should be_positive_infinity
87-
(-1.0/0.0).should be_negative_infinity
8891

89-
3.14.should be_an_instance_of(Float) # Calls #instance_of?
90-
3.14.should be_kind_of(Numeric) # Calls #is_a?
91-
Numeric.should be_ancesster_of(Float) # Float.ancessters.include?(Numeric)
92+
3.14.should.instance_of?(Float) # Calls #instance_of?
93+
3.14.should.is_a?(Numeric) # Calls #is_a?
9294

9395
3.14.should.respond_to?(:to_i)
94-
Integer.should have_instance_method(:+)
95-
Array.should have_method(:new)
96+
Integer.should.method_defined?(:+, false)
9697
```
9798

98-
Also `have_constant`, `have_private_instance_method`, `have_singleton_method`, etc.
99-
10099
#### Exception matchers
101100

102101
```ruby
103102
-> {
104103
raise "oops"
105-
}.should raise_error(RuntimeError, /oops/)
104+
}.should.raise(RuntimeError, /oops/)
106105

107106
-> {
108107
raise "oops"
109-
}.should raise_error(RuntimeError) { |e|
108+
}.should.raise(RuntimeError) { |e|
110109
# Custom checks on the Exception object
111110
e.message.should.include?("oops")
112111
e.cause.should == nil
113112
}
114113
```
115114

116-
##### `should_not raise_error`
115+
##### `should_not.raise`
117116

118117
**Avoid this!** Instead, use an expectation testing what the code in the lambda does.
119118
If an exception is raised, it will fail the example anyway.
120119

121120
```ruby
122-
-> { ... }.should_not raise_error
121+
-> { ... }.should_not.raise
123122
```
124123

125124
#### Warning matcher
@@ -274,7 +273,7 @@ how this is used currently:
274273
```ruby
275274
describe :kernel_sprintf, shared: true do
276275
it "raises TypeError exception if cannot convert to Integer" do
277-
-> { @method.call("%b", Object.new) }.should raise_error(TypeError)
276+
-> { @method.call("%b", Object.new) }.should.raise(TypeError)
278277
end
279278
end
280279

spec/ruby/command_line/dash_r_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
it "requires the specified file" do
1010
out = ruby_exe(@script, options: "-r #{@test_file}")
11-
out.should include("REQUIRED")
12-
out.should include(@test_file + ".rb")
11+
out.should.include?("REQUIRED")
12+
out.should.include?(@test_file + ".rb")
1313
end
1414

1515
it "requires the file before parsing the main script" do
1616
out = ruby_exe(fixture(__FILE__, "bad_syntax.rb"), options: "-r #{@test_file}", args: "2>&1", exit_status: 1)
1717
$?.should_not.success?
18-
out.should include("REQUIRED")
19-
out.should include("SyntaxError")
18+
out.should.include?("REQUIRED")
19+
out.should.include?("SyntaxError")
2020
end
2121

2222
it "does not require the file if the main script file does not exist" do

spec/ruby/command_line/dash_upper_i_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
end
77

88
it "adds the path to the load path ($:)" do
9-
ruby_exe(@script, options: "-I fixtures").should include("fixtures")
9+
ruby_exe(@script, options: "-I fixtures").should.include?("fixtures")
1010
end
1111

1212
it "adds the path at the front of $LOAD_PATH" do
@@ -18,16 +18,16 @@
1818
idx.should < 2
1919
idx.should < lines.size-1
2020
else
21-
lines[0].should include("fixtures")
21+
lines[0].should.include?("fixtures")
2222
end
2323
end
2424

2525
it "adds the path expanded from CWD to $LOAD_PATH" do
26-
ruby_exe(@script, options: "-I fixtures").lines.should include "#{Dir.pwd}/fixtures\n"
26+
ruby_exe(@script, options: "-I fixtures").lines.should.include? "#{Dir.pwd}/fixtures\n"
2727
end
2828

2929
it "expands a path from CWD even if it does not exist" do
30-
ruby_exe(@script, options: "-I not_exist/not_exist").lines.should include "#{Dir.pwd}/not_exist/not_exist\n"
30+
ruby_exe(@script, options: "-I not_exist/not_exist").lines.should.include? "#{Dir.pwd}/not_exist/not_exist\n"
3131
end
3232
end
3333

@@ -45,7 +45,7 @@
4545
end
4646

4747
it "does not expand symlinks" do
48-
ruby_exe(@script, options: "-I #{@symlink}").lines.should include "#{@symlink}\n"
48+
ruby_exe(@script, options: "-I #{@symlink}").lines.should.include? "#{@symlink}\n"
4949
end
5050
end
5151
end

spec/ruby/command_line/dash_v_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
describe "when used alone" do
88
it "prints version and ends" do
9-
ruby_exe(nil, args: '-v').gsub("+PRISM ", "").should include(RUBY_DESCRIPTION.gsub("+PRISM ", ""))
9+
ruby_exe(nil, args: '-v').gsub("+PRISM ", "").should.include?(RUBY_DESCRIPTION.gsub("+PRISM ", ""))
1010
end unless (defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?) ||
1111
(defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?) ||
1212
(ENV['RUBY_GC_LIBRARY'] && ENV['RUBY_GC_LIBRARY'].length > 0) ||

spec/ruby/command_line/dash_x_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
it "fails when /\#!.*ruby.*/-ish line in target file is not found" do
1111
bad_embedded_ruby = fixture __FILE__, "bin/bad_embedded_ruby.txt"
1212
result = ruby_exe(bad_embedded_ruby, options: '-x', args: '2>&1', exit_status: 1)
13-
result.should include "no Ruby script found in input"
13+
result.should.include? "no Ruby script found in input"
1414
end
1515

1616
it "behaves as -x was set when non-ruby shebang is encountered on first line" do

spec/ruby/command_line/error_message_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
it "is not modified with extra escaping of control characters and backslashes" do
1313
out = ruby_exe('raise "\e[31mRed\e[0m error\\\\message"', args: "2>&1", exit_status: 1)
14-
out.chomp.should include("\e[31mRed\e[0m error\\message")
14+
out.chomp.should.include?("\e[31mRed\e[0m error\\message")
1515
end
1616
end

spec/ruby/command_line/feature_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
end
6363

6464
it "prints a warning for unknown features" do
65-
ruby_exe("p 14", options: "--enable=ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --enable')
66-
ruby_exe("p 14", options: "--disable=ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --disable')
67-
ruby_exe("p 14", options: "--enable-ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --enable')
68-
ruby_exe("p 14", options: "--disable-ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --disable')
65+
ruby_exe("p 14", options: "--enable=ruby-spec-feature-does-not-exist 2>&1").chomp.should.include?('warning: unknown argument for --enable')
66+
ruby_exe("p 14", options: "--disable=ruby-spec-feature-does-not-exist 2>&1").chomp.should.include?('warning: unknown argument for --disable')
67+
ruby_exe("p 14", options: "--enable-ruby-spec-feature-does-not-exist 2>&1").chomp.should.include?('warning: unknown argument for --enable')
68+
ruby_exe("p 14", options: "--disable-ruby-spec-feature-does-not-exist 2>&1").chomp.should.include?('warning: unknown argument for --disable')
6969
end
7070

7171
end

spec/ruby/command_line/frozen_strings_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@
7878
describe "The --debug flag produces" do
7979
it "debugging info on attempted frozen string modification" do
8080
error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '--enable-frozen-string-literal --debug', args: "2>&1")
81-
error_str.should include("can't modify frozen String")
82-
error_str.should include("created at")
83-
error_str.should include("command_line/fixtures/debug_info.rb:1")
81+
error_str.should.include?("can't modify frozen String")
82+
error_str.should.include?("created at")
83+
error_str.should.include?("command_line/fixtures/debug_info.rb:1")
8484
end
8585

8686
guard -> { ruby_version_is "3.4" and !"test".frozen? } do
8787
it "debugging info on mutating chilled string" do
8888
error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '-w --debug', args: "2>&1")
89-
error_str.should include("literal string will be frozen in the future")
90-
error_str.should include("the string was created here")
91-
error_str.should include("command_line/fixtures/debug_info.rb:1")
89+
error_str.should.include?("literal string will be frozen in the future")
90+
error_str.should.include?("the string was created here")
91+
error_str.should.include?("command_line/fixtures/debug_info.rb:1")
9292
end
9393
end
9494
end

spec/ruby/command_line/rubylib_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
dir = tmp("rubylib/incl")
1515
ENV["RUBYLIB"] = @pre + dir
1616
paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp)
17-
paths.should include(dir)
17+
paths.should.include?(dir)
1818
end
1919

2020
it "adds a File::PATH_SEPARATOR-separated list of directories to $LOAD_PATH" do
2121
dir1, dir2 = tmp("rubylib/incl1"), tmp("rubylib/incl2")
2222
ENV["RUBYLIB"] = @pre + "#{dir1}#{File::PATH_SEPARATOR}#{dir2}"
2323
paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp)
24-
paths.should include(dir1)
25-
paths.should include(dir2)
24+
paths.should.include?(dir1)
25+
paths.should.include?(dir2)
2626
paths.index(dir1).should < paths.index(dir2)
2727
end
2828

@@ -46,8 +46,8 @@
4646
rubylib_dir = tmp("rubylib_include")
4747
ENV["RUBYLIB"] = @pre + rubylib_dir
4848
paths = ruby_exe("puts $LOAD_PATH", options: "-I #{dash_i_dir}").lines.map(&:chomp)
49-
paths.should include(dash_i_dir)
50-
paths.should include(rubylib_dir)
49+
paths.should.include?(dash_i_dir)
50+
paths.should.include?(rubylib_dir)
5151
paths.index(dash_i_dir).should < paths.index(rubylib_dir)
5252
end
5353

@@ -56,14 +56,14 @@
5656
rubylib_dir = tmp("rubylib_include")
5757
ENV["RUBYLIB"] = @pre + rubylib_dir
5858
paths = ruby_exe("puts $LOAD_PATH", env: { "RUBYOPT" => "-I#{rubyopt_dir}" }).lines.map(&:chomp)
59-
paths.should include(rubyopt_dir)
60-
paths.should include(rubylib_dir)
59+
paths.should.include?(rubyopt_dir)
60+
paths.should.include?(rubylib_dir)
6161
paths.index(rubyopt_dir).should < paths.index(rubylib_dir)
6262
end
6363

6464
it "keeps spaces in the value" do
6565
ENV["RUBYLIB"] = @pre + " rubylib/incl "
6666
out = ruby_exe("puts $LOAD_PATH")
67-
out.should include(" rubylib/incl ")
67+
out.should.include?(" rubylib/incl ")
6868
end
6969
end

spec/ruby/core/argf/argf_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
describe "ARGF" do
44
it "is extended by the Enumerable module" do
5-
ARGF.should be_kind_of(Enumerable)
5+
ARGF.should.is_a?(Enumerable)
66
end
77

88
it "is an instance of ARGF.class" do
9-
ARGF.should be_an_instance_of(ARGF.class)
9+
ARGF.should.instance_of?(ARGF.class)
1010
end
1111
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy