Skip to content

Commit

Permalink
Refactored the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaevee committed Mar 23, 2018
1 parent 4dfe6a1 commit 86da0c3
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class InstallGeneratorTest < Rails::Generators::TestCase
let(:namespace_path) { user_class.underscore }
let(:table_name) { user_class.pluralize.underscore.gsub("/","_") }

describe 'default values, clean install' do
describe 'user model with namespace, clean install' do
setup :prepare_destination

before do
run_generator %W(#{user_class} auth)
end

test 'user model is created, concern is included' do
test 'user model (with namespace) is created, concern is included' do
assert_file "app/models/#{namespace_path}.rb" do |model|
assert_match(/include DeviseTokenAuth::Concerns::User/, model)
end
Expand All @@ -29,11 +29,11 @@ class InstallGeneratorTest < Rails::Generators::TestCase
assert_file 'config/initializers/devise_token_auth.rb'
end

test 'migration is created' do
test 'migration is created for user model with namespace' do
assert_migration "db/migrate/devise_token_auth_create_#{table_name}.rb"
end

test 'migration file contains rails version' do
test 'migration file for user model with namespace contains rails version' do
if Rails::VERSION::MAJOR >= 5
assert_migration "db/migrate/devise_token_auth_create_#{table_name}.rb", /#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}/
else
Expand Down Expand Up @@ -112,7 +112,7 @@ def whatever
run_generator %W(#{user_class} auth)
end

test 'route method is appended to routes file' do
test 'route method for user model with namespace is appended to routes file' do
assert_file 'config/routes.rb' do |routes|
assert_match(/mount_devise_token_auth_for '#{user_class}', at: 'auth'/, routes)
end
Expand Down

0 comments on commit 86da0c3

Please sign in to comment.