mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 12:39:53 +01:00
added specs
This commit is contained in:
parent
aa1b5fab6f
commit
cae59cd5b4
6 changed files with 44 additions and 1 deletions
13
spec/controllers/user_controller_spec.rb
Normal file
13
spec/controllers/user_controller_spec.rb
Normal 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
8
spec/factories/users.rb
Normal 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
5
spec/models/user_spec.rb
Normal file
|
@ -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|
|
||||
# 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
|
||||
|
|
14
spec/requests/user_request_spec.rb
Normal file
14
spec/requests/user_request_spec.rb
Normal 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
|
3
spec/support/factory_girl.rb
Normal file
3
spec/support/factory_girl.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
RSpec.configure do |config|
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
end
|
Loading…
Reference in a new issue