From 8c5b60eb22d6d661e87992a65d54e3a5bc0aeed4 Mon Sep 17 00:00:00 2001 From: eregon Date: Sat, 28 Oct 2017 15:15:48 +0000 Subject: Update to ruby/spec@a6b8805 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/library/bigdecimal/sign_spec.rb | 2 +- spec/ruby/library/cgi/cookie/parse_spec.rb | 21 +++ spec/ruby/library/cgi/shared/http_header.rb | 6 +- .../library/conditionvariable/marshal_dump_spec.rb | 9 ++ spec/ruby/library/csv/liberal_parsing_spec.rb | 21 +++ spec/ruby/library/csv/parse_spec.rb | 14 ++ spec/ruby/library/csv/readlines_spec.rb | 14 ++ spec/ruby/library/date/friday_spec.rb | 12 ++ spec/ruby/library/date/minus_month_spec.rb | 2 +- spec/ruby/library/date/minus_spec.rb | 4 +- spec/ruby/library/date/monday_spec.rb | 8 ++ spec/ruby/library/date/next_day_spec.rb | 10 +- spec/ruby/library/date/next_month_spec.rb | 15 +++ spec/ruby/library/date/prev_day_spec.rb | 6 +- spec/ruby/library/date/prev_month_spec.rb | 15 +++ spec/ruby/library/date/saturday_spec.rb | 8 ++ spec/ruby/library/date/sunday_spec.rb | 8 ++ spec/ruby/library/date/thursday_spec.rb | 8 ++ spec/ruby/library/date/today_spec.rb | 10 +- spec/ruby/library/date/tuesday_spec.rb | 8 ++ spec/ruby/library/date/wday_spec.rb | 5 +- spec/ruby/library/date/wednesday_spec.rb | 8 ++ spec/ruby/library/datetime/new_spec.rb | 2 +- spec/ruby/library/datetime/now_spec.rb | 17 +++ spec/ruby/library/datetime/to_date_spec.rb | 33 ++++- spec/ruby/library/datetime/to_datetime_spec.rb | 5 +- spec/ruby/library/datetime/to_s_spec.rb | 13 +- spec/ruby/library/datetime/to_time_spec.rb | 22 ++- spec/ruby/library/etc/getlogin_spec.rb | 12 +- spec/ruby/library/fiber/resume_spec.rb | 2 +- spec/ruby/library/fiber/transfer_spec.rb | 2 +- spec/ruby/library/getoptlong/terminate_spec.rb | 2 +- spec/ruby/library/ipaddr/operator_spec.rb | 9 +- spec/ruby/library/logger/logger/new_spec.rb | 57 ++++++++ spec/ruby/library/matrix/diagonal_spec.rb | 4 +- spec/ruby/library/matrix/hermitian_spec.rb | 6 +- spec/ruby/library/matrix/normal_spec.rb | 4 +- spec/ruby/library/matrix/orthogonal_spec.rb | 4 +- spec/ruby/library/matrix/permutation_spec.rb | 4 +- spec/ruby/library/matrix/symmetric_spec.rb | 6 +- spec/ruby/library/matrix/unitary_spec.rb | 4 +- spec/ruby/library/net/ftp/fixtures/server.rb | 10 +- spec/ruby/library/net/ftp/status_spec.rb | 6 + .../library/net/http/http/fixtures/http_server.rb | 12 ++ spec/ruby/library/net/http/http/post_spec.rb | 39 ++++++ .../library/net/http/http/request_types_spec.rb | 28 ++-- .../net/http/httpheader/content_length_spec.rb | 2 +- spec/ruby/library/optionparser/order_spec.rb | 32 +++++ spec/ruby/library/optionparser/parse_spec.rb | 32 +++++ spec/ruby/library/pathname/empty_spec.rb | 34 +++++ .../library/pathname/relative_path_from_spec.rb | 2 +- .../library/rexml/element/add_attributes_spec.rb | 2 +- spec/ruby/library/rexml/element/add_text_spec.rb | 2 +- .../rexml/element/element_reference_spec.rb | 22 +++ spec/ruby/library/securerandom/base64_spec.rb | 2 +- spec/ruby/library/securerandom/hex_spec.rb | 2 +- spec/ruby/library/set/compare_by_identity_spec.rb | 147 +++++++++++++++++++++ spec/ruby/library/set/shared/difference.rb | 2 +- .../library/set/sortedset/shared/difference.rb | 2 +- spec/ruby/library/shellwords/shellwords_spec.rb | 7 + spec/ruby/library/socket/tcpserver/accept_spec.rb | 13 +- spec/ruby/library/socket/tcpserver/new_spec.rb | 2 +- spec/ruby/library/socket/unixserver/accept_spec.rb | 12 +- spec/ruby/library/stringio/each_line_spec.rb | 6 + spec/ruby/library/stringio/each_spec.rb | 6 + spec/ruby/library/stringio/getc_spec.rb | 2 +- spec/ruby/library/stringio/getch_spec.rb | 2 +- spec/ruby/library/stringio/gets_spec.rb | 13 +- spec/ruby/library/stringio/lines_spec.rb | 6 + spec/ruby/library/stringio/readline_spec.rb | 13 +- spec/ruby/library/stringio/readlines_spec.rb | 9 ++ spec/ruby/library/stringio/shared/each.rb | 9 ++ spec/ruby/library/time/to_time_spec.rb | 17 +++ .../library/win32ole/win32ole_method/new_spec.rb | 2 +- spec/ruby/library/yaml/shared/each_document.rb | 2 +- spec/ruby/library/yaml/to_yaml_spec.rb | 2 +- 76 files changed, 833 insertions(+), 90 deletions(-) create mode 100644 spec/ruby/library/conditionvariable/marshal_dump_spec.rb create mode 100644 spec/ruby/library/csv/liberal_parsing_spec.rb create mode 100644 spec/ruby/library/date/friday_spec.rb create mode 100644 spec/ruby/library/date/monday_spec.rb create mode 100644 spec/ruby/library/date/saturday_spec.rb create mode 100644 spec/ruby/library/date/sunday_spec.rb create mode 100644 spec/ruby/library/date/thursday_spec.rb create mode 100644 spec/ruby/library/date/tuesday_spec.rb create mode 100644 spec/ruby/library/date/wednesday_spec.rb create mode 100644 spec/ruby/library/optionparser/order_spec.rb create mode 100644 spec/ruby/library/optionparser/parse_spec.rb create mode 100644 spec/ruby/library/pathname/empty_spec.rb create mode 100644 spec/ruby/library/rexml/element/element_reference_spec.rb create mode 100644 spec/ruby/library/set/compare_by_identity_spec.rb create mode 100644 spec/ruby/library/time/to_time_spec.rb (limited to 'spec/ruby/library') diff --git a/spec/ruby/library/bigdecimal/sign_spec.rb b/spec/ruby/library/bigdecimal/sign_spec.rb index 0d722987b5..85aa74741c 100644 --- a/spec/ruby/library/bigdecimal/sign_spec.rb +++ b/spec/ruby/library/bigdecimal/sign_spec.rb @@ -27,7 +27,7 @@ describe "BigDecimal#sign" do BigDecimal("-Infinity").sign.should == BigDecimal::SIGN_NEGATIVE_INFINITE end - it "returns positive zero if BigDecimal equals positve zero" do + it "returns positive zero if BigDecimal equals positive zero" do BigDecimal("0").sign.should == BigDecimal::SIGN_POSITIVE_ZERO BigDecimal("0E-200000000").sign.should == BigDecimal::SIGN_POSITIVE_ZERO BigDecimal("0E200000000").sign.should == BigDecimal::SIGN_POSITIVE_ZERO diff --git a/spec/ruby/library/cgi/cookie/parse_spec.rb b/spec/ruby/library/cgi/cookie/parse_spec.rb index dc8498dcb4..6f615c0d23 100644 --- a/spec/ruby/library/cgi/cookie/parse_spec.rb +++ b/spec/ruby/library/cgi/cookie/parse_spec.rb @@ -10,6 +10,27 @@ describe "CGI::Cookie.parse" do CGI::Cookie.parse("first cookie=one&two;second cookie=three&four").should == expected end + ruby_version_is ""..."2.4" do + it "uses , for cookie separators" do + expected = { + "first cookie" => ["one", "two"], + "second cookie" => ["three", "four"], + "third_cookie" => ["five", "six"] + } + CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected + end + end + + ruby_version_is "2.4" do + it "does not use , for cookie separators" do + expected = { + "first cookie" => ["one", "two"], + "second cookie" => ["three", "four,third_cookie=five", "six"] + } + CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected + end + end + it "unescapes the Cookie values" do cookie = "test-cookie=+%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7E" expected = { "test-cookie" => [ " !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ] } diff --git a/spec/ruby/library/cgi/shared/http_header.rb b/spec/ruby/library/cgi/shared/http_header.rb index ed65b20abd..b6d81d2e0e 100644 --- a/spec/ruby/library/cgi/shared/http_header.rb +++ b/spec/ruby/library/cgi/shared/http_header.rb @@ -13,7 +13,7 @@ describe :cgi_http_header, shared: true do end - it "returns a HTTP header specifiying the Content-Type as text/html" do + it "returns a HTTP header specifying the Content-Type as text/html" do @cgi.send(@method).should == "Content-Type: text/html\r\n\r\n" end @@ -34,7 +34,7 @@ describe :cgi_http_header, shared: true do end - it "returns a HTTP header specifiying the Content-Type as the passed String's content" do + it "returns a HTTP header specifying the Content-Type as the passed String's content" do @cgi.send(@method, "text/plain").should == "Content-Type: text/plain\r\n\r\n" end @@ -105,7 +105,7 @@ describe :cgi_http_header, shared: true do @cgi.send(@method, {}).should == "Content-Type: text/html\r\nSet-Cookie: multiple\r\nSet-Cookie: cookies\r\n\r\n" end - it "returns a HTTP header specifiying the Content-Type as text/html when passed an empty Hash" do + it "returns a HTTP header specifying the Content-Type as text/html when passed an empty Hash" do @cgi.send(@method, {}).should == "Content-Type: text/html\r\n\r\n" end end diff --git a/spec/ruby/library/conditionvariable/marshal_dump_spec.rb b/spec/ruby/library/conditionvariable/marshal_dump_spec.rb new file mode 100644 index 0000000000..f32b784eaa --- /dev/null +++ b/spec/ruby/library/conditionvariable/marshal_dump_spec.rb @@ -0,0 +1,9 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'thread' + +describe "ConditionVariable#marshal_dump" do + it "raises a TypeError" do + cv = ConditionVariable.new + -> { cv.marshal_dump }.should raise_error(TypeError, /can't dump/) + end +end diff --git a/spec/ruby/library/csv/liberal_parsing_spec.rb b/spec/ruby/library/csv/liberal_parsing_spec.rb new file mode 100644 index 0000000000..99cedbcd22 --- /dev/null +++ b/spec/ruby/library/csv/liberal_parsing_spec.rb @@ -0,0 +1,21 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'csv' + +ruby_version_is '2.4' do + describe "CSV#liberal_parsing?" do + it "returns true if illegal input is handled" do + csv = CSV.new("", liberal_parsing: true) + csv.liberal_parsing?.should == true + end + + it "returns false if illegal input is not handled" do + csv = CSV.new("", liberal_parsing: false) + csv.liberal_parsing?.should == false + end + + it "returns false by default" do + csv = CSV.new("") + csv.liberal_parsing?.should == false + end + end +end diff --git a/spec/ruby/library/csv/parse_spec.rb b/spec/ruby/library/csv/parse_spec.rb index 41d37ca9a4..47d7ebbde1 100644 --- a/spec/ruby/library/csv/parse_spec.rb +++ b/spec/ruby/library/csv/parse_spec.rb @@ -78,4 +78,18 @@ describe "CSV.parse" do result = CSV.parse "foo;bar\nbaz;quz", col_sep: ?; result.should == [['foo','bar'],['baz','quz']] end + + it "raises CSV::MalformedCSVError exception if input is illegal" do + -> { + CSV.parse('"quoted" field') + }.should raise_error(CSV::MalformedCSVError) + end + + ruby_version_is '2.4' do + it "handles illegal input with the liberal_parsing option" do + illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson' + result = CSV.parse(illegal_input, liberal_parsing: true) + result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']] + end + end end diff --git a/spec/ruby/library/csv/readlines_spec.rb b/spec/ruby/library/csv/readlines_spec.rb index 387730db16..452effd343 100644 --- a/spec/ruby/library/csv/readlines_spec.rb +++ b/spec/ruby/library/csv/readlines_spec.rb @@ -20,4 +20,18 @@ describe "CSV#readlines" do file = CSV.new "a,, b, c" file.readlines.should == [["a", nil, " b", " c"]] end + + it "raises CSV::MalformedCSVError exception if input is illegal" do + csv = CSV.new('"quoted" field') + -> { csv.readlines }.should raise_error(CSV::MalformedCSVError) + end + + ruby_version_is '2.4' do + it "handles illegal input with the liberal_parsing option" do + illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson' + csv = CSV.new(illegal_input, liberal_parsing: true) + result = csv.readlines + result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']] + end + end end diff --git a/spec/ruby/library/date/friday_spec.rb b/spec/ruby/library/date/friday_spec.rb new file mode 100644 index 0000000000..369b943419 --- /dev/null +++ b/spec/ruby/library/date/friday_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#friday?" do + it "should be friday" do + Date.new(2000, 1, 7).friday?.should be_true + end + + it "should not be friday" do + Date.new(2000, 1, 8).friday?.should be_false + end +end diff --git a/spec/ruby/library/date/minus_month_spec.rb b/spec/ruby/library/date/minus_month_spec.rb index b6b20c5578..fbe5cb8593 100644 --- a/spec/ruby/library/date/minus_month_spec.rb +++ b/spec/ruby/library/date/minus_month_spec.rb @@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__) describe "Date#<<" do - it "substracts a number of months from a date" do + it "subtracts a number of months from a date" do d = Date.civil(2007,2,27) << 10 d.should == Date.civil(2006, 4, 27) end diff --git a/spec/ruby/library/date/minus_spec.rb b/spec/ruby/library/date/minus_spec.rb index 09da595872..fd7f3fd14c 100644 --- a/spec/ruby/library/date/minus_spec.rb +++ b/spec/ruby/library/date/minus_spec.rb @@ -3,12 +3,12 @@ require File.expand_path('../../../spec_helper', __FILE__) describe "Date#-" do - it "substracts a number of days from a Date" do + it "subtracts a number of days from a Date" do d = Date.civil(2007, 5 ,2) - 13 d.should == Date.civil(2007, 4, 19) end - it "substracts a negative number of days from a Date" do + it "subtracts a negative number of days from a Date" do d = Date.civil(2007, 4, 19).-(-13) d.should == Date.civil(2007, 5 ,2) end diff --git a/spec/ruby/library/date/monday_spec.rb b/spec/ruby/library/date/monday_spec.rb new file mode 100644 index 0000000000..f7d968b6d6 --- /dev/null +++ b/spec/ruby/library/date/monday_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#monday?" do + it "should be monday" do + Date.new(2000, 1, 3).monday?.should be_true + end +end diff --git a/spec/ruby/library/date/next_day_spec.rb b/spec/ruby/library/date/next_day_spec.rb index 1ccb4df257..795bfecf0a 100644 --- a/spec/ruby/library/date/next_day_spec.rb +++ b/spec/ruby/library/date/next_day_spec.rb @@ -3,8 +3,12 @@ require 'date' describe "Date#next_day" do it "returns the next day" do - d = Date.new(2000, 1, 5) - d1 = Date.new(2000, 1, 4).next_day - d1.should == d + d = Date.new(2000, 1, 4).next_day + d.should == Date.new(2000, 1, 5) + end + + it "returns three days later across months" do + d = Date.new(2000, 1, 30).next_day(3) + d.should == Date.new(2000, 2, 2) end end diff --git a/spec/ruby/library/date/next_month_spec.rb b/spec/ruby/library/date/next_month_spec.rb index 22699a39a5..9becd7e37f 100644 --- a/spec/ruby/library/date/next_month_spec.rb +++ b/spec/ruby/library/date/next_month_spec.rb @@ -11,4 +11,19 @@ describe "Date#next_month" do d = Date.new(2000, 7, 1).next_month(3) d.should == Date.new(2000, 10, 1) end + + it "returns three months later across years" do + d = Date.new(2000, 12, 1).next_month(3) + d.should == Date.new(2001, 3, 1) + end + + it "returns last day of month two months later" do + d = Date.new(2000, 1, 31).next_month(2) + d.should == Date.new(2000, 3, 31) + end + + it "returns last day of next month when same day does not exist" do + d = Date.new(2001, 1, 30).next_month + d.should == Date.new(2001, 2, 28) + end end diff --git a/spec/ruby/library/date/prev_day_spec.rb b/spec/ruby/library/date/prev_day_spec.rb index 8a42824154..149bfe9fa9 100644 --- a/spec/ruby/library/date/prev_day_spec.rb +++ b/spec/ruby/library/date/prev_day_spec.rb @@ -7,8 +7,8 @@ describe "Date#prev_day" do d.should == Date.new(2000, 7, 1) end - it "returns three days ago" do - d = Date.new(2000, 7, 4).prev_day(3) - d.should == Date.new(2000, 7, 1) + it "returns three days ago across months" do + d = Date.new(2000, 7, 2).prev_day(3) + d.should == Date.new(2000, 6, 29) end end diff --git a/spec/ruby/library/date/prev_month_spec.rb b/spec/ruby/library/date/prev_month_spec.rb index eaf7f67ee0..440c17ffc9 100644 --- a/spec/ruby/library/date/prev_month_spec.rb +++ b/spec/ruby/library/date/prev_month_spec.rb @@ -11,4 +11,19 @@ describe "Date#prev_month" do d = Date.new(2000, 10, 1).prev_month(3) d.should == Date.new(2000, 7, 1) end + + it "returns three months ago across years" do + d = Date.new(2000, 1, 1).prev_month(3) + d.should == Date.new(1999, 10, 1) + end + + it "returns last day of month two months ago" do + d = Date.new(2000, 3, 31).prev_month(2) + d.should == Date.new(2000, 1, 31) + end + + it "returns last day of previous month when same day does not exist" do + d = Date.new(2001, 3, 30).prev_month + d.should == Date.new(2001, 2, 28) + end end diff --git a/spec/ruby/library/date/saturday_spec.rb b/spec/ruby/library/date/saturday_spec.rb new file mode 100644 index 0000000000..1360050a69 --- /dev/null +++ b/spec/ruby/library/date/saturday_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#saturday?" do + it "should be saturday" do + Date.new(2000, 1, 1).saturday?.should be_true + end +end diff --git a/spec/ruby/library/date/sunday_spec.rb b/spec/ruby/library/date/sunday_spec.rb new file mode 100644 index 0000000000..d805006264 --- /dev/null +++ b/spec/ruby/library/date/sunday_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#sunday?" do + it "should be sunday" do + Date.new(2000, 1, 2).sunday?.should be_true + end +end diff --git a/spec/ruby/library/date/thursday_spec.rb b/spec/ruby/library/date/thursday_spec.rb new file mode 100644 index 0000000000..a59ca3f6cf --- /dev/null +++ b/spec/ruby/library/date/thursday_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#thursday?" do + it "should be thursday" do + Date.new(2000, 1, 6).thursday?.should be_true + end +end diff --git a/spec/ruby/library/date/today_spec.rb b/spec/ruby/library/date/today_spec.rb index 09e8ed6006..d487be089f 100644 --- a/spec/ruby/library/date/today_spec.rb +++ b/spec/ruby/library/date/today_spec.rb @@ -2,5 +2,13 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' describe "Date.today" do - it "needs to be reviewed for spec completeness" + it "returns a Date object" do + Date.today.should be_kind_of Date + end + + it "sets Date object to the current date" do + today = Date.today + now = Time.now + (now - today.to_time).should be_close(0.0, 24 * 60 * 60) + end end diff --git a/spec/ruby/library/date/tuesday_spec.rb b/spec/ruby/library/date/tuesday_spec.rb new file mode 100644 index 0000000000..10ed6755d1 --- /dev/null +++ b/spec/ruby/library/date/tuesday_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#tuesday?" do + it "should be tuesday" do + Date.new(2000, 1, 4).tuesday?.should be_true + end +end diff --git a/spec/ruby/library/date/wday_spec.rb b/spec/ruby/library/date/wday_spec.rb index 1d40b0c96c..7303423123 100644 --- a/spec/ruby/library/date/wday_spec.rb +++ b/spec/ruby/library/date/wday_spec.rb @@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' describe "Date#wday" do - it "needs to be reviewed for spec completeness" + it "returns the week day as a number starting with Sunday as 0" do + w = Date.new(2000, 1, 1).wday + w.should == 6 + end end diff --git a/spec/ruby/library/date/wednesday_spec.rb b/spec/ruby/library/date/wednesday_spec.rb new file mode 100644 index 0000000000..99478f21c2 --- /dev/null +++ b/spec/ruby/library/date/wednesday_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#wednesday?" do + it "should be wednesday" do + Date.new(2000, 1, 5).wednesday?.should be_true + end +end diff --git a/spec/ruby/library/datetime/new_spec.rb b/spec/ruby/library/datetime/new_spec.rb index a8275a1951..14ef329d56 100644 --- a/spec/ruby/library/datetime/new_spec.rb +++ b/spec/ruby/library/datetime/new_spec.rb @@ -42,7 +42,7 @@ describe "DateTime.new" do DateTime.new(1, 2, 3, 4, 5, 6, 0.7).offset.should == 0.7 end - it "takes the eigth argument as the date of calendar reform" do + it "takes the eighth argument as the date of calendar reform" do DateTime.new(1, 2, 3, 4, 5, 6, 0.7, Date::ITALY).start().should == Date::ITALY end diff --git a/spec/ruby/library/datetime/now_spec.rb b/spec/ruby/library/datetime/now_spec.rb index e8c93aa604..a5bf590aff 100644 --- a/spec/ruby/library/datetime/now_spec.rb +++ b/spec/ruby/library/datetime/now_spec.rb @@ -5,4 +5,21 @@ describe "DateTime.now" do it "creates an instance of DateTime" do DateTime.now.should be_an_instance_of(DateTime) end + + it "sets the current date" do + (DateTime.now - Date.today).to_f.should be_close(0.0, 1.0) + end + + it "sets the current time" do + dt = DateTime.now + now = Time.now + (dt.to_time - now).should be_close(0.0, 10.0) + end + + it "grabs the local timezone" do + with_timezone("PDT", -8) do + dt = DateTime.now + dt.zone.should == "-08:00" + end + end end diff --git a/spec/ruby/library/datetime/to_date_spec.rb b/spec/ruby/library/datetime/to_date_spec.rb index 915e1ac87a..387eda9229 100644 --- a/spec/ruby/library/datetime/to_date_spec.rb +++ b/spec/ruby/library/datetime/to_date_spec.rb @@ -2,5 +2,36 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' describe "DateTime#to_date" do - it "needs to be reviewed for spec completeness" + it "returns an instance of Date" do + dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00') + dt.to_date.should be_kind_of(Date) + end + + it "maintains the same year" do + dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00') + dt.to_date.year.should == dt.year + end + + it "maintains the same month" do + dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00') + dt.to_date.mon.should == dt.mon + end + + it "maintains the same day" do + dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00') + dt.to_date.day.should == dt.day + end + + it "maintains the same mday" do + dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00') + dt.to_date.mday.should == dt.mday + end + + it "maintains the same julian day regardless of local time or zone" do + dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00') + + with_timezone("Pactific/Pago_Pago", -11) do + dt.to_date.jd.should == dt.jd + end + end end diff --git a/spec/ruby/library/datetime/to_datetime_spec.rb b/spec/ruby/library/datetime/to_datetime_spec.rb index e289f8ce36..e4db9558f1 100644 --- a/spec/ruby/library/datetime/to_datetime_spec.rb +++ b/spec/ruby/library/datetime/to_datetime_spec.rb @@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' describe "DateTime#to_datetime" do - it "needs to be reviewed for spec completeness" + it "returns itself" do + dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00') + dt.to_datetime.should == dt + end end diff --git a/spec/ruby/library/datetime/to_s_spec.rb b/spec/ruby/library/datetime/to_s_spec.rb index 893cc93283..9d9dfc629f 100644 --- a/spec/ruby/library/datetime/to_s_spec.rb +++ b/spec/ruby/library/datetime/to_s_spec.rb @@ -2,5 +2,16 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' describe "DateTime#to_s" do - it "needs to be reviewed for spec completeness" + it "returns a new String object" do + dt = DateTime.new(2012, 12, 24, 1, 2, 3, "+03:00") + dt.to_s.should be_kind_of(String) + end + + it "maintains timezone regardless of local time" do + dt = DateTime.new(2012, 12, 24, 1, 2, 3, "+03:00") + + with_timezone("Pactific/Pago_Pago", -11) do + dt.to_s.should == "2012-12-24T01:02:03+03:00" + end + end end diff --git a/spec/ruby/library/datetime/to_time_spec.rb b/spec/ruby/library/datetime/to_time_spec.rb index aa2902930c..f5b7cb8a23 100644 --- a/spec/ruby/library/datetime/to_time_spec.rb +++ b/spec/ruby/library/datetime/to_time_spec.rb @@ -2,5 +2,25 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' describe "DateTime#to_time" do - it "needs to be reviewed for spec completeness" + it "yields a new Time object" do + DateTime.now.to_time.should be_kind_of(Time) + end + + ruby_version_is "2.4" do + it "preserves the same time regardless of local time or zone" do + date = DateTime.new(2012, 12, 24, 12, 23, 00, '+03:00') + + with_timezone("Pactific/Pago_Pago", -11) do + time = date.to_time + + time.utc_offset.should == 3 * 3600 + time.year.should == date.year + time.mon.should == date.mon + time.day.should == date.day + time.hour.should == date.hour + time.min.should == date.min + time.sec.should == date.sec + end + end + end end diff --git a/spec/ruby/library/etc/getlogin_spec.rb b/spec/ruby/library/etc/getlogin_spec.rb index ae52942a92..43e654bda6 100644 --- a/spec/ruby/library/etc/getlogin_spec.rb +++ b/spec/ruby/library/etc/getlogin_spec.rb @@ -11,9 +11,15 @@ describe "Etc.getlogin" do # make Etc.getlogin to return nil if getlogin(3) returns NULL envuser, ENV['USER'] = ENV['USER'], nil if Etc.getlogin - # Etc.getlogin returns the same result of logname(2) - # if it returns non NULL - Etc.getlogin.should == `id -un`.chomp + if ENV['TRAVIS'] and platform_is(:darwin) + # See https://travis-ci.org/ruby/spec/jobs/285967744 + # and https://travis-ci.org/ruby/spec/jobs/285999602 + Etc.getlogin.should be_an_instance_of(String) + else + # Etc.getlogin returns the same result of logname(2) + # if it returns non NULL + Etc.getlogin.should == `id -un`.chomp + end else # Etc.getlogin may return nil if the login name is not set # because of chroot or sudo or something. diff --git a/spec/ruby/library/fiber/resume_spec.rb b/spec/ruby/library/fiber/resume_spec.rb index 8709d01142..389757b7bd 100644 --- a/spec/ruby/library/fiber/resume_spec.rb +++ b/spec/ruby/library/fiber/resume_spec.rb @@ -4,7 +4,7 @@ with_feature :fiber_library do require 'fiber' describe "Fiber#resume" do - it "raises a FiberError if the Fiber has transfered control to another Fiber" do + it "raises a FiberError if the Fiber has transferred control to another Fiber" do fiber1 = Fiber.new { true } fiber2 = Fiber.new { fiber1.transfer; Fiber.yield } fiber2.resume diff --git a/spec/ruby/library/fiber/transfer_spec.rb b/spec/ruby/library/fiber/transfer_spec.rb index 79319a7d39..ad501c1d74 100644 --- a/spec/ruby/library/fiber/transfer_spec.rb +++ b/spec/ruby/library/fiber/transfer_spec.rb @@ -35,7 +35,7 @@ with_feature :fiber_library do states.should == [:start, :end] end - it "can transfer control to a Fiber that has transfered to another Fiber" do + it "can transfer control to a Fiber that has transferred to another Fiber" do states = [] fiber1 = Fiber.new { states << :fiber1 } fiber2 = Fiber.new { states << :fiber2_start; fiber1.transfer; states << :fiber2_end} diff --git a/spec/ruby/library/getoptlong/terminate_spec.rb b/spec/ruby/library/getoptlong/terminate_spec.rb index ad9f9a1623..66d318527b 100644 --- a/spec/ruby/library/getoptlong/terminate_spec.rb +++ b/spec/ruby/library/getoptlong/terminate_spec.rb @@ -11,7 +11,7 @@ describe "GetoptLong#terminate" do ) end - it "terminates option proccessing" do + it "terminates option processing" do argv [ "--size", "10k", "-v", "-q", "a.txt", "b.txt" ] do @opts.get.should == [ "--size", "10k" ] @opts.terminate diff --git a/spec/ruby/library/ipaddr/operator_spec.rb b/spec/ruby/library/ipaddr/operator_spec.rb index 3f54efd486..6d884780e3 100644 --- a/spec/ruby/library/ipaddr/operator_spec.rb +++ b/spec/ruby/library/ipaddr/operator_spec.rb @@ -57,13 +57,20 @@ describe "IPAddr Operator" do @a.should_not == IPAddr.new("3ffe:505:3::") end + ruby_version_is '2.4' do + # https://bugs.ruby-lang.org/issues/12799 + it "tests for equality correctly if object cannot be converted to IPAddr" do + IPAddr.new("1.1.1.1").should_not == "sometext" + end + end + it "sets a mask" do a = @a.mask(32) a.to_s.should == "3ffe:505::" @a.to_s.should == "3ffe:505:2::" end - it "checks whether an addres is included in a range" do + it "checks whether an address is included in a range" do @a.should include(IPAddr.new("3ffe:505:2::")) @a.should include(IPAddr.new("3ffe:505:2::1")) @a.should_not include(IPAddr.new("3ffe:505:3::")) diff --git a/spec/ruby/library/logger/logger/new_spec.rb b/spec/ruby/library/logger/logger/new_spec.rb index 255f686d25..b3eed42f00 100644 --- a/spec/ruby/library/logger/logger/new_spec.rb +++ b/spec/ruby/library/logger/logger/new_spec.rb @@ -60,4 +60,61 @@ describe "Logger#new" do f1.close rm_r path, "#{path}.0" end + + ruby_version_is "2.4" do + it "receives level symbol as keyword argument" do + logger = Logger.new(STDERR, level: :info) + logger.level.should == Logger::INFO + end + + it "receives level as keyword argument" do + logger = Logger.new(STDERR, level: Logger::INFO) + logger.level.should == Logger::INFO + end + + it "receives progname as keyword argument" do + progname = "progname" + + logger = Logger.new(STDERR, progname: progname) + logger.progname.should == progname + end + + it "receives datetime_format as keyword argument" do + datetime_format = "%H:%M:%S" + + logger = Logger.new(STDERR, datetime_format: datetime_format) + logger.datetime_format.should == datetime_format + end + + it "receives formatter as keyword argument" do + formatter = Class.new do + def call(_severity, _time, _progname, _msg); end + end.new + + logger = Logger.new(STDERR, formatter: formatter) + logger.formatter.should == formatter + end + + it "receives shift_period_suffix " do + shift_period_suffix = "%Y-%m-%d" + path = tmp("shift_period_suffix_test.log") + now = Time.now + tomorrow = Time.at(now.to_i + 60 * 60 * 24) + logger = Logger.new(path, 'daily', shift_period_suffix: shift_period_suffix) + + logger.add Logger::INFO, 'message' + + Time.stub!(:now).and_return(tomorrow) + logger.add Logger::INFO, 'second message' + + shifted_path = "#{path}.#{now.strftime(shift_period_suffix)}" + + File.exist?(shifted_path).should == true + + logger.close + + rm_r path, shifted_path + end + end + end diff --git a/spec/ruby/library/matrix/diagonal_spec.rb b/spec/ruby/library/matrix/diagonal_spec.rb index c88a92b5cd..ddf5a8d292 100644 --- a/spec/ruby/library/matrix/diagonal_spec.rb +++ b/spec/ruby/library/matrix/diagonal_spec.rb @@ -63,9 +63,9 @@ describe "Matrix.diagonal?" do Matrix[[0, 0]], Matrix.empty(0, 2), Matrix.empty(2, 0), - ].each do |rectangual_matrix| + ].each do |rectangular_matrix| lambda { - rectangual_matrix.diagonal? + rectangular_matrix.diagonal? }.should raise_error(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/hermitian_spec.rb b/spec/ruby/library/matrix/hermitian_spec.rb index cbfea433c2..e108ba1e34 100644 --- a/spec/ruby/library/matrix/hermitian_spec.rb +++ b/spec/ruby/library/matrix/hermitian_spec.rb @@ -10,7 +10,7 @@ describe "Matrix.hermitian?" do Matrix.empty.hermitian?.should be_true end - it "returns false for an assymetric Matrix" do + it "returns false for an asymmetric Matrix" do Matrix[[1, 2],[-2, 1]].hermitian?.should be_false end @@ -20,9 +20,9 @@ describe "Matrix.hermitian?" do Matrix[[0, 0]], Matrix.empty(0, 2), Matrix.empty(2, 0), - ].each do |rectangual_matrix| + ].each do |rectangular_matrix| lambda { - rectangual_matrix.hermitian? + rectangular_matrix.hermitian? }.should raise_error(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/normal_spec.rb b/spec/ruby/library/matrix/normal_spec.rb index 140909dcc2..5f0b8e6362 100644 --- a/spec/ruby/library/matrix/normal_spec.rb +++ b/spec/ruby/library/matrix/normal_spec.rb @@ -17,9 +17,9 @@ describe "Matrix.normal?" do Matrix[[0, 0]], Matrix.empty(0, 2), Matrix.empty(2, 0), - ].each do |rectangual_matrix| + ].each do |rectangular_matrix| lambda { - rectangual_matrix.normal? + rectangular_matrix.normal? }.should raise_error(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/orthogonal_spec.rb b/spec/ruby/library/matrix/orthogonal_spec.rb index 2e76b5924c..78f5c1be5d 100644 --- a/spec/ruby/library/matrix/orthogonal_spec.rb +++ b/spec/ruby/library/matrix/orthogonal_spec.rb @@ -17,9 +17,9 @@ describe "Matrix.orthogonal?" do Matrix[[0, 0]], Matrix.empty(0, 2), Matrix.empty(2, 0), - ].each do |rectangual_matrix| + ].each do |rectangular_matrix| lambda { - rectangual_matrix.orthogonal? + rectangular_matrix.orthogonal? }.should raise_error(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/permutation_spec.rb b/spec/ruby/library/matrix/permutation_spec.rb index 7098c46015..f40de4f58f 100644 --- a/spec/ruby/library/matrix/permutation_spec.rb +++ b/spec/ruby/library/matrix/permutation_spec.rb @@ -23,9 +23,9 @@ describe "Matrix#permutation?" do Matrix[[0, 0]], Matrix.empty(0, 2), Matrix.empty(2, 0), - ].each do |rectangual_matrix| + ].each do |rectangular_matrix| lambda { - rectangual_matrix.permutation? + rectangular_matrix.permutation? }.should raise_error(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/symmetric_spec.rb b/spec/ruby/library/matrix/symmetric_spec.rb index 53f962c0e2..c34a323510 100644 --- a/spec/ruby/library/matrix/symmetric_spec.rb +++ b/spec/ruby/library/matrix/symmetric_spec.rb @@ -10,7 +10,7 @@ describe "Matrix.symmetric?" do Matrix.empty.symmetric?.should be_true end - it "returns false for an assymetric Matrix" do + it "returns false for an asymmetric Matrix" do Matrix[[1, 2],[-2, 1]].symmetric?.should be_false end @@ -20,9 +20,9 @@ describe "Matrix.symmetric?" do Matrix[[0, 0]], Matrix.empty(0, 2), Matrix.empty(2, 0), - ].each do |rectangual_matrix| + ].each do |rectangular_matrix| lambda { - rectangual_matrix.symmetric? + rectangular_matrix.symmetric? }.should raise_error(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb index e322a5a3ce..0ea5586a6d 100644 --- a/spec/ruby/library/matrix/unitary_spec.rb +++ b/spec/ruby/library/matrix/unitary_spec.rb @@ -19,9 +19,9 @@ describe "Matrix.unitary?" do Matrix[[0, 0]], Matrix.empty(0, 2), Matrix.empty(2, 0), - ].each do |rectangual_matrix| + ].each do |rectangular_matrix| lambda { - rectangual_matrix.unitary? + rectangular_matrix.unitary? }.should raise_error(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/net/ftp/fixtures/server.rb b/spec/ruby/library/net/ftp/fixtures/server.rb index a6741820ff..65339cfaf9 100644 --- a/spec/ruby/library/net/ftp/fixtures/server.rb +++ b/spec/ruby/library/net/ftp/fixtures/server.rb @@ -35,7 +35,7 @@ module NetFTPSpecs response @connect_message || "220 Dummy FTP Server ready!" begin - while command = @socket.recv(1024) + while command = @socket.gets command, argument = command.chomp.split(" ", 2) if command == "QUIT" @@ -229,8 +229,12 @@ module NetFTPSpecs end end - def stat - self.response("211 System status, or system help reply. (STAT)") + def stat(param = :default) + if param == :default + self.response("211 System status, or system help reply. (STAT)") + else + self.response("211 System status, or system help reply. (STAT #{param})") + end end def stor(file) diff --git a/spec/ruby/library/net/ftp/status_spec.rb b/spec/ruby/library/net/ftp/status_spec.rb index 7e9927c3c8..243d3fc175 100644 --- a/spec/ruby/library/net/ftp/status_spec.rb +++ b/spec/ruby/library/net/ftp/status_spec.rb @@ -22,6 +22,12 @@ describe "Net::FTP#status" do @ftp.last_response.should == "211 System status, or system help reply. (STAT)\n" end + ruby_version_is "2.4" do + it "sends the STAT command with an optional parameter to the server" do + @ftp.status("/pub").should == "211 System status, or system help reply. (STAT /pub)\n" + end + end + it "returns the received information" do @ftp.status.should == "211 System status, or system help reply. (STAT)\n" end diff --git a/spec/ruby/library/net/http/http/fixtures/http_server.rb b/spec/ruby/library/net/http/http/fixtures/http_server.rb index c2ae2360d3..198fef36fb 100644 --- a/spec/ruby/library/net/http/http/fixtures/http_server.rb +++ b/spec/ruby/library/net/http/http/fixtures/http_server.rb @@ -42,6 +42,17 @@ module NetHTTPSpecs end end + class RequestBasicAuthServlet < SpecServlet + def reply(req, res) + res.content_type = "text/plain" + + WEBrick::HTTPAuth.basic_auth(req, res, "realm") do |user, pass| + res.body = "username: #{user}\npassword: #{pass}" + true + end + end + end + class << self @server = nil @server_thread = nil @@ -69,6 +80,7 @@ module NetHTTPSpecs @server.mount('/request', RequestServlet) @server.mount("/request/body", RequestBodyServlet) @server.mount("/request/header", RequestHeaderServlet) + @server.mount("/request/basic_auth", RequestBasicAuthServlet) @server_thread = @server.start end diff --git a/spec/ruby/library/net/http/http/post_spec.rb b/spec/ruby/library/net/http/http/post_spec.rb index a50663a01d..66a00f0670 100644 --- a/spec/ruby/library/net/http/http/post_spec.rb +++ b/spec/ruby/library/net/http/http/post_spec.rb @@ -1,7 +1,45 @@ require File.expand_path('../../../../../spec_helper', __FILE__) require 'net/http' +require 'uri' require File.expand_path('../fixtures/http_server', __FILE__) +ruby_version_is '2.4' do + describe "Net::HTTP.post" do + before :each do + NetHTTPSpecs.start_server + end + + after :each do + NetHTTPSpecs.stop_server + end + + it "sends post request to the specified URI and returns response" do + response = Net::HTTP.post( + URI("http://localhost:#{NetHTTPSpecs.port}/request"), + '{ "q": "ruby", "max": "50" }', + "Content-Type" => "application/json") + response.body.should == "Request type: POST" + end + + it "returns a Net::HTTPResponse" do + response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request"), "test=test") + response.should be_kind_of(Net::HTTPResponse) + end + + it "sends Content-Type: application/x-www-form-urlencoded by default" do + response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test") + response.body.should include('"content-type"=>["application/x-www-form-urlencoded"]') + end + + it "does not support HTTP Basic Auth" do + response = Net::HTTP.post( + URI("http://john:qwerty@localhost:#{NetHTTPSpecs.port}/request/basic_auth"), + "test=test") + response.body.should == "username: \npassword: " + end + end +end + describe "Net::HTTP#post" do before :each do NetHTTPSpecs.start_server @@ -36,3 +74,4 @@ describe "Net::HTTP#post" do end end end + diff --git a/spec/ruby/library/net/http/http/request_types_spec.rb b/spec/ruby/library/net/http/http/request_types_spec.rb index 8855a7db66..71fe863bb2 100644 --- a/spec/ruby/library/net/http/http/request_types_spec.rb +++ b/spec/ruby/library/net/http/http/request_types_spec.rb @@ -14,7 +14,7 @@ describe "Net::HTTP::Get" do Net::HTTP::Get::REQUEST_HAS_BODY.should be_false end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Get::RESPONSE_HAS_BODY.should be_true end end @@ -32,7 +32,7 @@ describe "Net::HTTP::Head" do Net::HTTP::Head::REQUEST_HAS_BODY.should be_false end - it "has no Respone Body" do + it "has no Response Body" do Net::HTTP::Head::RESPONSE_HAS_BODY.should be_false end end @@ -50,7 +50,7 @@ describe "Net::HTTP::Post" do Net::HTTP::Post::REQUEST_HAS_BODY.should be_true end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Post::RESPONSE_HAS_BODY.should be_true end end @@ -68,7 +68,7 @@ describe "Net::HTTP::Put" do Net::HTTP::Put::REQUEST_HAS_BODY.should be_true end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Put::RESPONSE_HAS_BODY.should be_true end end @@ -86,7 +86,7 @@ describe "Net::HTTP::Delete" do Net::HTTP::Delete::REQUEST_HAS_BODY.should be_false end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Delete::RESPONSE_HAS_BODY.should be_true end end @@ -104,7 +104,7 @@ describe "Net::HTTP::Options" do Net::HTTP::Options::REQUEST_HAS_BODY.should be_false end - it "has no Respone Body" do + it "has no Response Body" do Net::HTTP::Options::RESPONSE_HAS_BODY.should be_true end end @@ -122,7 +122,7 @@ describe "Net::HTTP::Trace" do Net::HTTP::Trace::REQUEST_HAS_BODY.should be_false end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Trace::RESPONSE_HAS_BODY.should be_true end end @@ -140,7 +140,7 @@ describe "Net::HTTP::Propfind" do Net::HTTP::Propfind::REQUEST_HAS_BODY.should be_true end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Propfind::RESPONSE_HAS_BODY.should be_true end end @@ -158,7 +158,7 @@ describe "Net::HTTP::Proppatch" do Net::HTTP::Proppatch::REQUEST_HAS_BODY.should be_true end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Proppatch::RESPONSE_HAS_BODY.should be_true end end @@ -176,7 +176,7 @@ describe "Net::HTTP::Mkcol" do Net::HTTP::Mkcol::REQUEST_HAS_BODY.should be_true end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Mkcol::RESPONSE_HAS_BODY.should be_true end end @@ -194,7 +194,7 @@ describe "Net::HTTP::Copy" do Net::HTTP::Copy::REQUEST_HAS_BODY.should be_false end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Copy::RESPONSE_HAS_BODY.should be_true end end @@ -212,7 +212,7 @@ describe "Net::HTTP::Move" do Net::HTTP::Move::REQUEST_HAS_BODY.should be_false end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Move::RESPONSE_HAS_BODY.should be_true end end @@ -230,7 +230,7 @@ describe "Net::HTTP::Lock" do Net::HTTP::Lock::REQUEST_HAS_BODY.should be_true end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Lock::RESPONSE_HAS_BODY.should be_true end end @@ -248,7 +248,7 @@ describe "Net::HTTP::Unlock" do Net::HTTP::Unlock::REQUEST_HAS_BODY.should be_true end - it "has a Respone Body" do + it "has a Response Body" do Net::HTTP::Unlock::RESPONSE_HAS_BODY.should be_true end end diff --git a/spec/ruby/library/net/http/httpheader/content_length_spec.rb b/spec/ruby/library/net/http/httpheader/content_length_spec.rb index 009eafde85..d93eb3a608 100644 --- a/spec/ruby/library/net/http/httpheader/content_length_spec.rb +++ b/spec/ruby/library/net/http/httpheader/content_length_spec.rb @@ -36,7 +36,7 @@ describe "Net::HTTPHeader#content_length=" do it "removes the 'Content-Length' entry if passed false or nil" do @headers["Content-Length"] = "123" @headers.content_length = nil - @headers["Content-Lenght"].should be_nil + @headers["Content-Length"].should be_nil end it "sets the 'Content-Length' entry to the passed value" do diff --git a/spec/ruby/library/optionparser/order_spec.rb b/spec/ruby/library/optionparser/order_spec.rb new file mode 100644 index 0000000000..6c6e03ecc8 --- /dev/null +++ b/spec/ruby/library/optionparser/order_spec.rb @@ -0,0 +1,32 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'optparse' + +describe "OptionParser#order" do + ruby_version_is '2.4' do + it "accepts `into` keyword argument and stores result in it" do + options = {} + parser = OptionParser.new do |opts| + opts.on("-v", "--[no-]verbose", "Run verbosely") + opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script") + end + parser.order %w[--verbose --require optparse], into: options + + options.should == { verbose: true, require: "optparse" } + end + end +end + +describe "OptionParser#order!" do + ruby_version_is '2.4' do + it "accepts `into` keyword argument and stores result in it" do + options = {} + parser = OptionParser.new do |opts| + opts.on("-v", "--[no-]verbose", "Run verbosely") + opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script") + end + parser.order! %w[--verbose --require optparse], into: options + + options.should == { verbose: true, require: "optparse" } + end + end +end diff --git a/spec/ruby/library/optionparser/parse_spec.rb b/spec/ruby/library/optionparser/parse_spec.rb new file mode 100644 index 0000000000..f13793773c --- /dev/null +++ b/spec/ruby/library/optionparser/parse_spec.rb @@ -0,0 +1,32 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'optparse' + +describe "OptionParser#parse" do + ruby_version_is '2.4' do + it "accepts `into` keyword argument and stores result in it" do + options = {} + parser = OptionParser.new do |opts| + opts.on("-v", "--[no-]verbose", "Run verbosely") + opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script") + end + parser.parse %w[--verbose --require optparse], into: options + + options.should == { verbose: true, require: "optparse" } + end + end +end + +describe "OptionParser#parse!" do + ruby_version_is '2.4' do + it "accepts `into` keyword argument and stores result in it" do + options = {} + parser = OptionParser.new do |opts| + opts.on("-v", "--[no-]verbose", "Run verbosely") + opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script") + end + parser.parse! %w[--verbose --require optparse], into: options + + options.should == { verbose: true, require: "optparse" } + end + end +end diff --git a/spec/ruby/library/pathname/empty_spec.rb b/spec/ruby/library/pathname/empty_spec.rb new file mode 100644 index 0000000000..ffe00c32e4 --- /dev/null +++ b/spec/ruby/library/pathname/empty_spec.rb @@ -0,0 +1,34 @@ +require File.expand_path('../../spec_helper', __dir__) +require 'pathname' + +ruby_version_is '2.4' do + describe 'Pathname#empty?' do + before :all do + @file = tmp 'new_file_path_name.txt' + touch @file + @dir = tmp 'new_directory_path_name' + Dir.mkdir @dir + end + + after :all do + rm_r @file + rm_r @dir + end + + it 'returns true when file is not empty' do + Pathname.new(__FILE__).empty?.should be_false + end + + it 'returns false when the directory is not empty' do + Pathname.new(__dir__).empty?.should be_false + end + + it 'return true when file is empty' do + Pathname.new(@file).empty?.should be_true + end + + it 'returns true when directory is empty' do + Pathname.new(@dir).empty?.should be_true + end + end +end diff --git a/spec/ruby/library/pathname/relative_path_from_spec.rb b/spec/ruby/library/pathname/relative_path_from_spec.rb index b3bc85e307..416eaa1a50 100644 --- a/spec/ruby/library/pathname/relative_path_from_spec.rb +++ b/spec/ruby/library/pathname/relative_path_from_spec.rb @@ -14,7 +14,7 @@ describe "Pathname#relative_path_from" do lambda { relative_path_str('a', '..') }.should raise_error(ArgumentError) end - it "retuns a path relative from root" do + it "returns a path relative from root" do relative_path_str('/usr', '/').should == 'usr' end diff --git a/spec/ruby/library/rexml/element/add_attributes_spec.rb b/spec/ruby/library/rexml/element/add_attributes_spec.rb index aa64b677ca..d4c0f0a6e2 100644 --- a/spec/ruby/library/rexml/element/add_attributes_spec.rb +++ b/spec/ruby/library/rexml/element/add_attributes_spec.rb @@ -1,7 +1,7 @@ require 'rexml/document' require File.expand_path('../../../../spec_helper', __FILE__) -describe "REXML::Element#add_attribute" do +describe "REXML::Element#add_attributes" do before :each do @person = REXML::Element.new "person" @person.attributes["name"] = "Bill" diff --git a/spec/ruby/library/rexml/element/add_text_spec.rb b/spec/ruby/library/rexml/element/add_text_spec.rb index 5d116ee6d3..2f77b5f9f7 100644 --- a/spec/ruby/library/rexml/element/add_text_spec.rb +++ b/spec/ruby/library/rexml/element/add_text_spec.rb @@ -1,7 +1,7 @@ require 'rexml/document' require File.expand_path('../../../../spec_helper', __FILE__) -describe "REXML::Element#add_namespace" do +describe "REXML::Element#add_text" do before :each do @name = REXML::Element.new "Name" end diff --git a/spec/ruby/library/rexml/element/element_reference_spec.rb b/spec/ruby/library/rexml/element/element_reference_spec.rb new file mode 100644 index 0000000000..eb01169137 --- /dev/null +++ b/spec/ruby/library/rexml/element/element_reference_spec.rb @@ -0,0 +1,22 @@ +require 'rexml/document' +require File.expand_path('../../../../spec_helper', __FILE__) + +describe "REXML::Element#[]" do + + before :each do + @doc = REXML::Document.new("") + @child = REXML::Element.new("child") + @doc.root.add_element @child + end + + ruby_version_is "2.4" do + it "return attribute value if argument is string or symbol" do + @doc.root[:foo].should == 'bar' + @doc.root['foo'].should == 'bar' + end + + it "return nth element if argument is int" do + @doc.root[0].should == @child + end + end +end diff --git a/spec/ruby/library/securerandom/base64_spec.rb b/spec/ruby/library/securerandom/base64_spec.rb index 68e61c9ecb..57db25fa29 100644 --- a/spec/ruby/library/securerandom/base64_spec.rb +++ b/spec/ruby/library/securerandom/base64_spec.rb @@ -36,7 +36,7 @@ describe "SecureRandom.base64" do SecureRandom.base64.length.should < 32 * 2 end - it "treats nil agrument as default one and generates a random base64 string" do + it "treats nil argument as default one and generates a random base64 string" do SecureRandom.base64(nil).should be_kind_of(String) SecureRandom.base64(nil).length.should < 32 * 2 end diff --git a/spec/ruby/library/securerandom/hex_spec.rb b/spec/ruby/library/securerandom/hex_spec.rb index 691392a7b9..8690d8458c 100644 --- a/spec/ruby/library/securerandom/hex_spec.rb +++ b/spec/ruby/library/securerandom/hex_spec.rb @@ -35,7 +35,7 @@ describe "SecureRandom.hex" do SecureRandom.hex.length.should == 32 end - it "treats nil agrument as default one and generates a random hex string of length 32" do + it "treats nil argument as default one and generates a random hex string of length 32" do SecureRandom.hex(nil).should be_kind_of(String) SecureRandom.hex(nil).length.should == 32 end diff --git a/spec/ruby/library/set/compare_by_identity_spec.rb b/spec/ruby/library/set/compare_by_identity_spec.rb new file mode 100644 index 0000000000..437af9dd0b --- /dev/null +++ b/spec/ruby/library/set/compare_by_identity_spec.rb @@ -0,0 +1,147 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'set' + +ruby_version_is '2.4' do + describe "Set#compare_by_identity" do + it "compares its members by identity" do + a = "a" + b1 = "b" + b2 = "b" + + set = Set.new + set.compare_by_identity + set.merge([a, a, b1, b2]) + set.to_a.sort.should == [a, b1, b2].sort + end + + it "causes future comparisons on the receiver to be made by identity" do + elt = [1] + set = Set.new + set << elt + set.member?(elt.dup).should be_true + set.compare_by_identity + set.member?(elt.dup).should be_false + end + + it "rehashes internally so that old members can be looked up" do + set = Set.new + (1..10).each { |k| set << k } + o = Object.new + def o.hash; 123; end + set << o + set.compare_by_identity + set.member?(o).should be_true + end + + it "returns self" do + set = Set.new + result = set.compare_by_identity + result.should equal(set) + end + + it "is idempotent and has no effect on an already compare_by_identity set" do + set = Set.new.compare_by_identity + set << :foo + set.compare_by_identity.should equal(set) + set.compare_by_identity?.should == true + set.to_a.should == [:foo] + end + + it "uses the semantics of BasicObject#equal? to determine members identity" do + :a.equal?(:a).should == true + Set.new.compare_by_identity.merge([:a, :a]).to_a.should == [:a] + + ary1 = [1] + ary2 = [1] + ary1.equal?(ary2).should == false + Set.new.compare_by_identity.merge([ary1, ary2]).to_a.sort.should == [ary1, ary2].sort + end + + it "uses #equal? semantics, but doesn't actually call #equal? to determine identity" do + set = Set.new.compare_by_identity + obj = mock("equal") + obj.should_not_receive(:equal?) + set << :foo + set << obj + set.to_a.should == [:foo, obj] + end + + it "does not call #hash on members" do + elt = mock("element") + elt.should_not_receive(:hash) + set = Set.new.compare_by_identity + set << elt + set.member?(elt).should be_true + end + + it "regards #dup'd objects as having different identities" do + a1 = "a" + a2 = a1.dup + + set = Set.new.compare_by_identity + set.merge([a1, a2]) + set.to_a.sort.should == [a1, a2].sort + end + + it "regards #clone'd objects as having different identities" do + a1 = "a" + a2 = a1.clone + + set = Set.new.compare_by_identity + set.merge([a1, a2]) + set.to_a.sort.should == [a1, a2].sort + end + + it "raises a RuntimeError on frozen sets" do + set = Set.new.freeze + lambda { + set.compare_by_identity + }.should raise_error(RuntimeError, /frozen Hash/) + end + + it "persists over #dups" do + set = Set.new.compare_by_identity + set << :a + set_dup = set.dup + set_dup.should == set + set_dup << :a + set_dup.to_a.should == [:a] + end + + it "persists over #clones" do + set = Set.new.compare_by_identity + set << :a + set_clone = set.clone + set_clone.should == set + set_clone << :a + set_clone.to_a.should == [:a] + end + + it "is not equal to set what does not compare by identity" do + Set.new([1, 2]).should == Set.new([1, 2]) + Set.new([1, 2]).should_not == Set.new([1, 2]).compare_by_identity + end + end +end + +ruby_version_is '2.4' do + describe "Set#compare_by_identity?" do + it "returns false by default" do + Set.new.compare_by_identity?.should == false + end + + it "returns true once #compare_by_identity has been invoked on self" do + set = Set.new + set.compare_by_identity + set.compare_by_identity?.should == true + end + + it "returns true when called multiple times on the same set" do + set = Set.new + set.compare_by_identity + set.compare_by_identity?.should == true + set.compare_by_identity?.should == true + set.compare_by_identity?.should == true + end + end +end diff --git a/spec/ruby/library/set/shared/difference.rb b/spec/ruby/library/set/shared/difference.rb index 9439715da7..52807709c3 100644 --- a/spec/ruby/library/set/shared/difference.rb +++ b/spec/ruby/library/set/shared/difference.rb @@ -3,7 +3,7 @@ describe :set_difference, shared: true do @set = Set[:a, :b, :c] end - it "returns a new Set containting self's elements excluding the elements in the passed Enumerable" do + it "returns a new Set containing self's elements excluding the elements in the passed Enumerable" do @set.send(@method, Set[:a, :b]).should == Set[:c] @set.send(@method, [:b, :c]).should == Set[:a] end diff --git a/spec/ruby/library/set/sortedset/shared/difference.rb b/spec/ruby/library/set/sortedset/shared/difference.rb index ec57015ac2..cf50ff0eb2 100644 --- a/spec/ruby/library/set/sortedset/shared/difference.rb +++ b/spec/ruby/library/set/sortedset/shared/difference.rb @@ -3,7 +3,7 @@ describe :sorted_set_difference, shared: true do @set = SortedSet["a", "b", "c"] end - it "returns a new SortedSet containting self's elements excluding the elements in the passed Enumerable" do + it "returns a new SortedSet containing self's elements excluding the elements in the passed Enumerable" do @set.send(@method, SortedSet["a", "b"]).should == SortedSet["c"] @set.send(@method, ["b", "c"]).should == SortedSet["a"] end diff --git a/spec/ruby/library/shellwords/shellwords_spec.rb b/spec/ruby/library/shellwords/shellwords_spec.rb index aa35c1a5c3..f8ab0cbd9d 100644 --- a/spec/ruby/library/shellwords/shellwords_spec.rb +++ b/spec/ruby/library/shellwords/shellwords_spec.rb @@ -26,4 +26,11 @@ describe "Shellwords#shellwords" do it "raises ArgumentError when single quoted strings are misquoted" do lambda { shellwords("a 'b c d e") }.should raise_error(ArgumentError) end + + ruby_version_is '2.4' do + # https://bugs.ruby-lang.org/issues/10055 + it "matches POSIX sh behavior for backslashes within double quoted strings" do + shellsplit('printf "%s\n"').should == ['printf', '%s\n'] + end + end end diff --git a/spec/ruby/library/socket/tcpserver/accept_spec.rb b/spec/ruby/library/socket/tcpserver/accept_spec.rb index f7b017d014..e7a1d87dbe 100644 --- a/spec/ruby/library/socket/tcpserver/accept_spec.rb +++ b/spec/ruby/library/socket/tcpserver/accept_spec.rb @@ -48,14 +48,15 @@ describe "TCPServer#accept" do end it "can be interrupted by Thread#raise" do - t = Thread.new { @server.accept } + t = Thread.new { + -> { + @server.accept + }.should raise_error(Exception, "interrupted") + } Thread.pass while t.status and t.status != "sleep" - - # raise in thread, ensure the raise happens - ex = Exception.new - t.raise ex - lambda { t.join }.should raise_error(Exception) + t.raise Exception, "interrupted" + t.join end it "raises an IOError if the socket is closed" do diff --git a/spec/ruby/library/socket/tcpserver/new_spec.rb b/spec/ruby/library/socket/tcpserver/new_spec.rb index ddbe96d89d..adbc3f303e 100644 --- a/spec/ruby/library/socket/tcpserver/new_spec.rb +++ b/spec/ruby/library/socket/tcpserver/new_spec.rb @@ -62,7 +62,7 @@ describe "TCPServer.new" do # pick such a service port that will be able to reliably bind... end - it "raises Errno::EADDRNOTAVAIL when the adress is unknown" do + it "raises Errno::EADDRNOTAVAIL when the address is unknown" do lambda { TCPServer.new("1.2.3.4", 0) }.should raise_error(Errno::EADDRNOTAVAIL) end diff --git a/spec/ruby/library/socket/unixserver/accept_spec.rb b/spec/ruby/library/socket/unixserver/accept_spec.rb index 90b22d7eb1..3921dadd9d 100644 --- a/spec/ruby/library/socket/unixserver/accept_spec.rb +++ b/spec/ruby/library/socket/unixserver/accept_spec.rb @@ -48,14 +48,14 @@ platform_is_not :windows do it "can be interrupted by Thread#raise" do t = Thread.new { - @server.accept + -> { + @server.accept + }.should raise_error(Exception, "interrupted") } - Thread.pass while t.status and t.status != "sleep" - # raise in thread, ensure the raise happens - ex = Exception.new - t.raise ex - lambda { t.join }.should raise_error(Exception) + Thread.pass while t.status and t.status != "sleep" + t.raise Exception, "interrupted" + t.join end end end diff --git a/spec/ruby/library/stringio/each_line_spec.rb b/spec/ruby/library/stringio/each_line_spec.rb index e4deb9b3e9..d770c18e67 100644 --- a/spec/ruby/library/stringio/each_line_spec.rb +++ b/spec/ruby/library/stringio/each_line_spec.rb @@ -13,3 +13,9 @@ end describe "StringIO#each_line when self is not readable" do it_behaves_like :stringio_each_not_readable, :each_line end + +ruby_version_is "2.4" do + describe "StringIO#each_line when passed chomp" do + it_behaves_like :stringio_each_chomp, :each_line + end +end diff --git a/spec/ruby/library/stringio/each_spec.rb b/spec/ruby/library/stringio/each_spec.rb index 07ad070192..cebaa345d8 100644 --- a/spec/ruby/library/stringio/each_spec.rb +++ b/spec/ruby/library/stringio/each_spec.rb @@ -13,3 +13,9 @@ end describe "StringIO#each when self is not readable" do it_behaves_like :stringio_each_not_readable, :each end + +ruby_version_is "2.4" do + describe "StringIO#each when passed chomp" do + it_behaves_like :stringio_each_chomp, :each + end +end diff --git a/spec/ruby/library/stringio/getc_spec.rb b/spec/ruby/library/stringio/getc_spec.rb index f7e98d2a33..804502d8ba 100644 --- a/spec/ruby/library/stringio/getc_spec.rb +++ b/spec/ruby/library/stringio/getc_spec.rb @@ -5,7 +5,7 @@ require File.expand_path('../shared/getc', __FILE__) describe "StringIO#getc" do it_behaves_like :stringio_getc, :getc - it "returns the charactor at the current position" do + it "returns the character at the current position" do io = StringIO.new("example") io.send(@method).should == ?e diff --git a/spec/ruby/library/stringio/getch_spec.rb b/spec/ruby/library/stringio/getch_spec.rb index c7fdfe9080..d6f652424e 100644 --- a/spec/ruby/library/stringio/getch_spec.rb +++ b/spec/ruby/library/stringio/getch_spec.rb @@ -9,7 +9,7 @@ describe "StringIO#getch" do it_behaves_like :stringio_getc, :getch - it "returns the charactor at the current position" do + it "returns the character at the current position" do io = StringIO.new("example") io.send(@method).should == ?e diff --git a/spec/ruby/library/stringio/gets_spec.rb b/spec/ruby/library/stringio/gets_spec.rb index 307f564a6e..f94448688b 100644 --- a/spec/ruby/library/stringio/gets_spec.rb +++ b/spec/ruby/library/stringio/gets_spec.rb @@ -6,7 +6,7 @@ describe "StringIO#gets when passed [separator]" do @io = StringIO.new("this>is>an>example") end - it "returns the data read till the next occurence of the passed separator" do + it "returns the data read till the next occurrence of the passed separator" do @io.gets(">").should == "this>" @io.gets(">").should == "is>" @io.gets(">").should == "an>" @@ -72,7 +72,7 @@ describe "StringIO#gets when passed no argument" do @io = StringIO.new("this is\nan example\nfor StringIO#gets") end - it "returns the data read till the next occurence of $/ or till eof" do + it "returns the data read till the next occurrence of $/ or till eof" do @io.gets.should == "this is\n" begin @@ -236,3 +236,12 @@ describe "StringIO#gets when in write-only mode" do lambda { io.gets }.should raise_error(IOError) end end + +ruby_version_is "2.4" do + describe "StringIO#gets when passed [chomp]" do + it "returns the data read without a trailing newline character" do + io = StringIO.new("this>is>an>example\n") + io.gets(chomp: true).should == "this>is>an>example" + end + end +end \ No newline at end of file diff --git a/spec/ruby/library/stringio/lines_spec.rb b/spec/ruby/library/stringio/lines_spec.rb index 550b25549e..c3af802073 100644 --- a/spec/ruby/library/stringio/lines_spec.rb +++ b/spec/ruby/library/stringio/lines_spec.rb @@ -13,3 +13,9 @@ end describe "StringIO#lines when self is not readable" do it_behaves_like :stringio_each_not_readable, :lines end + +ruby_version_is "2.4" do + describe "StringIO#lines when passed chomp" do + it_behaves_like :stringio_each_chomp, :lines + end +end diff --git a/spec/ruby/library/stringio/readline_spec.rb b/spec/ruby/library/stringio/readline_spec.rb index 90890e3ad1..1deb52c492 100644 --- a/spec/ruby/library/stringio/readline_spec.rb +++ b/spec/ruby/library/stringio/readline_spec.rb @@ -7,7 +7,7 @@ describe "StringIO#readline when passed [separator]" do @io = StringIO.new("this>is>an>example") end - it "returns the data read till the next occurence of the passed separator" do + it "returns the data read till the next occurrence of the passed separator" do @io.readline(">").should == "this>" @io.readline(">").should == "is>" @io.readline(">").should == "an>" @@ -60,7 +60,7 @@ describe "StringIO#readline when passed no argument" do @io = StringIO.new("this is\nan example\nfor StringIO#readline") end - it "returns the data read till the next occurence of $/ or till eof" do + it "returns the data read till the next occurrence of $/ or till eof" do @io.readline.should == "this is\n" begin @@ -120,3 +120,12 @@ describe "StringIO#readline when in write-only mode" do lambda { io.readline }.should raise_error(IOError) end end + +ruby_version_is "2.4" do + describe "StringIO#readline when passed [chomp]" do + it "returns the data read without a trailing newline character" do + io = StringIO.new("this>is>an>example\n") + io.readline(chomp: true).should == "this>is>an>example" + end + end +end diff --git a/spec/ruby/library/stringio/readlines_spec.rb b/spec/ruby/library/stringio/readlines_spec.rb index 215a6cbb2a..11217d1e59 100644 --- a/spec/ruby/library/stringio/readlines_spec.rb +++ b/spec/ruby/library/stringio/readlines_spec.rb @@ -90,3 +90,12 @@ describe "StringIO#readlines when in write-only mode" do lambda { io.readlines }.should raise_error(IOError) end end + +ruby_version_is "2.4" do + describe "StringIO#readlines when passed [chomp]" do + it "returns the data read without a trailing newline character" do + io = StringIO.new("this>is\nan>example\r\n") + io.readlines(chomp: true).should == ["this>is", "an>example"] + end + end +end diff --git a/spec/ruby/library/stringio/shared/each.rb b/spec/ruby/library/stringio/shared/each.rb index 0fde23634e..55ed27c1c7 100644 --- a/spec/ruby/library/stringio/shared/each.rb +++ b/spec/ruby/library/stringio/shared/each.rb @@ -103,3 +103,12 @@ describe :stringio_each_not_readable, shared: true do lambda { io.send(@method) { |b| b } }.should raise_error(IOError) end end + +describe :stringio_each_chomp, shared: true do + it "yields each line with removed newline characters to the passed block" do + seen = [] + io = StringIO.new("a b \rc d e\n1 2 3 4 5\r\nthe end") + io.send(@method, chomp: true) {|s| seen << s } + seen.should == ["a b \rc d e", "1 2 3 4 5", "the end"] + end +end diff --git a/spec/ruby/library/time/to_time_spec.rb b/spec/ruby/library/time/to_time_spec.rb new file mode 100644 index 0000000000..a02ec31cb9 --- /dev/null +++ b/spec/ruby/library/time/to_time_spec.rb @@ -0,0 +1,17 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'time' + +ruby_version_is "2.4" do + describe "Time#to_time" do + it "returns itself in the same timezone" do + time = Time.new(2012, 2, 21, 10, 11, 12) + + with_timezone("America/Regina") do + time.to_time.should equal time + end + + time2 = Time.utc(2012, 2, 21, 10, 11, 12) + time2.to_time.should equal time2 + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb index fc8d1d7691..f904107c6c 100644 --- a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb @@ -10,7 +10,7 @@ platform_is :windows do lambda { WIN32OLE_METHOD.new(1, 2) }.should raise_error TypeError end - it "raises ArgumentError if only 1 arugment is given" do + it "raises ArgumentError if only 1 argument is given" do lambda { WIN32OLE_METHOD.new("hello") }.should raise_error ArgumentError lambda { WIN32OLE_METHOD.new(@ole_type) }.should raise_error ArgumentError end diff --git a/spec/ruby/library/yaml/shared/each_document.rb b/spec/ruby/library/yaml/shared/each_document.rb index 5d9d240005..999123dc2a 100644 --- a/spec/ruby/library/yaml/shared/each_document.rb +++ b/spec/ruby/library/yaml/shared/each_document.rb @@ -1,5 +1,5 @@ describe :yaml_each_document, shared: true do - it "calls the block on each succesive document" do + it "calls the block on each successive document" do documents = [] YAML.send(@method, $multidocument) do |doc| documents << doc diff --git a/spec/ruby/library/yaml/to_yaml_spec.rb b/spec/ruby/library/yaml/to_yaml_spec.rb index d129fe2d79..afe583d502 100644 --- a/spec/ruby/library/yaml/to_yaml_spec.rb +++ b/spec/ruby/library/yaml/to_yaml_spec.rb @@ -46,7 +46,7 @@ describe "Object#to_yaml" do nil_klass.to_yaml.should match_yaml("--- \n") end - it "returns the YAML represenation of a RegExp object" do + it "returns the YAML representation of a RegExp object" do Regexp.new('^a-z+:\\s+\w+').to_yaml.should match_yaml("--- !ruby/regexp /^a-z+:\\s+\\w+/\n") end -- cgit v1.2.3