diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb new file mode 100644 index 00000000..cfd08f08 --- /dev/null +++ b/spec/controllers/user_controller_spec.rb @@ -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 diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 00000000..f932c4e7 --- /dev/null +++ b/spec/factories/users.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 00000000..dcc9df96 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe User, :type => :model do + # TODO: specs for user model +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4d1d4392..ecb15e3d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -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 diff --git a/spec/requests/user_request_spec.rb b/spec/requests/user_request_spec.rb new file mode 100644 index 00000000..21152b25 --- /dev/null +++ b/spec/requests/user_request_spec.rb @@ -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 diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb new file mode 100644 index 00000000..eec437fb --- /dev/null +++ b/spec/support/factory_girl.rb @@ -0,0 +1,3 @@ +RSpec.configure do |config| + config.include FactoryGirl::Syntax::Methods +end