Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

use expect instead of should in rspec #966

Merged
merged 1 commit into from

3 participants

@rajcybage

As we are using rspec new version we can use then expect in all our rspec test cases.

As for better rspec http://betterspecs.org/#expect.

If it is acceptable then I will proceed to change others

Thanks

@BanzaiMan BanzaiMan was assigned
spec/java_integration/addons/throwable_spec.rb
((6 lines not shown))
end
it "does not prevent catch/throw from working" do
- lambda do
+ expect do
@BanzaiMan Owner

Indentation seems off here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@BanzaiMan
Owner

The commit subject should be fixed.

@rajcybage

Done

Thank you @BanzaiMan

@jrubyci jrubyci merged commit 76b73a8 into jruby:master
@rajcybage rajcybage deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 22, 2013
  1. use expect instead of should for better rspec

    Rajarshi Das authored
This page is out of date. Refresh to see the latest.
View
4 spec/java_integration/addons/net_spec.rb
@@ -11,7 +11,7 @@
contents = java.net.URL.new(@url).open do |io|
io.read
end
- contents.should == File.read(__FILE__)
+ expect(contents).to eq(File.read(__FILE__))
end
it "can used with 'open-uri' and passed to #open and yield an IO" do
@@ -19,6 +19,6 @@
contents = open(java.net.URL.new(@url)) do |io|
io.read
end
- contents.should == File.read(__FILE__)
+ expect(contents).to eq(File.read(__FILE__))
end
end
View
4 spec/java_integration/addons/object_spec.rb
@@ -24,14 +24,14 @@
class Foo
java_import java.util.Properties
end
- Foo.constants.should have_strings_or_symbols 'Properties'
+ expect(Foo.constants).to have_strings_or_symbols 'Properties'
end
it "should allow inclusion of Java class constants in module context" do
module Foo
java_import java.util.Properties
end
- Foo.constants.should have_strings_or_symbols 'Properties'
+ expect(Foo.constants).to have_strings_or_symbols 'Properties'
end
it "should allow inclusion of Java class constants in instance context" do
View
2  spec/java_integration/addons/string_spec.rb
@@ -3,6 +3,6 @@
describe "String#to_java_string" do
it "produces a wrapped Java String" do
wrapped = 'foo'.to_java_string
- wrapped.class.should == java.lang.String
+ expect(wrapped.class).to eq java.lang.String
end
end
View
4 spec/java_integration/addons/synchronized_class_spec.rb
@@ -11,11 +11,11 @@ def call_wait
end
def expect_synchronized
- lambda { call_wait }.should_not raise_error
+ expect { call_wait }.not_to raise_error
end
def expect_unsynchronized
- lambda { call_wait }.should raise_error(java.lang.IllegalMonitorStateException)
+ expect { call_wait }.to raise_error(java.lang.IllegalMonitorStateException)
end
end
end
View
36 spec/java_integration/addons/throwable_spec.rb
@@ -6,24 +6,24 @@
ex = java.lang.Exception.new
trace = nil
lambda {trace = ex.backtrace}.should_not raise_error
- trace.should == ex.stack_trace.map(&:to_s)
+ expect(trace).to eq(ex.stack_trace.map(&:to_s))
end
it "implements backtrace= as a no-op" do
ex = java.lang.Exception.new
backtrace = ex.backtrace
ex.set_backtrace ['blah']
- ex.backtrace.should == backtrace
+ expect(ex.backtrace).to eq backtrace
end
it "implements to_s as message" do
ex = java.lang.Exception.new
- ex.to_s.should == ""
- ex.to_s.should == ex.message
+ expect(ex.to_s).to eq ""
+ expect(ex.to_s).to eq ex.message
ex = java.lang.Exception.new('hello')
- ex.to_s.should == 'hello'
- ex.to_s.should == ex.message
+ expect(ex.to_s).to eq 'hello'
+ expect(ex.to_s).to eq ex.message
end
it "implements to_str to call to_s" do
@@ -32,19 +32,19 @@ def ex.to_s
'hello'
end
- ex.to_str.should == 'hello'
+ expect(ex.to_str).to eq 'hello'
end
it "implements inspect as toString" do
ex = java.lang.Exception.new('hello')
- ex.inspect.should == "java.lang.Exception: hello"
+ expect(ex.inspect).to eq "java.lang.Exception: hello"
end
it "can be rescued by rescue Exception" do
begin
raise ex = java.lang.Exception.new
rescue Exception => e
- e.should == ex
+ expect(e).to eq(ex)
end
end
@@ -52,7 +52,7 @@ def ex.to_s
begin
raise ex = java.lang.Exception.new
rescue java.lang.Exception => e
- e.should == ex
+ expect(e).to eq(ex)
end
end
@@ -60,7 +60,7 @@ def ex.to_s
begin
raise ex = java.lang.Exception.new
rescue Object => e
- e.should == ex
+ expect(e).to eq(ex)
end
end
end
@@ -77,17 +77,17 @@ def x.foo
end
end
end
- x.foo.should == 1
+ expect(x.foo).to eq 1
end
it "does not prevent non-local break from working" do
- loop do
+ expect(loop do
begin
break 1
rescue Exception
2
end
- end.should == 1
+ end).to eq 1
end
it "does not prevent non-local redo from working" do
@@ -101,11 +101,11 @@ def x.foo
i = 3
end
end
- i.should == 2
+ expect(i).to eq 2
end
it "does not prevent catch/throw from working" do
- lambda do
+ expect do
catch :blah do
begin
throw :blah
@@ -113,7 +113,7 @@ def x.foo
raise
end
end
- end.should_not raise_error
+ end.not_to raise_error
end
it "does not prevent retry from working" do
@@ -128,6 +128,6 @@ def x.foo
i = 3
end
end
- i.should == 2
+ expect(i).to eq 2
end
end
Something went wrong with that request. Please try again.