...never create a new object in an implicit conversion method. This method should either return self or not be implemented at all. Obviously, this is the reason behind this recent...
To return non-HTML responses (like XLS spreadsheets), we usually use the respond_to do |format| format.xls do # send spreadsheet end end This is often, but not always the same...
...than calling other step definitions. Because you are using plain ruby, you can use return values, structured arguments (e.g. hash options), etc. I often have files like the session_steps.rb (below...
...offense for rule "space-before-blocks" [#180343876] Fix ESLint offense for rule "no-useless-return" [#180343876] Add ESLint without any offenses
...it will wait for any beforeunload to be handled before e.g. a page.refresh statement returns. That that this also applies to wrapped calls like accept_confirm { page.refresh }. Setting unhandled_prompt...
...order of test-writing and implementation is up to you. When you're done, return to writing the code. The specced thing now exists, so you can continue making that...
...function escapeHighASCII(string) { let unicodeEscape = (char) => "\\u" + char.charCodeAt(0).toString(16).padStart(4, '0') return string.replace(/[^\x00-\x7F]/g, unicodeEscape) } Escaping high ASCII in Ruby def escape_high_ascii(string...
...Yarn requires Node.js 4.0 or higher to be installed. Check if command -v "node" returns a path and you load NVM before Yarn. This could look like this:
...POST session/1230859ba100e7b2e5472cfb5bdf94c3/execute 2020-01-02 00:00:03 INFO Selenium >>> http://127.0.0.1:9538/session/1230859ba100e7b2e5472cfb5bdf94c3/execute | {"script":"return arguments[0].matches(':disabled, select:disabled *')","args":[{"ELEMENT...
Note: In case a string does not match the pattern, .match will return nil. With Ruby 2.4 the result of .match can be transformed to a Hash with...
'fish' => nil, 'birds' => '1' } ] end let(:csv) { generate_csv(csv_data) } # This will return a CSV with one header row and four data rows
var key = keyValuePair[0]; var value = keyValuePair[1]; pdfInfo[key] = decodeURI(value); } } return pdfInfo; } If you want to place repeated content outside the header or footer area, I...
...but includes the space character /[[:punct:]]/ Punctuation character /[[:space:]]/ Whitespace character ([[:blank:]], newline, carriage return, etc.) /[[:upper:]]/ Uppercase alphabetical /[[:xdigit:]]/ Digit allowed in a hexadecimal number (i.e., 0-9a...
...performance optimizations Removing an enum value that exists on records will make their getter return nil Neat features the generated instance methods, prefix/suffix options and scopes
...name is missing' end context 'when admin' do before { … } describe '#last_action' do it 'returns the last action performed by the user' it 'is nil for a new user'
...good habit to always end a composed matcher in true to ensure that it returns a truthy value. E.g. by using a condition as the last expression you may otherwise...
timer = Capybara::Helpers.timer(expire_in: seconds) loop do prev_size = size sleep 0.025 return res if prev_size == size break if timer.expired? end raise Capybara::WindowError, "Window size not...
an underlying Net::HTTP result, e.g. Net::HTTPUnprocessableEntity The called method will then return the return statement of the block. So this will just return the response object of...
...hash_including( id: 1, thread: {id: 1} ) ) end end The example will fail and returns a not very helpful error message: expected {:id => 1, :name => "Foo", :thread => {:id => 1, :title...
...to write [\s\S]or (.|\s) to match any character including line feeds, carriage returns, etc. There's a TC39 proposal that's stuck in Stage 1. While there is...
...to set the Sass options. Webpacker const sassLoaderConfig = environment.loaders.get('sass') const sassLoaderIndex = sassLoaderConfig.use.findIndex(config => { return config.loader === 'sass-loader' }) // Disable deprecation warnings inside dependencies sassLoaderConfig.use[sassLoaderIndex].options.sassOptions.quietDeps = true sassLoaderConfig.use[sassLoaderIndex].options.sassOptions.silenceDeprecations...
...where you can specify a lambda to adjust its verification response. Your callback must return either true or false and OpenSSL's verification result is the first callback block argument...
...the qualifier. Reads like "greedy without backtracking" – *+ and ++ try to match everything but immediately return if it doesn't succeed, i.e. /\d++/ matches 333 whereas /\d++3/ does not. (A...
...to shuffle an array randomly and a class that uses shuffle within the constructor. returnValue & returnValues it('shuffles the array', () => { spyOn(Random, 'shuffle').and.returnValue([3, 2, 1])
...If you have several new classes created in one test you could also use returnValues for any call of the method Random.shuffle. callFake If you are testing the class in...