Skip to content

Commit 6a04f39

Browse files
Merge pull request #75 from petergoldstein/feature/rspec_3_compatible
Make RSpec 3 compatible
2 parents 0d41403 + 4e0c801 commit 6a04f39

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

spec/comment_spec.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99

1010
describe "that is valid" do
1111
it "should have a user" do
12-
@comment.user.should_not be_nil
12+
expect(@comment.user).not_to be_nil
1313
end
1414

1515
it "should have a body" do
16-
@comment.body.should_not be_nil
16+
expect(@comment.body).not_to be_nil
1717
end
1818
end
1919

2020
it "should not have a parent if it is a root Comment" do
21-
@comment.parent.should be_nil
21+
expect(@comment.parent).to be_nil
2222
end
2323

2424
it "can have see how child Comments it has" do
25-
@comment.children.size.should == 0
25+
expect(@comment.children.size).to eq(0)
2626
end
2727

2828
it "can add child Comments" do
2929
grandchild = Comment.new(:body => "This is a grandchild", :user => @user)
3030
grandchild.save!
3131
grandchild.move_to_child_of(@comment)
32-
@comment.children.size.should == 1
32+
expect(@comment.children.size).to eq(1)
3333
end
3434

3535
describe "after having a child added" do
@@ -39,11 +39,11 @@
3939
end
4040

4141
it "can be referenced by its child" do
42-
@child.parent.should == @comment
42+
expect(@child.parent).to eq(@comment)
4343
end
4444

4545
it "can see its child" do
46-
@comment.children.first.should == @child
46+
expect(@comment.children.first).to eq(@child)
4747
end
4848
end
4949

@@ -57,11 +57,11 @@
5757
end
5858

5959
it "should return all the comments created by the passed user" do
60-
@comments.should include(@user_comment)
60+
expect(@comments).to include(@user_comment)
6161
end
6262

6363
it "should not return comments created by non-passed users" do
64-
@comments.should_not include(@non_user_comment)
64+
expect(@comments).not_to include(@non_user_comment)
6565
end
6666
end
6767

@@ -76,11 +76,11 @@
7676
end
7777

7878
it "should return the comments for the passed commentable" do
79-
@comments.should include(@user_comment)
79+
expect(@comments).to include(@user_comment)
8080
end
8181

8282
it "should not return the comments for non-passed commentables" do
83-
@comments.should_not include(@other_comment)
83+
expect(@comments).not_to include(@other_comment)
8484
end
8585
end
8686
end

spec/commentable_spec.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe "A class that is commentable" do
44
it "can have many root comments" do
5-
Commentable.new.comment_threads.respond_to?(:each).should be_true
5+
expect(Commentable.new.comment_threads.respond_to?(:each)).to eq(true)
66
end
77

88
describe "when is destroyed" do
@@ -14,7 +14,7 @@
1414

1515
it "also destroys its root comments" do
1616
@commentable.destroy
17-
Comment.all.should_not include(@comment)
17+
expect(Comment.all).not_to include(@comment)
1818
end
1919

2020
it "also destroys its nested comments" do
@@ -23,8 +23,8 @@
2323
child.move_to_child_of(@comment)
2424

2525
@commentable.destroy
26-
Comment.all.should_not include(@comment)
27-
Comment.all.should_not include(child)
26+
expect(Comment.all).not_to include(@comment)
27+
expect(Comment.all).not_to include(child)
2828
end
2929
end
3030

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

4747
it "should return the comments for the passed commentable" do
48-
@comments.should include(@comment)
48+
expect(@comments).to include(@comment)
4949
end
5050

5151
it "should not return the comments for other commentables" do
52-
@comments.should_not include(@other_comment)
52+
expect(@comments).not_to include(@other_comment)
5353
end
5454
end
5555

@@ -65,12 +65,12 @@
6565
end
6666

6767
it "should return comments by the passed user" do
68-
@comments.all? { |c| c.user == @user }.should be_true
68+
expect(@comments.all? { |c| c.user == @user }).to eq(true)
6969
end
7070

7171

7272
it "should not return comments by other users" do
73-
@comments.any? { |c| c.user != @user }.should be_false
73+
expect(@comments.any? { |c| c.user != @user }).to eq(false)
7474
end
7575
end
7676
end
@@ -89,12 +89,12 @@
8989
end
9090

9191
it "should return its own comments, ordered with the newest first" do
92-
@comments.all? { |c| c.commentable_type == @commentable.class.to_s and c.commentable_id == @commentable.id }.should be_true
93-
@comments.each_cons(2) { |c, c2| c.created_at.should > c2.created_at }
92+
expect(@comments.all? { |c| c.commentable_type == @commentable.class.to_s and c.commentable_id == @commentable.id }).to eq(true)
93+
@comments.each_cons(2) { |c, c2| expect(c.created_at).to be > c2.created_at }
9494
end
9595

9696
it "should not include comments for other commentables" do
97-
@comments.any? { |c| c.commentable_type != @commentable.class.to_s or c.commentable_id != @commentable.id }.should be_false
97+
expect(@comments.any? { |c| c.commentable_type != @commentable.class.to_s or c.commentable_id != @commentable.id }).to eq(false)
9898
end
9999
end
100100
end

0 commit comments

Comments
 (0)