added specs

This commit is contained in:
nilsding 2014-11-14 20:45:30 +01:00
parent aa1b5fab6f
commit cae59cd5b4
6 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,13 @@
require 'rails_helper'
RSpec.describe UserController, :type => :controller do
before do
@user = create(:user)
end
it 'responds successfully with a HTTP 200 status code' do
get :show, username: @user.screen_name, page: 1
expect(response).to be_success
expect(response).to have_http_status(200)
end
end

8
spec/factories/users.rb Normal file
View File

@ -0,0 +1,8 @@
FactoryGirl.define do
factory :user do |u|
u.screen_name { Faker::Internet.user_name 0..16, %w(_) }
u.email { Faker::Internet.email }
u.password { Faker::Internet.password }
u.display_name { Faker::Name.name }
end
end

5
spec/models/user_spec.rb Normal file
View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe User, :type => :model do
# TODO: specs for user model
end

View File

@ -19,7 +19,7 @@ ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false

View File

@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe UserController, :type => :request do
before do
# we need at least 2 users to test meaningfully
@user1 = create(:user)
@user2 = create(:user)
end
it 'shows the user page' do
get "/@#{@user1.screen_name}"
assert_select "h3.text-muted", :text => @user1.screen_name
end
end

View File

@ -0,0 +1,3 @@
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end