added specs
This commit is contained in:
parent
aa1b5fab6f
commit
cae59cd5b4
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe User, :type => :model do
|
||||||
|
# TODO: specs for user model
|
||||||
|
end
|
|
@ -19,7 +19,7 @@ ActiveRecord::Migration.maintain_test_schema!
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
# 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
|
# 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
|
# examples within a transaction, remove the following line or assign false
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.include FactoryGirl::Syntax::Methods
|
||||||
|
end
|
Loading…
Reference in New Issue