Browse files

Switch to new expect syntax.

  • Loading branch information...
1 parent a7f5731 commit a9fbefa796f0650aaa6d9a6613627f3f3a1e7630 @myronmarston myronmarston committed Jan 22, 2013
Showing with 25 additions and 24 deletions.
  1. +12 −12 spec/rspec/matchers/include_matcher_integration_spec.rb
  2. +13 −12 spec/rspec/matchers/include_spec.rb
View
24 spec/rspec/matchers/include_matcher_integration_spec.rb
@@ -4,26 +4,26 @@ module RSpec
module Matchers
describe "include() interaction with built-in matchers" do
it "works with be_within(delta).of(expected)" do
- [10, 20, 30].should include( be_within(5).of(24) )
- [10, 20, 30].should_not include( be_within(3).of(24) )
+ expect([10, 20, 30]).to include( be_within(5).of(24) )
+ expect([10, 20, 30]).not_to include( be_within(3).of(24) )
end
-
+
it "works with be_instance_of(klass)" do
- ["foo", 123, {:foo => "bar"}].should include( be_instance_of(Hash) )
- ["foo", 123, {:foo => "bar"}].should_not include( be_instance_of(Range) )
+ expect(["foo", 123, {:foo => "bar"}]).to include( be_instance_of(Hash) )
+ expect(["foo", 123, {:foo => "bar"}]).not_to include( be_instance_of(Range) )
end
-
+
it "works with be_kind_of(klass)" do
class StringSubclass < String; end
class NotHashSubclass; end
-
- [StringSubclass.new("baz")].should include( be_kind_of(String) )
- [NotHashSubclass.new].should_not include( be_kind_of(Hash) )
+
+ expect([StringSubclass.new("baz")]).to include( be_kind_of(String) )
+ expect([NotHashSubclass.new]).not_to include( be_kind_of(Hash) )
end
-
+
it "works with be_[some predicate]" do
- [stub("actual", :happy? => true)].should include( be_happy )
- [stub("actual", :happy? => false)].should_not include( be_happy )
+ expect([stub("actual", :happy? => true)]).to include( be_happy )
+ expect([stub("actual", :happy? => false)]).not_to include( be_happy )
end
end
end
View
25 spec/rspec/matchers/include_spec.rb
@@ -391,35 +391,36 @@ def array.send; :sent; end
match do |actual|
actual.include?(expected)
end
+
description do
"a string containing '#{expected}'"
end
end
-describe "should include(matcher)" do
+describe "expect(...).to include(matcher)" do
context 'for an array target' do
it "passes if target includes an object that satisfies the matcher" do
- ['foo', 'bar', 'baz'].should include(string_containing_string("ar"))
+ expect(['foo', 'bar', 'baz']).to include(string_containing_string("ar"))
end
-
+
it "fails if target doesn't include object that satisfies the matcher" do
- lambda {
- ['foo', 'bar', 'baz'].should include(string_containing_string("abc"))
- }.should fail_matching(%Q|expected #{['foo', 'bar', 'baz'].inspect} to include a string containing 'abc'|)
+ expect {
+ expect(['foo', 'bar', 'baz']).to include(string_containing_string("abc"))
+ }.to fail_matching(%Q|expected #{['foo', 'bar', 'baz'].inspect} to include a string containing 'abc'|)
end
end
end
-describe "should include(multiple, matcher, arguments)" do
- context 'for an array target' do
+describe "expect(...).to include(multiple, matcher, arguments)" do
+ context 'for an array target' do
it "passes if target includes items satisfying all matchers" do
- ['foo', 'bar', 'baz'].should include(string_containing_string("ar"), string_containing_string('oo'))
+ expect(['foo', 'bar', 'baz']).to include(string_containing_string("ar"), string_containing_string('oo'))
end
it "fails if target does not include an item satisfying any one of the items" do
- lambda {
- ['foo', 'bar', 'baz'].should include(string_containing_string("ar"), string_containing_string("abc"))
- }.should fail_matching(%Q|expected #{['foo', 'bar', 'baz'].inspect} to include a string containing 'ar' and a string containing 'abc'|)
+ expect {
+ expect(['foo', 'bar', 'baz']).to include(string_containing_string("ar"), string_containing_string("abc"))
+ }.to fail_matching(%Q|expected #{['foo', 'bar', 'baz'].inspect} to include a string containing 'ar' and a string containing 'abc'|)
end
end
end

0 comments on commit a9fbefa

Please sign in to comment.