Ember camelize() vs javaScript camelize() - ember.js

I'm trying to camelize an extracted value from an ember view, and I was hoping to get the lower case camelized form of a string as is written here http://docs.emberjs.com/symbols/Ember.String.html#.camelize
However, what I'm getting back is the capitalized version of it (the extracted value started off as Capitalized).

Try this Ember.String.camelize("my lovely property") which gives you myLovelyProperty

I can confirm that My-Lovely-Property isn't converted to myLovelyProperty. Nor is MY-LOVELY-PROPERTY -- it leaves those "OVELY" "ROPERTY" caps alone too and yields MYLOVELYPROPERTY which certainly doesn't feel like camel case. I'm not sure if that behavior is intended or not, but it seems neither this case nor yours is covered by the test examples.
If you or anyone else believes strongly that such cases should be covered in some way, perhaps submit a github issue or PR? Otherwise, for the case you describe you can use an expression like str.charAt(0).toLowerCase() + str.substr(1).camelize().

Related

Saving cookies in Cypress without cy.session()

I am looking for some way how to save exact cookie in Cypress through whole test case.
Was using
Cypress.Cookies.defaults({ preserve: 'cookie_name' })
and
Cypress.Cookies.preserveOnce('cookie_name')
but this doesn't work anymore. And the new cy.session() is not working for me, because I use custom addresses per user and per new form.
Does anyone know of anything that works better than cy.session()?
The use pattern of cy.session() is a bit opaque, but since it replaces the older cookie config it probably can be made to work.
I have seen a note somewhere that session is likely to be revamped shortly.
Since Cypress.Cookies.preserveOnce('cookie_name') is deprecated but still available, maybe use that until session mark 2 comes along.

Viewstate Replacing error. [ViewStateException: Invalid viewstate. ]

Tried with JMeter: How to know why my regular expression extractor in JMeter is not extracting the data but still not able to replace my view-state, its throwing [ViewStateException: Invalid viewstate. ] error . Please check the attachment , an my script has not _EVENTVALIDATION .
enter image description hereViewstate
viwstate2
As i am observing from your attached image
You need to pass same `Reference name` as a value of __VIEWSTATE in Next request
First Cross verify, Is your correaltion is correct or not? (you can use debug sampler to check the correlation)
If yes, then first mistake is, you had given reference name as "VIEWSTATE" in below shown snapshot
But you are passing ${jsfViewState} in other snapshot, so correct it and pass same reference name i.e. ${VIEWSTATE}
It'll resolve your issue, if issue still persists then click on encode button beside Name-Value pair because sometimes there is some mismatch in encoding format between the response which we capture and the value which we have to pass
Don't be confused with ASP.NET ViewState and JSF Viewstate, they have similar nature but different underlying technologies and different parameter names
Given you correctly correlated the value, I believe you need to change __VIEWSTATE parameter name to javax.faces.ViewState and it should work.
See Testing a JSF Application with JMeter guide for a little bit more detailed explanation on the topic and How to debug your Apache JMeter script guide for some troubleshooting techniques.

Mongoid 4 finding embedded documents by ID

I have a project that is my first serious dive into Mongoid.
I saw a tip to use the following command:
Parent.where('childrens._id' => Moped::BSON::ObjectId(params[:id])).first
But this doesn't work. Error message was:
NameError: uninitialized constant Moped::BSON
I found that BSON is no longer included, so I added it to my Gemfile, as well as Moped. Then, I did another fix I found (placing Moped::BSON=BSON in application.rb).
This still didn't work, but the error changed to:
NoMethodError: undefined method `ObjectId' for BSON:Module
So I am assuming that this method got deprecated or something. Does anyone have any other tips?
Just to be clear, I am finding myself in the situation where I want to sort embedded documents using jquery-sortable. This requires me to update them in the database, but the serialize from that doesn't include the parent document in the hash. So I figured I'd try to get it on the back end using an ID from the embedded document. That is why I need it.
Thanks again for any help you can provide.
Try simply:
Parent.where('childrens._id' => params[:id]).first
I have solved the question though this won't be of much help to people in the future. The requirements have changed and now I am using human-readable strings as IDs to assist in friendly URLs and some other stuff.
Therefore, I don't have any issues with ObjectIds. Cortex's solution should (from what I have read) work for dealing with ObjectIds but I cannot verify it now.

Issues with raw_post_data decoding in Django

I have stumbled on a strange issue that I can't resolve:
In my Django app there is a method which gets hit by a POST from a java applet, which sends it a JSON object. Django method parses it like so:
req = json.loads(request.raw_post_data)
and based on the results returns a value. I haven't written this code, but yesterday I was sent to investigate an error triggered in this method. It was saying there was "ValueError: Expecting property name: line 1 column 1 (char 1)".
What I discovered is that my raw post data looks like this:
{#012#011"ImmutableMachineFactors": #012#011{#012#011#011"machineName": "lukka",#012#011#011"osName": "MacOS"}}
The type of it was string, however, my attempts to replace these weird characters with spaces or nothing failed. It would just ignore the sub() command. I know that raw_post_data returns a bytestring, but when I tried to convert it to a regular string using:
mystring.decode('utf-8')
it did add the u'' notation, but didn't remove those weird characters. Stranger still, in many cases (on my personal machine), Django would happily convert this kind of data into JSON, it only fails sometimes, which led me to believe that the JSON which triggered the error was malformed, but when I would strip out all the #011 and #012 characters, it parsed perfectly.
My questions are:
1) What are those crazy things? (#011, #012). I tried to google around, but these are very common things to find in a search, so I couldn't find anything relevant.
2) How can I turn this bytestring into a regular string so that I can replace those characters? Or is it the wring way to approach this problem?
Thanks!
Luka
This may be way too late to help, but since QueryDict instances (request.POST or request.DATA) are immutable, it's reasonable to expect that request.raw_post_data is also immutable. You'd have to make a copy before changing it.

Can you construct an xpath for an input element that will be case insensitive regarding the type being matched?

So this issue stems from Watir-Webdriver which uses the webdriver ruby bindings
The challenge to us is a situation where someone is testing against HTML where the web developer has specified an input element with the type of RADIO (in upper case). While uncommon that's valid HTML as far as I can tell.
When the user tries to work with the element via a water statement such as
browser.radio(:id => "RadioM").set
then the .radio method in watir-webdriver converts this selector to XPath -
//input[#type='radio' and #id='RadioM']
which of course ends up being case sensitive and thus webdriver won't find their element
Is there some way we could be converting this to an XPATH that would be case insensitive with regard to the #type value it's looking for, and still work with webdriver to locate/manipulate the element?
edit: An additional complication is that as I understand it webdriver tries to delegate to the browser's xpath engine and right now, none of the browser's support xpath2.0. So that would also seem to indicate we would have to order webdriver to handle all the xpath stuff internally, and I do not know if webdriver's implementation of xpath supports xpath2.0 either. (and if it does, what affect this would have on test performance etc)