...seems also to have problems with zeitwerk, since the create statement just didn't return. Pry (binding.pry) worked without problems for me. Note: In case you are using pry-byebug...
...use .to_json instead of .iso8601 to use the build-in eq matcher: it 'returns the created at attribute of a user' do get '/users/1' expect(JSON.parse(response.body)['created_at...
The Angular 1.2 way: # By default, angular returns undefined for invalid attributes which removes # the value from the form field's ngModel (which means it's not sent to the...
...not be overwritten). # # This directive makes sure that form fields with an invalid value return an # empty string instead of undefined. for elementType in ['input', 'textarea', 'select'] @app.directive elementType, ->
...to get to a pagination page that does not exist), the database will not return a record and so you will not get the count. To work around this, I...
...of the weekday in Ruby as defined by ISO 8601, use Date#cwday, which returns values in 1..7 (mind the range difference to Date#wday). The first week of...
...the calendar week in Ruby as defined by ISO 8601, use Date#cweek, which returns values in 1..53 USA and Canada Not defined in a standard. Weeks start on...
"more": true } } Basic ajax options $('#mySelect2').select2({ ajax: { url: , data: function (params) { return { query: params.term, page: params.page || 1 } } processResults: function (data, params) { return data }, } }); Further reading: https://select2.org/data-sources/ajax
...both its group and its group_id: user = User.find(1) user.group = Group.find(3) user.group # returns # user.group_id = 4 user.group_id # returns 4 user.save After the save, the change to group...
...id will be lost: user.group # returns # user.group_id # returns...
The class should cache its results so subsequent calls for the same URLs return the HTML size instantly, without making an additional HTTP request. Write two versions of WebsiteSizer...
...The AJAX call is asynchronously and we don't have control over when it returns (and hence when it calls the callback function). Here is a test that does all...
We're using jasmine-ajax to mock access to the network. jasmine.Ajax.requests.mostRecent() returns the most recent AJAX request, which we can inspect for its parameters and payload. We...
...the same job. If you configure one job to use both keywords, the linter returns a key may not be used with rules error. GitLab 12.3 introduced rules. You can...
...to die for this code: function effectiveDeviceWidth() { var deviceWidth = window.orientation == 0 ? window.screen.width : window.screen.height; // iOS returns available pixels, Android returns pixels / pixel ratio // http://www.quirksmode.org/blog/archives/2012/07/more_about_devi.html if (navigator.userAgent.indexOf('Android') >= 0 && window.devicePixelRatio...
...deviceWidth = deviceWidth / window.devicePixelRatio; } return deviceWidth...
...instance to fill in text. Ensure everything is loaded with patiently do page.execute_script("return isCkeditorLoaded('#{selector}');").should be_true end Example The fill in text snippet for Cucumber:
...I fill in the "([^\"]+)" WYSIWYG editor with:$/ do |selector, html| patiently do page.execute_script("return isCkeditorLoaded('#{selector}');").should be_true end html.gsub!(/\n+/, "") # otherwise: unterminated string literal (Selenium::WebDriver::Error...
...you are using Coffeescript, it is likely to be the culprit. Since Coffeescript always returns the value of the last expression, it may return DOM nodes: # coffeescript scope.focus = -> element.focus()
...scope.focus = function() { return element.focus(); // wheee } If you e.g. use this function like this, the error will be raised:
Solution By adding an explicit return value (e.g. return false), you can...
...useful methods: URLSearchParams.append() - appends a query parameter URLSearchParams.delete() - deletes the specified query parameter URLSearchParams.get() - returns the value of the specified query parameter URLSearchParams.has() - checks if specified query parameter exists URLSearchParams.set...
...Element attribute" To access virtually anything, create a "Custom Javascript" variable. Define a function() { return ...; } that returns whatever you need. You can reference other GTM variables with {{ }}.
Previous versions of Consul exhibited strange behavior when querying a power that returns nil. Consul 0.4.2+ behaves as expected: power.notes # => returns nil power.notes? # => returns false power.notes! # => raises Consul::Powerless
...Note.last) # => returns false power.note!(Note.last) # => raises Consul::Powerless
...Sass function is computing a result that is neither assigned to a variable nor returned. Keep in mind that all functions in Sass return something, Sass does not mutate objects...
...If you don't speak CoffeeScript, take this JavaScript: this.app.decorator('$httpBackend', ['$delegate', function($delegate) { return function() { var headers = arguments[4]; var contentType = (headers != null ? headers['X-Force-Content-Type'] : void...
...if (contentType != null && headers['Content-Type'] == null) { headers['Content-Type'] = contentType; } return $delegate.apply(null, arguments...
...get: () => value, set: (newValue) => value = newValue } delete newDescriptor.value delete newDescriptor.writable Object.defineProperty(obj, prop, newDescriptor) return spyOnProperty(obj, prop, accessType...
You can easily have a JavaScript hash/object that returns a default value for unset keys/properties -- as long as you need to support only recent browsers. The key are JavaScript proxies...
...getter method. They work like this: var hash = new Proxy({}, { get: function(object, property) { return object.hasOwnProperty(property) ? object[property] : 'hello'; } }); When you set a key, you can read its value...
should include the model and tag if the tool has a tag should return the model if the tool has no tag .search should find tools by model and...
...attr_writer :browser_died def scenario_started self.browser_died = false end def scenario_ended return unless session.driver.is_a?(::Capybara::Selenium::Driver) self.driver_scenario_count += 1 if !browser_died? && driver_scenario...
...legacy code. For new code, always use capture3. %x{ } or backticks – quick and easy Returns the standard output of running the given command in a subshell. This is an alias...
...exec, but executes the given command in a subshell. Your script will go on. Returns: true if the command gives zero exit status false for non zero exit status
...image_tag), Rails will compile your entire assets within its process before that helper returns. This will cause your helper to freeze for many seconds. Since Webpack needs to boot...