2014-07-12 9 views
9
ruby: 2.0 
rails: 3.2.17 
rspec: 2.14.8 
Database: mysql 

rspec spec utilizzato per emettere solo i punti.Come ottenere rspec per non mostrare le query db e solo i punti con rails_12factor?

Stavo ricevendo un avviso di ritiro quando ho spinto a Heroku e recentemente ho aggiunto la gemma rails_12factor per aggirare il problema. Ora tuttavia ottengo questo output db dettagliato per ogni transazione quando si eseguono le specifiche localmente.
Questa è una grande opzione quando ne ho bisogno altrimenti è un sacco di output non necessari e di distrazione.

Quindi vorrei un'opzione che lo utilizzi per Heroku ma non localmente.

Nota questo è non indirizzato utilizzando il formattatore, ad es.

rspec spec -fd 

Inoltre, se c'è un errore, con questo livello di verbosità, l'errore Scrolls quasi sempre fuori dalla pagina corrente ...

09:50:39 durrantm Castle2012 /home/durrantm/Dropnot/_/rails_apps/linker 74093480_wire_up_verify_code 
$ rspec spec/models/link_spec.rb -fd 
Connecting to database specified by database.yml 
... 
Link 
    (0.2ms) BEGIN 
    (0.2ms) SAVEPOINT active_record_1 
    SQL (0.6ms) INSERT INTO `groups` (`created_at`, `group_description`, `group_name`, `updated_at`) VALUES ('2014-07-12 13:50:49', 'Various jQuery examples of common situa 
tions amnd solutions', 'jQuery Examples', '2014-07-12 13:50:49') 
    (0.2ms) RELEASE SAVEPOINT active_record_1 
    (0.2ms) SAVEPOINT active_record_1 
    Link Load (0.6ms) SELECT `links`.* FROM `links` WHERE (links.position IS NOT NULL) AND (1 = 1) ORDER BY links.position DESC LIMIT 1 
    SQL (0.4ms) INSERT INTO `links` (`alt_text`, `content_date`, `created_at`, `group_id`, `position`, `updated_at`, `url_address`, `verified_date`, `version_number`) VALUE 
S ('examples of common situations amnd solutions', NULL, '2014-07-12 13:50:49', 141, 1, '2014-07-12 13:50:49', 'http://test.com', NULL, NULL) 
    (0.1ms) RELEASE SAVEPOINT active_record_1 
    (68.4ms) ROLLBACK 
    should be valid 
    (0.2ms) BEGIN 
    (0.2ms) SAVEPOINT active_record_1 
    SQL (0.3ms) INSERT INTO `groups` (`created_at`, `group_description`, `group_name`, `updated_at`) VALUES ('2014-07-12 13:50:49', 'Various jQuery examples of common situa 
tions amnd solutions', 'jQuery Examples', '2014-07-12 13:50:49') 
    (0.1ms) RELEASE SAVEPOINT active_record_1 
    (0.2ms) SAVEPOINT active_record_1 
    Link Load (0.7ms) SELECT `links`.* FROM `links` WHERE (links.position IS NOT NULL) AND (1 = 1) ORDER BY links.position DESC LIMIT 1 
    SQL (0.5ms) INSERT INTO `links` (`alt_text`, `content_date`, `created_at`, `group_id`, `position`, `updated_at`, `url_address`, `verified_date`, `version_number`) VALUE 
S ('examples of common situations amnd solutions', NULL, '2014-07-12 13:50:49', 142, 1, '2014-07-12 13:50:49', 'http://test.com', NULL, NULL) 
    (0.2ms) RELEASE SAVEPOINT active_record_1 
    (67.6ms) ROLLBACK 
    should have attribute :group_id 
    (0.3ms) BEGIN 
    (0.2ms) SAVEPOINT active_record_1 
    SQL (0.4ms) INSERT INTO `groups` (`created_at`, `group_description`, `group_name`, `updated_at`) VALUES ('2014-07-12 13:50:49', 'Various jQuery examples of common situa 
tions amnd solutions', 'jQuery Examples', '2014-07-12 13:50:49') 
    (0.1ms) RELEASE SAVEPOINT active_record_1 
    (0.2ms) SAVEPOINT active_record_1 
    Link Load (0.5ms) SELECT `links`.* FROM `links` WHERE (links.position IS NOT NULL) AND (1 = 1) ORDER BY links.position DESC LIMIT 1 
    SQL (0.4ms) INSERT INTO `links` (`alt_text`, `content_date`, `created_at`, `group_id`, `position`, `updated_at`, `url_address`, `verified_date`, `version_number`) VALUE 
S ('examples of common situations amnd solutions', NULL, '2014-07-12 13:50:49', 143, 1, '2014-07-12 13:50:49', 'http://test.com', NULL, NULL) 
    (0.1ms) RELEASE SAVEPOINT active_record_1 
    (68.7ms) ROLLBACK 
    should have attribute :url_address 
... 
+0

non stai usando la gemma 'rails_12factor' per caso sei tu? – Anthony

+0

Sì, è così. Hmmm. Credo di aver aggiunto quella gemma per aggirare gli avvertimenti sulla deprecazione spingendo verso Heroku. Quindi ora non sono sicuro di cosa fare. Consentitemi di aggiornare la domanda per affermare che ho bisogno di una soluzione per affrontare entrambi. –

risposta

20

Abbiamo visto anche questo, è generato dal rails_12factor gemma e può essere surpressed, in genere solo fare in modo che gioiello è solo nel gruppo di produzione, in questo modo:

group :production do 
    gem 'rails_12factor' 
end 

una delle dipendenze di rails_12factor è un'altra gemma chiamata rails_stdout_logging che sta causando l'output che stai vedendo.

+0

+1 Sì questa è la soluzione che sto cercando di usare. –

+0

È anche possibile modificare il livello del registro in testing su ': warn'. https://github.com/heroku/rails_stdout_logging#set-log-level –

Problemi correlati