LazyInitializationException from object stored in the HTTP session - spring

I have a scenario in a Grails project where I am storing domain object in an HTTP session. This is arguably not a great practice, but I'm not in a position to change that at the moment.
The issue I'm encountering is that if I hit an unhandled exception, and then attempt to logout (authentication is using Spring Security) I will be unable to logout and will get another LazyInitialization exception (not even on the same collection as before.)
What I don't understand is what Spring Security is trying to do with these detached domain objects in the HTTP session.
If I look through the Grails docs, there are examples on how to reattach things to the Hibernate session: http://grails.org/doc/latest/ref/Domain%20Classes/attach.html. In this case though, I don't even want to reattach these objects. I'm done with them. It seems like spring security is looking in the HTTP session and trying to do something with those objects, but I'm not sure what, or how to fix it.
Full stack trace:
Line | Method
->> 1418 | writeOrdinaryObject in java.io.ObjectOutputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1177 | writeObject0 in ''
| 1547 | defaultWriteFields in ''
| 1508 | writeSerialData in ''
| 1431 | writeOrdinaryObject in ''
| 1177 | writeObject0 in ''
| 1547 | defaultWriteFields in ''
| 1508 | writeSerialData in ''
| 1431 | writeOrdinaryObject in ''
| 1177 | writeObject0 in ''
| 347 | writeObject . . . . in ''
| 1128 | writeObject in java.util.HashMap
| 988 | invokeWriteObject . in java.io.ObjectStreamClass
| 1495 | writeSerialData in java.io.ObjectOutputStream
| 1431 | writeOrdinaryObject in ''
| 1177 | writeObject0 in ''
| 1547 | defaultWriteFields in ''
| 1508 | writeSerialData in ''
| 1431 | writeOrdinaryObject in ''
| 1177 | writeObject0 in ''
| 1547 | defaultWriteFields in ''
| 1508 | writeSerialData in ''
| 1431 | writeOrdinaryObject in ''
| 1177 | writeObject0 in ''
| 1547 | defaultWriteFields in ''
| 1508 | writeSerialData in ''
| 1431 | writeOrdinaryObject in ''
| 1177 | writeObject0 in ''
| 347 | writeObject . . . . in ''
| 1129 | writeObject in java.util.HashMap
| 988 | invokeWriteObject . in java.io.ObjectStreamClass
| 1495 | writeSerialData in java.io.ObjectOutputStream
| 1431 | writeOrdinaryObject in ''
| 1177 | writeObject0 in ''
| 347 | writeObject . . . . in ''
| 74 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
| 1145 | runWorker . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . . in java.lang.Thread

Related

pywinauto how to click on a pane?

Dialog - 'sample' (L585, T187, R1341, B716)
['Dialog', 'Sample', 'Sample']
child_window(title="Sivielliance Suite", control_type="Window")
|
| Pane - '' (L588, T213, R1338, B713)
| ['Pane', 'Pane0', 'Pane1']
| |
| | Pane - '' (L588, T213, R844, B673)
| | ['Pane2']
| |
| | Pane - '' (L588, T675, R1338, B713)
| | ['Pane3']
| | |
| | | Pane - '' (L588, T693, R1093, B694)
| | | ['Pane4']
| | |
| | | Pane - '' (L1093, T681, R1333, B706)
| | | ['Pane5']
| | | |
| | | | Pane - '' (L1255, T681, R1331, B706)
| | | | ['Pane6']
| | | |
| | | | Pane - '' (L1175, T681, R1251, B706)
| | | | ['Pane7']
| | | |
| | | | Pane - '' (L1095, T681, R1171, B706)
| | | | ['Pane8']
| |
| | Pane - '' (L588, T673, R1338, B675)
| | ['Pane9']
| | |
| | | Pane - '' (L588, T673, R1338, B675)
| | | ['Pane10']
| |
| | Pane - '' (L844, T271, R1338, B673)
| | ['Pane11']
| | |
| | | Pane - '' (L844, T271, R1338, B673)
| | | ['Pane12']
| | | |
| | | | Image - '' (L852, T286, R1330, B305)
| | | | ['Image', 'Image0', 'Image1']
| |
| | Pane - '' (L844, T213, R1338, B271)
| | ['Pane13']
| | |
| | | Image - '' (L854, T231, R1043, B252)
| | | ['Image2']
|
| TitleBar - '' (L604, T190, R1338, B213)
| ['TitleBar']
| |
| | Menu - 'System' (L593, T195, R615, B217)
| | ['System', 'Menu', 'SystemMenu', 'System0', 'System1']
| | child_window(title="System", auto_id="MenuBar", control_type="MenuBar")
| | |
| | | MenuItem - 'System' (L593, T195, R615, B217)
| | | ['System2', 'MenuItem', 'SystemMenuItem']
| | | child_window(title="System", control_type="MenuItem")
| |
| | Button - 'Minimize' (L1199, T188, R1246, B213)
| | ['Button', 'MinimizeButton', 'Minimize', 'Button0', 'Button1']
| | child_window(title="Minimize", control_type="Button")
| |
| | Button - 'Maximize' (L1246, T188, R1292, B213)
| | ['Button2', 'MaximizeButton', 'Maximize']
| | child_window(title="Maximize", control_type="Button")
| |
| | Button - 'Close' (L1292, T188, R1339, B213)
| | ['CloseButton', 'Button3', 'Close']
| | child_window(title="Close", control_type="Button")
I am unable to click on any of the child panes. Is there any solution for this?
Control identifiers
app.dlg.child_window(control_type="Pane",found_index=0).app.dlg.child_window(control_type="Pane",found_index=2).app.dlg.child_window(control_type="Pane",found_index=0).app.dlg.child_window(control_type="Pane",found_index=0).app.dlg.child_window(control_type="Pane",found_index=0).app.dlg.child_window(control_type="Pane",found_index=2).app.dlg.child_window(control_type="Pane",found_index=0).app.dlg.child_window(control_type="Pane",found_index=0).click_input()

grails webflow notserializableexception

Grails upgrade from 1.3.7 to Grails 2.1.0.
Grails run-app executed. No errors.
Call to webflow action throws GrailsExceptionResolver error. States a grails webflow object isn’t serializable. I have navigated all classes to ensure all have ‘implements serializable’.
Error not identifying object not being serialized, so unable to identify if a class field should be made transient to be ignored by serializable runtime.
Full Stacktrace:
2016-12-20 09:51:25,750 [http-bio-80-exec-1] DEBUG services.RpgService - ************
| Error 2016-12-20 09:51:26,450 [http-bio-80-exec-1] ERROR errors.GrailsExceptionResolver - NotSerializableException occurred when processing request: [GET] /…/…/order
org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext. Stacktrace follows:
Message: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable
Line | Method
->> 384 | doFilterInternal in org.jsecurity.web.servlet.JsecurityFilter
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 183 | doFilter in org.jsecurity.web.servlet.OncePerRequestFilter
| 886 | runTask . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 662 | run . . . . . . in java.lang.Thread
Caused by NotSerializableException: org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext
->> 1164 | writeObject0 in java.io.ObjectOutputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1518 | defaultWriteFields in ''
| 1483 | writeSerialData in ''
| 1400 | writeOrdinaryObject in ''
| 1158 | writeObject0 . . in ''
| 1518 | defaultWriteFields in ''
| 1483 | writeSerialData in ''
| 1400 | writeOrdinaryObject in ''
| 1158 | writeObject0 . . in ''
| 330 | writeObject in ''
| 1001 | writeObject . . in java.util.HashMap
| 940 | invokeWriteObject in java.io.ObjectStreamClass
| 1469 | writeSerialData in java.io.ObjectOutputStream
| 1400 | writeOrdinaryObject in ''
| 1158 | writeObject0 . . in ''
| 1518 | defaultWriteFields in ''
Found the resolution.
My controller service was calling sessionFactory which also needed to be transient.
code change:
def sessionFactory => transient sessionFactory.
Did not need make any domain class variables transient directly.
fixed the issue.

mysql table unaligned in console output when using UTF8

I like to use mysql client. But when using UTF-8, the tables on the console are unaligned:
> set names utf8;
> [some query]
+--------+---------+---------------------------------+-----------------------------+----------+---------+-----------+-------+---------+-----------+
| RuleId | TaxonId | Note | NoteSci | MinCount | DayFrom | MonthFrom | DayTo | MonthTo | ExtraNote |
+--------+---------+---------------------------------+-----------------------------+----------+---------+-----------+-------+---------+-----------+
| 722 | 10090 | sedmihlásek malý | Hippolais caligata | 1 | 1 | 1 | 31 | 12 | NULL |
| 727 | 10059 | Anseranas semipalmata | husovec strakatý | 1 | 1 | 1 | 31 | 12 | NULL |
| 728 | 10062 | Cygnus atratus | labuť černá | 1 | 1 | 1 | 31 | 12 | NULL |
| 729 | 10094 | Anser cygnoides | husa labutí | 1 | 1 | 1 | 31 | 12 | NULL |
| 730 | 10063 | Tadorna cana | husice šedohlavá | 1 | 1 | 1 | 31 | 12 | NULL |
| 731 | 10031 | Cairina moschata f. domestica | pižmovka domácí | 20 | 1 | 1 | 31 | 12 | NULL |
| 732 | 10088 | Cairina scutulata | pižmovka bělokřídlá | 1 | 1 | 1 | 31 | 12 | NULL |
| 733 | 10087 | Anas sibilatrix | hvízdák chilský | 1 | 1 | 1 | 31 | 12 | NULL |
| 734 | 10077 | Anas platyrhynchos f. domestica | kachna domácí | 1000 | 1 | 1 | 31 | 12 | NULL |
| 735 | 10086 | Anas hottentota | čírka hottentotská | 1 | 1 | 1 | 31 | 12 | NULL |
|
This is apparently because mysql client will compute the widths of the columns using string length which doesn't take UTF-8 characters into account - so then there is exactly one space missing for each accented character (because these actually take two bytes).
Do you know possible workaround for this problem?
Run your mysql client with charset option:
mysql -uUSER -p DATABASE --default-character-set=utf8
(USER and DATABASE should be replaced with actual credentials data)

Apache Camel: Nested filters (filter ... filter ... end ...filter ... end ..end) in DSL (Groovy or Java)

we have some issues with the DSL for Camel Routes. It seems that it is not possible to translate the following XML Configuration into the Groovy (or JAVA) DSL
<route id="myroute" >
<from uri="fromURI" />
<filter>
<xpath>//entity[contains(#destinations, 'databasedestination')]</xpath>
<filter>
<xpath>//entity[#objectType = 'objectType']</xpath>
<camel:setHeader headerName="bodyTemp">
<simple>${body}</simple>
</camel:setHeader>
<filter>
<xpath>//entity[#command = 'add']</xpath>
<convertBodyTo type="com.foo.bar.Entity" />
<bean ref="handler" method="add" />
</filter>
<filter>
<xpath>//entity[#command = 'foo']</xpath>
<convertBodyTo type="com.foo.bar.Entity" />
<bean ref="handler" method="foo" />
</filter>
<filter>
<xpath>//entity[#command = 'bar']</xpath>
<convertBodyTo type="com.foo.bar.Entity" />
<bean ref="handler" method="bar" />
</filter>
<to uri="toURI" />
</filter>
</filter>
</route>
Wie tried to translate it inside a Groovy based RouteBuilder as follows:
from("fromURI")
.filter().xpath('//entity[contains(#destinations, \'databasedestination\')]')
.setHeader("bodyTemp", simple('${body}'))
.filter().xpath('//entity[#objectType = \'objectType\']')
.filter().xpath('//entity[#command = \'add\']')
.convertBodyTo(com.foo.bar.Entity)
.bean(handler, "add")
.end()
.filter().xpath('//entity[#command = \'foo\']')
.convertBodyTo(com.foo.bar.Entity)
.bean(handler, "foo")
.end()
.filter().xpath('//entity[#command = \'bar\']')
.convertBodyTo(com.foo.bar.Entity)
.bean(handler, "bar")
.end()
.to("toURI")
.end()
.end()
But that obviously doesn't work. We get a javax.xml.xpath.XPathExpressionException with the Message: Invalid xpath: //entity[#command = 'foo']
See the corresponding stacktrace as well.
->> 814 | doInEvaluateAs in org.apache.camel.builder.xml.XPathBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 697 | evaluateAs in ''
| 139 | matches . . . . . . in ''
| 47 | process in org.apache.camel.processor.FilterProcessor
| 73 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 99 | processNext in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process . . . . . . in ''
| 73 | process in org.apache.camel.management.InstrumentationProcessor
| 99 | processNext . . . . in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process in ''
| 91 | process . . . . . . in org.apache.camel.processor.interceptor.TraceInterceptor
| 73 | process in org.apache.camel.util.AsyncProcessorHelper
| 330 | processErrorHandler in org.apache.camel.processor.RedeliveryErrorHandler
| 220 | process in ''
| 45 | processNext . . . . in org.apache.camel.processor.RouteContextProcessor
| 90 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 303 | process . . . . . . in org.apache.camel.processor.interceptor.DefaultChannel
| 73 | process in org.apache.camel.util.AsyncProcessorHelper
| 117 | process . . . . . . in org.apache.camel.processor.Pipeline
| 80 | process in ''
| 45 | processNext . . . . in org.apache.camel.processor.RouteContextProcessor
| 90 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 150 | processAsync . . . in org.apache.camel.processor.UnitOfWorkProcessor
| 117 | process in ''
| 48 | processNext . . . . in org.apache.camel.processor.RouteInflightRepositoryProcessor
| 90 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 73 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 99 | processNext in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process . . . . . . in ''
| 73 | process in org.apache.camel.management.InstrumentationProcessor
| 99 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 86 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 105 | onMessage . . . . . in org.apache.camel.component.jms.EndpointMessageListener
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by XPathExpressionException: null
->> 200 | evaluate in com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 800 | doInEvaluateAs in org.apache.camel.builder.xml.XPathBuilder
| 697 | evaluateAs . . . . in ''
| 139 | matches in ''
| 47 | process . . . . . . in org.apache.camel.processor.FilterProcessor
| 73 | process in org.apache.camel.util.AsyncProcessorHelper
| 99 | processNext . . . . in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process in ''
| 73 | process . . . . . . in org.apache.camel.management.InstrumentationProcessor
| 99 | processNext in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process . . . . . . in ''
| 91 | process in org.apache.camel.processor.interceptor.TraceInterceptor
| 73 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 330 | processErrorHandler in org.apache.camel.processor.RedeliveryErrorHandler
| 220 | process . . . . . . in ''
| 45 | processNext in org.apache.camel.processor.RouteContextProcessor
| 90 | process . . . . . . in org.apache.camel.processor.DelegateAsyncProcessor
| 303 | process in org.apache.camel.processor.interceptor.DefaultChannel
| 73 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 117 | process in org.apache.camel.processor.Pipeline
| 80 | process . . . . . . in ''
| 45 | processNext in org.apache.camel.processor.RouteContextProcessor
| 90 | process . . . . . . in org.apache.camel.processor.DelegateAsyncProcessor
| 150 | processAsync in org.apache.camel.processor.UnitOfWorkProcessor
| 117 | process . . . . . . in ''
| 48 | processNext in org.apache.camel.processor.RouteInflightRepositoryProcessor
| 90 | process . . . . . . in org.apache.camel.processor.DelegateAsyncProcessor
| 73 | process in org.apache.camel.util.AsyncProcessorHelper
| 99 | processNext . . . . in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process in ''
| 73 | process . . . . . . in org.apache.camel.management.InstrumentationProcessor
| 99 | process in org.apache.camel.util.AsyncProcessorHelper
| 86 | process . . . . . . in org.apache.camel.processor.DelegateAsyncProcessor
| 105 | onMessage in org.apache.camel.component.jms.EndpointMessageListener
| 1110 | runWorker . . . . . in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . . . . in java.lang.Thread
Caused by TransformerException: Unable to evaluate expression using this context
->> 367 | execute in com.sun.org.apache.xpath.internal.XPath
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 129 | eval in com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl
| 105 | eval . . . . . . . in ''
| 187 | evaluate in ''
| 800 | doInEvaluateAs . . in org.apache.camel.builder.xml.XPathBuilder
| 697 | evaluateAs in ''
| 139 | matches . . . . . . in ''
| 47 | process in org.apache.camel.processor.FilterProcessor
| 73 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 99 | processNext in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process . . . . . . in ''
| 73 | process in org.apache.camel.management.InstrumentationProcessor
| 99 | processNext . . . . in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process in ''
| 91 | process . . . . . . in org.apache.camel.processor.interceptor.TraceInterceptor
| 73 | process in org.apache.camel.util.AsyncProcessorHelper
| 330 | processErrorHandler in org.apache.camel.processor.RedeliveryErrorHandler
| 220 | process in ''
| 45 | processNext . . . . in org.apache.camel.processor.RouteContextProcessor
| 90 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 303 | process . . . . . . in org.apache.camel.processor.interceptor.DefaultChannel
| 73 | process in org.apache.camel.util.AsyncProcessorHelper
| 117 | process . . . . . . in org.apache.camel.processor.Pipeline
| 80 | process in ''
| 45 | processNext . . . . in org.apache.camel.processor.RouteContextProcessor
| 90 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 150 | processAsync . . . in org.apache.camel.processor.UnitOfWorkProcessor
| 117 | process in ''
| 48 | processNext . . . . in org.apache.camel.processor.RouteInflightRepositoryProcessor
| 90 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 73 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 99 | processNext in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process . . . . . . in ''
| 73 | process in org.apache.camel.management.InstrumentationProcessor
| 99 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 86 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 105 | onMessage . . . . . in org.apache.camel.component.jms.EndpointMessageListener
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by RuntimeException: Unable to evaluate expression using this context
->> 266 | setRoot in com.sun.org.apache.xpath.internal.axes.NodeSequence
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 214 | execute in com.sun.org.apache.xpath.internal.axes.LocPathIterator
| 339 | execute . . . . . . in com.sun.org.apache.xpath.internal.XPath
| 129 | eval in com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl
| 105 | eval . . . . . . . in ''
| 187 | evaluate in ''
| 800 | doInEvaluateAs . . in org.apache.camel.builder.xml.XPathBuilder
| 697 | evaluateAs in ''
| 139 | matches . . . . . . in ''
| 47 | process in org.apache.camel.processor.FilterProcessor
| 73 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 99 | processNext in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process . . . . . . in ''
| 73 | process in org.apache.camel.management.InstrumentationProcessor
| 99 | processNext . . . . in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process in ''
| 91 | process . . . . . . in org.apache.camel.processor.interceptor.TraceInterceptor
| 73 | process in org.apache.camel.util.AsyncProcessorHelper
| 330 | processErrorHandler in org.apache.camel.processor.RedeliveryErrorHandler
| 220 | process in ''
| 45 | processNext . . . . in org.apache.camel.processor.RouteContextProcessor
| 90 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 303 | process . . . . . . in org.apache.camel.processor.interceptor.DefaultChannel
| 73 | process in org.apache.camel.util.AsyncProcessorHelper
| 117 | process . . . . . . in org.apache.camel.processor.Pipeline
| 80 | process in ''
| 45 | processNext . . . . in org.apache.camel.processor.RouteContextProcessor
| 90 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 150 | processAsync . . . in org.apache.camel.processor.UnitOfWorkProcessor
| 117 | process in ''
| 48 | processNext . . . . in org.apache.camel.processor.RouteInflightRepositoryProcessor
| 90 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 73 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 99 | processNext in org.apache.camel.processor.DelegateAsyncProcessor
| 90 | process . . . . . . in ''
| 73 | process in org.apache.camel.management.InstrumentationProcessor
| 99 | process . . . . . . in org.apache.camel.util.AsyncProcessorHelper
| 86 | process in org.apache.camel.processor.DelegateAsyncProcessor
| 105 | onMessage . . . . . in org.apache.camel.component.jms.EndpointMessageListener
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Thank you for any help
Markus
Your code seems to be more fitting for a Content Based Router, making use of the choice EIP.
Are you able to make use of a choice statement instead? http://camel.apache.org/content-based-router.html

Ruby on Rails: Rake: rake stats didn't add my field to the correct value?

Before my rake stats modification
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 5037 | 3936 | 31 | 292 | 9 | 11 |
| Helpers | 150 | 128 | 0 | 17 | 0 | 5 |
| Models | 1523 | 1166 | 42 | 123 | 2 | 7 |
| Libraries | 633 | 415 | 4 | 65 | 16 | 4 |
| Functional tests | 289 | 228 | 13 | 0 | 0 | 0 |
| Unit tests | 560 | 389 | 30 | 0 | 0 | 0 |
| Model specs | 1085 | 904 | 0 | 3 | 0 | 299 |
| View specs | 88 | 75 | 0 | 0 | 0 | 0 |
| Controller specs | 468 | 388 | 0 | 2 | 0 | 192 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total | 9833 | 7629 | 120 | 502 | 4 | 13 |
+----------------------+-------+-------+---------+---------+-----+-------+
Code LOC: 5645 Test LOC: 1984 Code to Test Ratio: 1:0.4
now, when I add:
#Factories
::STATS_DIRECTORIES << %w(Factories\ specs test/factories) if File.exist?('test/factories')
::CodeStatistics::TEST_TYPES << "Factory specs" if File.exist?('test/factories')
around line 120, it should increase test LOC, right?
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 5037 | 3936 | 31 | 292 | 9 | 11 |
| Helpers | 150 | 128 | 0 | 17 | 0 | 5 |
| Models | 1523 | 1166 | 42 | 123 | 2 | 7 |
| Libraries | 633 | 415 | 4 | 65 | 16 | 4 |
| Functional tests | 289 | 228 | 13 | 0 | 0 | 0 |
| Unit tests | 560 | 389 | 30 | 0 | 0 | 0 |
| Model specs | 1085 | 904 | 0 | 3 | 0 | 299 |
| View specs | 88 | 75 | 0 | 0 | 0 | 0 |
| Controller specs | 468 | 388 | 0 | 2 | 0 | 192 |
| Factories specs | 144 | 119 | 0 | 0 | 0 | 0 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total | 9977 | 7748 | 120 | 502 | 4 | 13 |
+----------------------+-------+-------+---------+---------+-----+-------+
Code LOC: 5764 Test LOC: 1984 Code to Test Ratio: 1:0.3
Instead of adding tho 144 lines from factories to test LOC, it adds them to code LOC =\
How do I get the line count to be in Test LOC?
You're adding something called "Factories specs" (plural) to the STATS_DIRECTORIES array, but you call it "Factory specs" (singular) when you add it to TEST_TYPES array -- so when rake:stat hits your test/factories folder, it looks for "Factories specs" in TEST_TYPES, doesn't find it, and assumes it's code, not tests. You need to call it the same thing in both places:
::STATS_DIRECTORIES << %w(Factory\ specs test/factories) if File.exist?('test/factories')
::CodeStatistics::TEST_TYPES << "Factory specs" if File.exist?('test/factories')

Resources