diff --git a/README.md b/README.md index d6ae1848..c2efebee 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,16 @@ Add this line to your application's Gemfile: gem 'reform-rails' ``` +## Generators + +This gem also have support of rails generators: + +``` +bin/rails g form Test property1 property2 +``` + +It will generate TestForm in `app/forms` dir. + ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). - diff --git a/lib/rails/generators/form/form_generator.rb b/lib/rails/generators/form/form_generator.rb new file mode 100644 index 00000000..9e2b0dac --- /dev/null +++ b/lib/rails/generators/form/form_generator.rb @@ -0,0 +1,20 @@ +module Rails + module Generators + class FormGenerator < Rails::Generators::NamedBase + source_root File.expand_path('../templates', __FILE__) + + check_class_collision suffix: 'Form' + + argument :properties, + type: :array, + default: [], + banner: 'property property2' + + def create_form_file + template 'form.rb.erb', File.join('app/forms', class_path, "#{file_name}_form.rb") + end + + hook_for :test_framework + end + end +end diff --git a/lib/rails/generators/form/templates/form.rb.erb b/lib/rails/generators/form/templates/form.rb.erb new file mode 100644 index 00000000..020c8cda --- /dev/null +++ b/lib/rails/generators/form/templates/form.rb.erb @@ -0,0 +1,5 @@ +class <%= class_name %>Form < Reform::Form +<% properties.each do |property| -%> + property :<%= property %> +<% end -%> +end diff --git a/reform-rails.gemspec b/reform-rails.gemspec index 0d4a9462..d49a1598 100644 --- a/reform-rails.gemspec +++ b/reform-rails.gemspec @@ -24,5 +24,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rails" spec.add_development_dependency "bundler", "~> 1.10" spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "sqlite3" spec.add_development_dependency "minitest" end diff --git a/test/form_generator_test.rb b/test/form_generator_test.rb new file mode 100644 index 00000000..9e1e6119 --- /dev/null +++ b/test/form_generator_test.rb @@ -0,0 +1,27 @@ +require 'test_helper' +require 'rails/generators/form/form_generator' +describe Rails::Generators::FormGenerator do + let(:arguments) { ['test'] } + let(:content) { File.read("./tmp/generators/app/forms/#{arguments[0]}_form.rb") } + + before do + Rails::Generators.invoke('form', arguments, destination_root: './tmp/generators') + end + + after do + FileUtils.rm_rf './tmp/generators' + end + + it 'generates form' do + content.must_match /^class TestForm < Reform::Form$/ + end + + describe 'when properties are present' do + let(:arguments) { ['second_test', 'username', 'password'] } + + it 'generates form with properties' do + content.must_match /^ property :username$/ + content.must_match /^ property :password$/ + end + end +end diff --git a/test/rails-app/config/application.rb b/test/rails-app/config/application.rb index beaa8fbb..77e10250 100644 --- a/test/rails-app/config/application.rb +++ b/test/rails-app/config/application.rb @@ -1,8 +1,6 @@ require File.expand_path('../boot', __FILE__) -require "active_model/railtie" -require "action_controller/railtie" -require "action_view/railtie" +require 'rails/all' Bundler.require @@ -17,4 +15,4 @@ class Application < Rails::Application end end -#require "reform/rails" # FIXME: this has to happen automatically in the rake test_rails run. \ No newline at end of file +#require "reform/rails" # FIXME: this has to happen automatically in the rake test_rails run. diff --git a/test/rails-app/config/environments/test.rb b/test/rails-app/config/environments/test.rb index d10f8958..c4cc43a1 100644 --- a/test/rails-app/config/environments/test.rb +++ b/test/rails-app/config/environments/test.rb @@ -21,6 +21,9 @@ config.action_controller.allow_forgery_protection = false config.secret_key_base = "yo" + config.eager_load = 'false' + config.active_support.test_order = :random + # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. diff --git a/test/rails-app/log/development.log b/test/rails-app/log/development.log deleted file mode 100644 index a5c1d4df..00000000 --- a/test/rails-app/log/development.log +++ /dev/null @@ -1,600 +0,0 @@ -------------------- -RailsTest: test_bla -------------------- -------------------- -RailsTest: test_bla -------------------- -------------------- -RailsTest: test_bla -------------------- -------------------- -RailsTest: test_bla -------------------- -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML - Rendered text template (0.1ms) -Completed 200 OK in 39ms (Views: 37.2ms) -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML -Completed 500 Internal Server Error in 1ms -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML - Rendered text template (0.0ms) -Completed 200 OK in 25ms (Views: 5.1ms) -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML - Rendered text template (0.0ms) -Completed 200 OK in 62ms (Views: 27.7ms) -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML - Rendered text template (0.0ms) -Completed 200 OK in 22ms (Views: 4.7ms) -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML - Rendered text template (0.0ms) -Completed 200 OK in 121ms (Views: 64.6ms) ------------------------------ -RailsTest: test_rendering_1-n ------------------------------ -Processing by MusicianController#album as HTML -Completed 500 Internal Server Error in 112ms ---------------------- -HasManyTest: test_bla ---------------------- -------------------------------- -HasManyTest: test_rendering_1-n -------------------------------- -Processing by AlbumController#new as HTML -Completed 500 Internal Server Error in 78ms -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML -Completed 200 OK in 16ms (Views: 1.3ms) ------------------------------ -RailsTest: test_rendering_1-n ------------------------------ -Processing by MusicianController#album_new as HTML -Completed 500 Internal Server Error in 1ms ---------------------- -HasManyTest: test_bla ---------------------- -------------------------------- -HasManyTest: test_rendering_1-n -------------------------------- -Processing by AlbumController#new as HTML -Completed 500 Internal Server Error in 61ms -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML -Completed 200 OK in 14ms (Views: 1.3ms) ------------------------------ -RailsTest: test_rendering_1-n ------------------------------ -Processing by MusicianController#album_new as HTML -Completed 500 Internal Server Error in 1ms ---------------------- -HasManyTest: test_bla ---------------------- -------------------------------- -HasManyTest: test_rendering_1-n -------------------------------- -Processing by AlbumController#new as HTML -Completed 500 Internal Server Error in 39ms -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML -Completed 200 OK in 46ms (Views: 1.5ms) ------------------------------ -RailsTest: test_rendering_1-n ------------------------------ -Processing by MusicianController#album_new as HTML -Completed 500 Internal Server Error in 3ms ---------------------- -HasManyTest: test_bla ---------------------- -------------------------------- -HasManyTest: test_rendering_1-n -------------------------------- -Processing by AlbumController#new as HTML -Completed 500 Internal Server Error in 36ms -------------------- -RailsTest: test_bla -------------------- -Processing by MusicianController#index as HTML -Completed 200 OK in 15ms (Views: 1.4ms) ------------------------------ -RailsTest: test_rendering_1-n ------------------------------ -Processing by MusicianController#album_new as HTML -Completed 500 Internal Server Error in 1ms -------------------------------- -HasManyTest: test_rendering_1-n -------------------------------- -Processing by AlbumController#new as HTML -Completed 500 Internal Server Error in 35ms -------------------------------- -HasManyTest: test_rendering_1-n -------------------------------- -Processing by AlbumController#new as HTML -Completed 500 Internal Server Error in 36ms -------------------------------- -HasManyTest: test_rendering_1-n -------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.haml (22.0ms) -Completed 200 OK in 60ms (Views: 27.4ms) -------------------------------- -HasManyTest: test_rendering_1-n -------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.haml (21.7ms) -Completed 200 OK in 143ms (Views: 29.8ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.haml (21.3ms) -Completed 200 OK in 104ms (Views: 28.6ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.haml (4.0ms) -Completed 500 Internal Server Error in 182ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (31.9ms) -Completed 500 Internal Server Error in 110ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 1ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 4ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 5ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 73ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 73ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 77ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (11.0ms) -Completed 500 Internal Server Error in 113ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (72.6ms) -Completed 500 Internal Server Error in 173ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (16.3ms) -Completed 200 OK in 120ms (Views: 41.9ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (95.7ms) -Completed 200 OK in 537ms (Views: 152.4ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (20.0ms) -Completed 200 OK in 153ms (Views: 50.8ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (18.0ms) -Completed 200 OK in 121ms (Views: 43.6ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (17.5ms) -Completed 200 OK in 122ms (Views: 43.4ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (16.4ms) -Completed 200 OK in 120ms (Views: 41.1ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (17.2ms) -Completed 200 OK in 121ms (Views: 42.6ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (17.2ms) -Completed 200 OK in 129ms (Views: 50.0ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (17.2ms) -Completed 200 OK in 125ms (Views: 42.5ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 21ms (Views: 9.0ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (17.6ms) -Completed 200 OK in 123ms (Views: 43.1ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 24ms (Views: 9.3ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (16.3ms) -Completed 200 OK in 126ms (Views: 41.4ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 21ms (Views: 9.0ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (16.3ms) -Completed 200 OK in 120ms (Views: 40.8ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 19ms (Views: 8.9ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (16.4ms) -Completed 200 OK in 127ms (Views: 47.7ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 19ms (Views: 8.8ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (16.6ms) -Completed 200 OK in 122ms (Views: 41.7ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 20ms (Views: 9.0ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (98.2ms) -Completed 200 OK in 441ms (Views: 188.0ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 20ms (Views: 9.1ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (76.0ms) -Completed 200 OK in 314ms (Views: 144.4ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 45ms (Views: 16.1ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (21.9ms) -Completed 200 OK in 70ms (Views: 26.7ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 43ms (Views: 15.3ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (87.1ms) -Completed 200 OK in 534ms (Views: 155.3ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 44ms (Views: 14.8ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (46.2ms) -Completed 200 OK in 94ms (Views: 51.2ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 41ms (Views: 14.4ms) ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 34ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 2ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 35ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 2ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 35ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 2ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 41ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 3ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 36ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 2ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 36ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 2ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 35ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 3ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 36ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 2ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 38ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 2ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 35ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 2ms ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 34ms --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 2ms -  (0.9ms) begin transaction ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 8ms -  (0.2ms) rollback transaction -  (0.1ms) begin transaction --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 0ms -  (0.1ms) rollback transaction -  (0.3ms) begin transaction ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 8ms -  (0.1ms) rollback transaction -  (0.1ms) begin transaction --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 0ms -  (0.1ms) rollback transaction -  (0.3ms) begin transaction ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 8ms -  (0.1ms) rollback transaction -  (0.1ms) begin transaction --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 1ms -  (0.2ms) rollback transaction -  (0.3ms) begin transaction ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 8ms -  (0.1ms) rollback transaction -  (0.1ms) begin transaction --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 0ms -  (0.1ms) rollback transaction -  (0.4ms) begin transaction ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 9ms -  (0.2ms) rollback transaction -  (0.1ms) begin transaction --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 1ms -  (0.1ms) rollback transaction -  (0.4ms) begin transaction ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML -Completed 500 Internal Server Error in 12ms -  (0.1ms) rollback transaction -  (0.2ms) begin transaction --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 500 Internal Server Error in 0ms -  (0.1ms) rollback transaction diff --git a/test/rails-app/log/production.log b/test/rails-app/log/production.log deleted file mode 100644 index e69de29b..00000000 diff --git a/test/rails-app/log/server.log b/test/rails-app/log/server.log deleted file mode 100644 index e69de29b..00000000 diff --git a/test/rails-app/log/test.log b/test/rails-app/log/test.log index e83a8720..e69de29b 100644 --- a/test/rails-app/log/test.log +++ b/test/rails-app/log/test.log @@ -1,12 +0,0 @@ ------------------------------------------------- -HasOneAndHasManyTest: test_rendering_1-1_and_1-n ------------------------------------------------- -Processing by AlbumsController#new as HTML - Rendered albums/new.html.erb (48.3ms) -Completed 200 OK in 86ms (Views: 50.1ms) --------------------------------------------------- -HasOneAndHasManyTest: test_submitting_invalid_form --------------------------------------------------- -Processing by AlbumsController#create as HTML - Parameters: {"album"=>{"title"=>"Rio", "songs_attributes"=>{"0"=>{"name"=>""}, "1"=>{"name"=>""}}}, "commit"=>"Create Album"} -Completed 200 OK in 41ms (Views: 13.5ms) diff --git a/test/reform/rails_test.rb b/test/reform/rails_test.rb deleted file mode 100644 index ac5dcc7b..00000000 --- a/test/reform/rails_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'test_helper' - -class Reform::RailsTest < Minitest::Test - def test_that_it_has_a_version_number - refute_nil ::Reform::Rails::VERSION - end - - def test_it_does_something_useful - assert false - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb index 7458c7a4..bb4788ff 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,10 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) +ENV["RAILS_ENV"] = "test" + require 'reform/rails' require 'minitest/autorun' -require "rails-app/config/environment" \ No newline at end of file +require "rails-app/config/environment" +require "rails/test_help" +require 'minitest/spec' diff --git a/test/uniqueness_validator_test.rb b/test/uniqueness_validator_test.rb deleted file mode 100644 index 87c9bfad..00000000 --- a/test/uniqueness_validator_test.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "test_helper" - -class FormWithLeakyUniquenessValidation < Reform::Form - property :email - validates :email, uniqueness: true -end \ No newline at end of file