Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1205 from mikz/integration-test
formtastic integration test
- Loading branch information
Showing
4 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ Gemfile.lock | |
doc/ | ||
tmp | ||
gemfiles/*.lock | ||
/dummy/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
gem 'formtastic', path: '..' | ||
gem 'bcrypt', '~> 3.1.7' | ||
gem 'rails-dom-testing', group: :test | ||
|
||
# to speed up travis install, reuse the bundle path | ||
def bundle_path | ||
File.expand_path ENV.fetch('BUNDLE_PATH', 'vendor/bundle'), ENV['TRAVIS_BUILD_DIR'] | ||
end | ||
|
||
if File.directory?(bundle_path) && bundle_install? | ||
def run_bundle | ||
bundle_command("install --jobs=3 --retry=3 --path=#{bundle_path}") | ||
end | ||
end | ||
|
||
in_root do | ||
ENV['BUNDLE_GEMFILE'] = File.expand_path('Gemfile') | ||
end | ||
|
||
formtastic = -> do | ||
generate(:scaffold, 'user name:string password_digest:string') | ||
generate('formtastic:install') | ||
generate('formtastic:form', 'user name password:password --force') | ||
|
||
rake('db:migrate') | ||
|
||
in_root do | ||
inject_into_file 'app/models/user.rb', " has_secure_password\n", after: "< ActiveRecord::Base\n" | ||
inject_into_file 'app/assets/stylesheets/application.css', " *= require formtastic\n", before: ' *= require_self' | ||
inject_into_file 'test/controllers/users_controller_test.rb', <<-RUBY, before: ' test "should get edit" do' | ||
test "should show form" do | ||
get :edit, id: @user | ||
assert_select "form" do | ||
assert_select 'li.input.string' do | ||
assert_select 'input#user_name[type=text]' | ||
end | ||
assert_select 'li.input.password' do | ||
assert_select 'input#user_password[type=password]' | ||
end | ||
assert_select 'fieldset.actions' do | ||
assert_select 'li.action.input_action' do | ||
assert_select 'input[type=submit]' | ||
end | ||
end | ||
end | ||
end | ||
RUBY | ||
end | ||
end | ||
|
||
if respond_to?(:after_bundle) # Rails >= 4.2 | ||
after_bundle(&formtastic) | ||
else # Rails 4.1 | ||
run_bundle | ||
formtastic.call | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
set -o verbose | ||
|
||
test_app=dummy | ||
|
||
rm -rf ${test_app} | ||
|
||
bundle exec rails new ${test_app} \ | ||
--template=$(dirname "$0")/integration-template.rb \ | ||
--skip-spring \ | ||
--skip-turbolinks | ||
|
||
cd ${test_app} && export BUNDLE_GEMFILE=Gemfile | ||
|
||
bundle exec rake test |