Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
rspecs
Browse files Browse the repository at this point in the history
  • Loading branch information
metermaid committed Oct 9, 2013
1 parent 6f60044 commit dd756eb
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

before (:each) do
@user = FactoryGirl.create(:user)
@bookmark = FactoryGirl.create(:bookmark, user: @user)
end

describe "GET 'show'" do
it "assigns the user's posts as @items" do
get 'show', id: @user.id
assigns(:items).should eq([@bookmark])
end

it "returns http success" do
get 'show', id: @user.id
response.should be_success
Expand Down
27 changes: 27 additions & 0 deletions spec/helpers/bookmark_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'spec_helper'

describe BookmarkHelper do

before (:each) do
@bookmark = FactoryGirl.create(:bookmark)
@comment = FactoryGirl.create(:comment)
self.stub(:current_page?) { true }
end

describe "#comment_link" do
context "does not have any comments" do
it "returns a link as 'No Comments'" do
expect { comment_link(@bookmark) == link_to("No Comments", @bookmark) }
end
end
before do
@comment.update_attributes(bookmark: @bookmark)
end
context "has a comment" do
it "returns a link as '1 Comment'" do
expect { comment_link(@bookmark) == link_to("1 Comment", @bookmark) }
end
end
end

end
25 changes: 25 additions & 0 deletions spec/helpers/user_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'spec_helper'

describe UserHelper do

before (:each) do
@user = FactoryGirl.create(:user)
@bookmark = FactoryGirl.create(:bookmark)
end

describe '#user_name' do
context "does not have a user" do
it "returns a blank username" do
expect { user_name(@bookmark) == "Anonymous" }
end
end
before do
@bookmark.update_attributes(user: @user)
end
context "has a user" do
it "returns the user's username" do
expect { user_name(@bookmark) == @user.name }
end
end
end
end

0 comments on commit dd756eb

Please sign in to comment.