Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

User model spec

  • Loading branch information...
commit cf442d3c955578fa53258785cf31a73a1d0720c4 1 parent 9930b0f
@ArturG ArturG authored
View
13 features/step_definitions/user_steps.rb
@@ -1,5 +1,5 @@
def login_user
- @user = User.create!(username: "test_user",
+ @user = User.create!(username: "test_user",
email: "test_user@example.com",
password: "foobar",
password_confirmation: "foobar")
@@ -20,6 +20,13 @@ def create_other_user
login_user unless @user
end
+Given /^a steve exists$/ do
+ @steve = User.create!(username: "steve",
+ email: "steve_user@example.com",
+ password: "foobar",
+ password_confirmation: "foobar")
+end
+
When /^I go to look at my profile page$/ do
visit user_path(@user)
end
@@ -73,3 +80,7 @@ def create_other_user
page.should have_content("Test user likes to edit his profile")
end
+Then(/^I should see 'Steve'$/) do
+ @user.following?(@steve).should == true
+ page.should have_link @steve.username
+end
View
8 features/users.feature
@@ -3,7 +3,8 @@ Feature: Manage account
As a user of this site, I can view and update my profile, see my followers
Background:
- Given a logged in user
+ Given a steve exists
+ And a logged in user
Scenario: View my profile
When I go to look at my profile page
@@ -23,4 +24,7 @@ Feature: Manage account
When I am following someone
And I click on the number of people I am following on my profile
Then I should see someone I'm following
-
+
+ Scenario: I should always follow steve and vice versa
+ When I click on the number of people I am following on my profile
+ Then I should see 'Steve'
View
16 spec/models/user_spec.rb
@@ -1,10 +1,10 @@
require 'spec_helper'
describe User do
-
- let(:bob){Fabricate(:user)}
+ let(:bob){Fabricate(:user, :username => 'hacker')}
let(:mozart){Fabricate(:user)}
-
+ let(:hello_world){Fabricate(:program, :author_username => bob.username)}
+
it 'can be created validly' do
bob.should be_valid
mozart.should be_valid
@@ -17,4 +17,14 @@
bob.reload
bob.following?(mozart).should be_false
end
+
+ describe 'programs' do
+ it 'should return programs list' do
+ bob.programs.class.should == Plucky::Query
+ hello_world.author_username.should == 'hacker'
+ bob.username.should == 'hacker'
+ bob.programs.count.should == 1
+ bob.programs.first.should == hello_world
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.