Skip to content

Commit f5d4634

Browse files
committed
1 parent b04b92e commit f5d4634

File tree

10 files changed

+70
-68
lines changed

10 files changed

+70
-68
lines changed

spec/ruby/.mspec.constants

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ EvalBindingProcA
7373
Exception2MessageMapper
7474
ExceptionForMatrix
7575
Fcntl
76+
Fiddle
7677
FileStat
7778
FileUtils
7879
Find

spec/ruby/core/dir/read_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
Encoding.default_external = Encoding::SHIFT_JIS
5757
shift_jis_entries = []
5858
begin
59-
Dir.open(File.join(DirSpecs.mock_dir, 'special')) do |dir|
59+
Dir.open(File.join(DirSpecs.mock_dir, 'special')) do |d|
6060
-> {
61-
while entry = dir.read
61+
while entry = d.read
6262
shift_jis_entries << entry
6363
end
6464
}.should_not raise_error

spec/ruby/core/exception/interrupt_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@
4949
out.should == "Interrupt: #{Signal.list["INT"]}\n"
5050
end
5151

52-
it "shows the backtrace and has a signaled exit status" do
53-
err = IO.popen([*ruby_exe, '-e', 'Process.kill :INT, Process.pid; sleep'], err: [:child, :out], &:read)
54-
$?.termsig.should == Signal.list.fetch('INT')
55-
err.should.include? ': Interrupt'
56-
err.should.include? "from -e:1:in `<main>'"
52+
platform_is_not :windows do
53+
it "shows the backtrace and has a signaled exit status" do
54+
err = IO.popen([*ruby_exe, '-e', 'Process.kill :INT, Process.pid; sleep'], err: [:child, :out], &:read)
55+
$?.termsig.should == Signal.list.fetch('INT')
56+
err.should.include? ': Interrupt'
57+
err.should.include? "from -e:1:in `<main>'"
58+
end
5759
end
5860
end

spec/ruby/core/rational/minus_spec.rb

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,51 @@
1-
require_relative '../../shared/rational/minus'
1+
require_relative '../../spec_helper'
22
require_relative '../../shared/rational/arithmetic_exception_in_coerce'
33

44
describe "Rational#-" do
5-
it_behaves_like :rational_minus, :-
65
it_behaves_like :rational_arithmetic_exception_in_coerce, :-
6+
7+
it "calls #coerce on the passed argument with self" do
8+
rational = Rational(3, 4)
9+
obj = mock("Object")
10+
obj.should_receive(:coerce).with(rational).and_return([1, 2])
11+
12+
rational - obj
13+
end
14+
15+
it "calls #- on the coerced Rational with the coerced Object" do
16+
rational = Rational(3, 4)
17+
18+
coerced_rational = mock("Coerced Rational")
19+
coerced_rational.should_receive(:-).and_return(:result)
20+
21+
coerced_obj = mock("Coerced Object")
22+
23+
obj = mock("Object")
24+
obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
25+
26+
(rational - obj).should == :result
27+
end
28+
end
29+
30+
describe "Rational#- passed a Rational" do
31+
it "returns the result of subtracting other from self as a Rational" do
32+
(Rational(3, 4) - Rational(0, 1)).should eql(Rational(3, 4))
33+
(Rational(3, 4) - Rational(1, 4)).should eql(Rational(1, 2))
34+
35+
(Rational(3, 4) - Rational(2, 1)).should eql(Rational(-5, 4))
36+
end
37+
end
38+
39+
describe "Rational#- passed a Float" do
40+
it "returns the result of subtracting other from self as a Float" do
41+
(Rational(3, 4) - 0.2).should eql(0.55)
42+
(Rational(3, 4) - 2.5).should eql(-1.75)
43+
end
44+
end
45+
46+
describe "Rational#- passed an Integer" do
47+
it "returns the result of subtracting other from self as a Rational" do
48+
(Rational(3, 4) - 1).should eql(Rational(-1, 4))
49+
(Rational(3, 4) - 2).should eql(Rational(-5, 4))
50+
end
751
end

spec/ruby/core/string/shared/to_sym.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@
5353
sym.to_s.should == binary_string
5454
end
5555

56+
it "ignores exising symbols with different encoding" do
57+
source = "fée"
58+
59+
iso_symbol = source.force_encoding(Encoding::ISO_8859_1).send(@method)
60+
iso_symbol.encoding.should == Encoding::ISO_8859_1
61+
binary_symbol = source.force_encoding(Encoding::BINARY).send(@method)
62+
binary_symbol.encoding.should == Encoding::BINARY
63+
end
64+
5665
it "raises an EncodingError for UTF-8 String containing invalid bytes" do
5766
invalid_utf8 = "\xC3"
5867
invalid_utf8.should_not.valid_encoding?

spec/ruby/language/predefined_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ def obj.foo2; yield; end
13241324

13251325
it "returns what will be loaded without actual loading, .so file" do
13261326
require 'rbconfig'
1327+
skip "no dynamically loadable standard extension" if RbConfig::CONFIG["EXTSTATIC"] == "static"
13271328

13281329
extension, path = $LOAD_PATH.resolve_feature_path('etc')
13291330
extension.should == :so

spec/ruby/library/date/iso8601_spec.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,11 @@
1717
d.should == Date.civil(-4712, 1, 1)
1818
end
1919

20-
it "parses a Symbol into a Date object" do
21-
d = Date.iso8601(:'2015-10-15')
22-
d.should == Date.civil(2015, 10, 15)
23-
end
24-
2520
it "parses a StringSubclass into a Date object" do
2621
d = Date.iso8601(Class.new(String).new("-4712-01-01"))
2722
d.should == Date.civil(-4712, 1, 1)
2823
end
2924

30-
it "raises an ArgumentError when passed a Symbol without a valid Date" do
31-
-> { Date.iso8601(:test) }.should raise_error(ArgumentError)
32-
end
33-
3425
it "raises a TypeError when passed an Object" do
3526
-> { Date.iso8601(Object.new) }.should raise_error(TypeError)
3627
end

spec/ruby/library/date/parse_spec.rb

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

6868
it "raises a TypeError trying to parse non-String-like object" do
6969
-> { Date.parse(1) }.should raise_error(TypeError)
70-
-> { Date.parse(:invalid) }.should raise_error(TypeError)
70+
-> { Date.parse([]) }.should raise_error(TypeError)
7171
end
7272

7373
it "coerces using to_str" do

spec/ruby/optional/capi/string_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,9 @@ def inspect
611611
filename = fixture(__FILE__, "read.txt")
612612
str = ""
613613
capacities = @s.RSTRING_PTR_read(str, filename)
614-
capacities.should == [30, 53]
614+
capacities[0].should >= 30
615+
capacities[1].should >= 53
616+
capacities[0].should < capacities[1]
615617
str.should == "fixture file contents to test read() with RSTRING_PTR"
616618
end
617619
end

spec/ruby/shared/rational/minus.rb

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)