Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Working on rspec tests.

  • Loading branch information...
commit 864585237fc855c914a45fcc6897ae211232ec8a 1 parent 4998666
Rian Rainey authored
View
10 Gemfile
@@ -9,14 +9,16 @@ gem 'bootstrap-wysihtml5-rails'
gem 'devise'
-group :development do
+group :development, :test do
gem 'rspec-rails'
- gem 'annotate'
- gem 'guard-rspec'
+ gem 'annotate' # Automatic model documentation
+ gem 'guard-rspec' # Automate testing
+ gem 'factory_girl_rails' # Uses test data for tests
+ gem 'capybara' # Helps imitate a browser
+ gem 'faker' # Generates fake test data
end
group :test do
- gem 'capybara'
end
# Gems used only for assets and not required
View
9 Gemfile.lock
@@ -63,6 +63,13 @@ GEM
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
+ factory_girl (4.1.0)
+ activesupport (>= 3.0.0)
+ factory_girl_rails (4.1.0)
+ factory_girl (~> 4.1.0)
+ railties (>= 3.0.0)
+ faker (1.0.1)
+ i18n (~> 0.4)
ffi (1.1.5)
guard (1.5.1)
listen (>= 0.4.2)
@@ -175,6 +182,8 @@ DEPENDENCIES
capybara
coffee-rails (~> 3.2.1)
devise
+ factory_girl_rails
+ faker
guard-rspec
jquery-rails
pg
View
13 spec/controllers/users_controller_spec.rb
@@ -160,5 +160,18 @@
# response.should redirect_to(users_url)
# end
# end
+
+ describe "authenticated users can only edit their own profile" do
+ it "prevents modification of others' profiles" do
+ user = FactoryGirl.create(:user)
+ puts user.id
+ link = "/users/edit/#{user.id}"
+ puts link
+ end
+
+ it "allows modification of own profile"
+
+
+ end
end
View
0  spec/factories/roles.rb
No changes.
View
8 spec/factories/users.rb
@@ -0,0 +1,8 @@
+require 'faker'
+
+FactoryGirl.define do
+ factory :user do |f|
+ f.email { Faker::Internet.email }
+ f.password { Faker::Lorem.characters(6) }
+ end
+end
View
2  spec/helpers/roles_helper_spec.rb
@@ -11,5 +11,5 @@
# end
# end
describe RolesHelper do
- pending "add some examples to (or delete) #{__FILE__}"
+ #pending "add some examples to (or delete) #{__FILE__}"
end
View
2  spec/helpers/users_helper_spec.rb
@@ -11,5 +11,5 @@
# end
# end
describe UsersHelper do
- pending "add some examples to (or delete) #{__FILE__}"
+ #pending "add some examples to (or delete) #{__FILE__}"
end
View
2  spec/helpers/workouts_helper_spec.rb
@@ -11,5 +11,5 @@
# end
# end
describe WorkoutsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
+ #pending "add some examples to (or delete) #{__FILE__}"
end
View
4 spec/models/role_spec.rb
@@ -1,5 +1,7 @@
require 'spec_helper'
describe Role do
- pending "add some examples to (or delete) #{__FILE__}"
+
+ it "has only 4 roles: Admin, Member, Staff and Super Admin"
+
end
View
37 spec/models/user_spec.rb
@@ -13,5 +13,40 @@
require 'spec_helper'
describe User do
- pending "add some examples to (or delete) #{__FILE__}"
+
+ it "has a valid factory" do
+ FactoryGirl.create(:user).should be_valid
+ end
+
+ it "is invalid without an email" do
+ FactoryGirl.build(:user, email: nil).should_not be_valid
+ end
+
+ it "is invalid without a password" do
+ FactoryGirl.build(:user, password: nil).should_not be_valid
+ end
+
+ it "is valid without first name" do
+ FactoryGirl.build(:user, firstName: nil).should be_valid
+ end
+
+ it "is valid without last name" do
+ FactoryGirl.build(:user, lastName: nil).should be_valid
+ end
+
+ it "does not allow passwords less than 6 characters" do
+ FactoryGirl.build(:user, password: "12345").should_not be_valid
+ end
+
+ it "does not allow separate users with same email addresses" do
+ FactoryGirl.create(:user, email: "john@smith.com", password: "123456")
+ FactoryGirl.build(:user, email: "john@smith.com", password: "123456").should_not be_valid
+ end
+
+ it "returns a user's full name as a string" do
+ user = FactoryGirl.create(:user, firstName: "John", lastName: "Smith")
+ user.name.should == "John Smith"
+ end
+
+
end
View
2  spec/models/workout_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
describe Workout do
- pending "add some examples to (or delete) #{__FILE__}"
+ #pending "add some examples to (or delete) #{__FILE__}"
end
View
22 spec/requests/roles_spec.rb
@@ -1,11 +1,17 @@
require 'spec_helper'
-describe "Roles" do
- # describe "GET /roles" do
- # it "works! (now write some real specs)" do
- # # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- # get roles_path
- # response.status.should be(200)
- # end
- # end
+describe "Roles Testing:" do
+ describe "GET /admin/roles" do
+ it "should display all roles to Admin" do
+ visit admin_roles_path
+
+ #page.should have_content(["Admin", "Member"].include?)
+ end
+
+ it "should NOT display roles to non-admin users" do
+
+ end
+ end
+
+
end
View
39 spec/routing/users_routing_spec.rb
@@ -1,48 +1,41 @@
require "spec_helper"
describe Admin::UsersController do
- describe "routing" do
+ describe "Admin Users Routing:" do
- it "routes to #index" do
+ it "routes to admin#index" do
get("/admin/users").should route_to(
:controller => "admin/users",
:action => "index")
end
- it "routes to #new" do
+ it "routes to admin#new" do
get("/admin/users/new").should route_to(
:controller => "admin/users",
:action => "new")
end
- it "routes to #show" do
- get("/users/1").should route_to(
- :controller => "users",
- :action => "show",
- :id => "1")
- end
-
- it "routes to #edit" do
+ it "routes to admin#edit" do
get("/admin/users/1/edit").should route_to(
:controller => "admin/users",
:action => "edit",
:id => "1")
end
- it "routes to #create" do
+ it "routes to admin#create" do
post("/admin/users").should route_to(
:controller => "admin/users",
:action => "create")
end
- it "routes to #update" do
+ it "routes to admin#update" do
put("/admin/users/1").should route_to(
:controller => "admin/users",
:action => "update",
:id => "1")
end
- it "routes to #destroy" do
+ it "routes to admin#destroy" do
delete("/admin/users/1").should route_to(
:controller => "admin/users",
:action => "destroy",
@@ -50,4 +43,22 @@
end
end
+
end
+
+describe UsersController do
+ describe "Users Routing:" do
+
+ it "/users should not be routable" do
+ expect(:get => '/users').not_to be_routable
+ end
+
+ it "routes to #show" do
+ get("/users/1").should route_to(
+ :controller => "users",
+ :action => "show",
+ :id => "1")
+ end
+ end
+end
+
View
6 spec/views/users/edit.html.erb_spec.rb
@@ -19,4 +19,10 @@
# assert_select "input#user_email", :name => "user[email]"
# end
# end
+
+ it "authenticated users can only see an edit button on their profile"
+
+
+
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.