Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
finished off my testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Douglas committed Sep 18, 2014
1 parent 59234b3 commit 0681701
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 22 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ end
group :development, :test do
gem "better_errors"
gem 'capybara'
gem 'database_cleaner', '~> 1.3.0'
gem 'factory_girl_rails', '~> 4.0'
gem 'letter_opener', "1.1.2"
gem 'rspec-rails'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.7.0)
database_cleaner (1.3.0)
devise (3.2.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
Expand Down Expand Up @@ -259,6 +260,7 @@ DEPENDENCIES
capybara
carrierwave
coffee-rails (~> 4.0.0)
database_cleaner (~> 1.3.0)
devise
factory_girl_rails (~> 4.0)
faker
Expand Down
21 changes: 17 additions & 4 deletions spec/factories/users_factory.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
FactoryGirl.define do
factory :user do
email 'me@me.com'
sequence(:email) { |n|"me#{n}@me.com" }
name 'brian'
username 'brianllamar'
password 'monkeyturtles'
password_confirmation 'monkeyturtles'
sequence(:username) { |n| "brianllamar#{n}"}
password 'top_secret'
password_confirmation 'top_secret'
end

factory :fake_user do
email Faker::Internet.email
name Faker::Name.name
username Faker::Internet.user_name
password 'top_secret'
password_confirmation 'top_secret'

factory :confirmed_user, :parent => :user do
after(:create) { |user| user.confirm! }
end
end

end
20 changes: 8 additions & 12 deletions spec/features/user_feature_spec.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
require 'spec_helper'

user = FactoryGirl.build(:user)
feature "logging in" do
user = FactoryGirl.build(:confirmed_user)

feature "login" do
it "should work and view as a user" do
visit root_path
click_on 'Sign In'
fill_in 'Email', with: user.email
fill_in 'Password', with: user.password
click_button 'Sign In'
# save_and_open_page

# assert page.has_content?("Discover Churches")
assert_redirected_to root_path
click_on 'Sign In'
fill_in 'Email', with: user.email
fill_in 'Password', with: user.password
click_on 'Sign in'
expect(page).to have_content
end
end


end
9 changes: 5 additions & 4 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
require 'spec_helper'

describe User do
let(:user) { FactoryGirl.build(:user) }
let(:user) { FactoryGirl.build(:confirmed_user) }

context "checking invalidation" do
it "can create a new user" do

expect(user.valid?).to eq(true)
end

it "is has a name" do
expect(user.name).to eq('brian')
expect(user.errors[:name]).to be_empty
expect(user[:name]).to_not be_empty
end

it "is has a email" do
expect(user.email).to eq('me@me.com')
expect(user.errors[:email]).to be_empty
expect(user[:email]).to_not be_empty
end

it "is has a username" do
expect(user.username).to eq('brianllamar')
expect(user.errors[:username]).to be_empty
expect(user[:username]).to_not be_empty
end
end

Expand Down
5 changes: 3 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'rspec/rails'
require 'rspec/autorun'
require "factory_girl_rails"
require 'database_cleaner'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Expand Down Expand Up @@ -40,8 +41,8 @@
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"

# use restful paths in specs
config.include Rails.application.routes.url_helpers

# Removes the need for FactoryGirl
config.include FactoryGirl::Syntax::Methods
end

0 comments on commit 0681701

Please sign in to comment.