diff --git a/Gemfile b/Gemfile index 2d3a56e59..f4df5a0d6 100644 --- a/Gemfile +++ b/Gemfile @@ -49,9 +49,11 @@ group :development do end group :development, :test do - #EPP client - gem 'epp', '~> 1.4.0' + # For cleaning db in feature and epp tests + gem 'database_cleaner', '~> 1.3.0' + # EPP client + gem 'epp', '~> 1.4.0' # Replacement for fixtures gem 'fabrication', '~> 2.11.3' diff --git a/Gemfile.lock b/Gemfile.lock index 3d3303e1c..5533c3a3b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,6 +41,7 @@ GEM execjs coffee-script-source (1.7.0) columnize (0.8.9) + database_cleaner (1.3.0) debugger-linecache (1.2.0) diff-lcs (1.2.5) epp (1.4.0) @@ -178,6 +179,7 @@ PLATFORMS DEPENDENCIES coffee-rails (~> 4.0.0) + database_cleaner (~> 1.3.0) epp (~> 1.4.0) fabrication (~> 2.11.3) faker (~> 1.3.0) diff --git a/README.md b/README.md index 62e7aa1c5..a53c96434 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ For development configuration, add: EPPEngine On EPPCommandRoot /proxy/command EPPSessionRoot /proxy/session - ProxyPass /proxy/ http://localhost:8080/epp/ + ProxyPass /proxy/ http://localhost:8989/epp/ EPPErrorRoot /cgi-bin/epp/error EPPAuthURI implicit @@ -95,11 +95,11 @@ For plain TCP EPP configuration, see below (may be useful for debugging purposes Try it out: -* Fire up your appserver (This setup is tested with Unicorn) +* Fire up your appserver on port 8989 (This setup is tested with Unicorn) * `cd $mod_epp` -* `./epptelnet.pl localhost 1701` +* `./epptelnet.pl localhost` -You should receive the greeting from the registry server. +You should receive the greeting from the registry server. Wait for the greeting message on the STD, then send EPP/TCP frame: ```xml @@ -112,7 +112,10 @@ Wait for the greeting message on the STD, then send EPP/TCP frame: ``` -* `rspec` to run tests +Because Apache can not call the same process where the rspec is running (worker is busy), another instance of the appserver must be initialized before running tests. + +* `unicorn -p 8989 -E test` +* `rspec` --- @@ -141,7 +144,7 @@ Add: ``` -For debugging purposes, standalone CGI scripts can be used: +For debugging purposes, standalone CGI scripts can be used: This needs a static greeting file, so you will have to make /var/www writable. ```apache diff --git a/config/environments/test.rb b/config/environments/test.rb index 053f5b66d..82ca38674 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -5,7 +5,7 @@ Rails.application.configure do # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true + config.cache_classes = false # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that diff --git a/spec/epp/session_spec.rb b/spec/epp/session_spec.rb index b00cb43a2..82a62919f 100644 --- a/spec/epp/session_spec.rb +++ b/spec/epp/session_spec.rb @@ -17,7 +17,6 @@ describe 'EPP Session', type: :epp do it 'logs in epp user' do response = Nokogiri::XML(server.send_request(read_body('login.xml'))) - result = response.css('epp response result').first expect(result[:code]).to eq('1000') diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 9274f2063..94f086758 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -25,7 +25,27 @@ RSpec.configure do |config| # 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 # instead of true. - config.use_transactional_fixtures = true + config.use_transactional_fixtures = false + + config.before(:suite) do + DatabaseCleaner.clean_with(:truncation) + end + + config.before(:each) do + DatabaseCleaner.strategy = :transaction + end + + config.before(:each, type: :epp) do + DatabaseCleaner.strategy = :truncation + end + + config.before(:each) do + DatabaseCleaner.start + end + + config.after(:each) do + DatabaseCleaner.clean + end # RSpec Rails can automatically mix in different behaviours to your tests # based on their file location, for example enabling you to call `get` and