...you-type box to filter the list by query: +-----------------------------------------+ | MOVIEDB | +--------------------+--------------------+ | | | | MOVIES | MOVIES | | [ Search… ] | [ Search… ] | | | | | - Foo movie | - Foo movie | | - Bar movie | - Bar movie | | - Baz movie | - Baz movie | | | | +--------------------+--------------------+ The search box above...
...never affect the other pane. So this state should be possible: +-----------------------------------------+ | MOVIEDB | +--------------------+--------------------+ | | | | MOVIES | MOVIES | | [ Foo ] | [ Ba ] | | | | | - Foo movie | - Bar movie | | | - Baz movie | | | | | | | +--------------------+--------------------+ Did your existing JavaScript already behave that way...
...Integer() defined on Kernel, that typecasts everything into an Integer. Integer("2") # 2 Integer("foo") # Invalid value for Integer() (ArgumentError) Integer(nil) # Can't convert nil to Integer (TypeError)
...This is very similar but not identical to to_i: "2".to_i # 2 "foo".to_i # 0 nil.to_i # 0 [].to_i # undefined method 'to_i' for an instance...
...you mention them in a module and the following code works without any problems: foo(); import { foo } from 'my_module'; Footgun example When you're not aware of import hoisting...
expect(subject).to eq(expected_string) end end describe 'some string' do subject { 'foo' } it_behaves_like 'string equaling another string', 'foo' end RSpec 1 Use it_should_act...
...equal to another string' do subject.should == string end end describe 'some string' do subject { 'foo' } it_should_act_like 'string equaling another string', :string => 'foo' end If you call it...
...That said, please don't do something like this: Factory(:document) do |document| document.category { ['foo', 'bar', 'baz'].sample } end Instead do this: Factory(:document) do |document| document.category 'foo' end
...phone and email attribute: book = Addressbook.parse do contact 'Henning Koch' do phone '12345' email 'foo@bar.de' end contact 'Tobias Kraze' do phone '67890' email 'bam@baz.de' end end book.find('Henning Koch') # => { :phone...
...email => 'foo@bar.de' } book.find('Tobias Kraze') # => { :phone => '67890', :email => 'bam@baz.de' } Now change Addressbook so contacts can be accessed by their underscored names: book.henning_koch # => { :phone => '12345', :email => 'foo@bar.de' } book.tobias_kraze # => { :phone...
...offer an API like this: contact = Contact.new(first_name: 'Anna', last_name: 'Muster', street: 'Foo Avenue 77') contact.first_name # => 'Anna' contact.last_name # => 'Muster' A Contact object should be able to...
...list of contacts in memory: addresses = AddressBook.new addresses.add Contact.new(first_name: 'Frederik', last_name: 'Foo') addresses.add Contact.new(first_name: 'Berta', last_name: 'Beispiel', phone: '556677') addresses.add Contact.new(first_name: 'Anna...
...apply to class methods defined on self This does not make anything private: class Foo private def self.foo 'foo' end end You need to use private_class_method instead:
def self.foo 'foo' end private_class_method :foo end "private" does not apply to define_method This does not make anything private: class Foo private define_method :foo do...
...from a controller, it won't work by default. Take this controller action: class FoosController < ApplicationController def download file = Tempfile.new('foo') file.puts 'foo' file.close send_file file.path end end
...is to save the tempfile in your project directory's tmp instead: file = Tempfile.new('foo', 'tmp') Note that depending on your setup, you might need to change that file's...
Was ist STDOUT und STDERR? Was ist |? Was ist der Unterschied zwischen echo foo > /tmp/txt und echo foo >> /tmp/txt? Was ist eine ENV Variable und wie kann ich diese...
...cookies can simply set or expect by using one of the following options: helper.cookies[:foo] = "bar" helper.cookies.signed[:foo] = "bar" helper.cookies.encrypted[:foo] = "bar" Request Specs In request specs you can simply...
...direnv and mise handle environment variables. For switching use: $ direnv disallow $ cat `.envrc` export FOO=bar $ mise set FOO=bar --file mise.local.toml $ chmod 0600 mise.local.toml
...method with the same name. Take this example: class Project < ActiveRecord::Base def user "foo" end belongs_to :user end Project.new.user still returns "foo". The reason for this is that...
...belongs_to does is actually this: class Project < ActiveRecord::Base include FeatureMethods def user "foo" end end module Project::FeatureMethods def user # association getter goes here end end
...placed in your .bashrc or any location that is loaded by it. # Usage: linearcommits FOO-123456 # Alternative usage: linearcommits https://linear.app/some-workspace/issue/FOO-123456 function linearcommits { if test "$1" then local LINEAR...
...a regular git show). Example output for linearcommits ABC-165086636 --stat: commit 048054b1df87576f7c59cc0161cc331c44d2ea6b Author: Foo Bar <foo@bar.com> Date: Fri Apr 5 14:24:24 2019 +0200 [ABC-165086636] Linear issue...
...When you compare two objects in Ruby, you most often see the use of foo == bar. By default the == operator inherits from Object and is implemented as object identity (see...
...the Method object Dead simple: Get the method object and ask for its owner: "foo".method(:upcase) # => # "foo".method(:upcase).owner # => String Look up a method's source location
class Example; def method() end; end # => nil Example.new.method(:method).source_location # => ["(irb)", 11] "foo".method(:upcase).source_location # => nil # String#upcase is a native method that's defined in...
Given this class: class Foo class Bar end end If you want to clean up this code with the modularity gem, you might try something like this: class Foo
end end end Note that this changes Bar's full class name from Foo::Bar to BarTrait::Bar. If you have methods inside Foo (or other classes), you would...
...you can also render a partial within a helper. #_mobile_navigation.html.haml .mobile_navigation .htmlclass .htmlclass .foo links.each do |link| = link_to(link) module SomeHelper def render_mobile_navigation links = build_links...
...You can use it to dispatch an event on a jQuery object: let $element = $('.foo') $element.trigger('change') A caveat is that such an event will be received by jQuery event...
...listeners, but not by native event listeners: let $element = $('.foo') $element.on('change', event => console.log('I will be called')) $element[0].addEventListener('change', event => console.log("I WON'T be called")) $element.trigger...
...attributes, which would not be possible with a private attribute. class B def <=>(other) foo <=> other.foo end protected attr_accessor :foo
...you out on creating it. Simply use Nokogiri's xpath_for: Nokogiri::CSS.xpath_for('#foo') # => ["//*[@id = 'foo']"] Nokogiri::CSS.xpath_for('#foo .bar:nth-of-type(2)') # => ["//*[@id = 'foo']//*[contains(concat...
test "user can be created" do post users_path, params: { first_name: "Foo", last_name: "Bar" } assert User.count == 3 end Good example: test "user can be created" do...
...assert_difference "User.count", 1 do post users_path, params: { first_name: "Foo", last_name: "Bar" } end end Conclusion Benefits You tests will become more explicit by default (less tools such...
Usage: /foo+/ Shorthand for creating a regular expression object RegExp() object Usage: RegExp("foo+") or new RegExp("foo+") No surrounding slashes required (they're the literal markers)
...index they matched. Multiple calls to test() will advance this pointer: matcher = new RegExp("foo", "g") // <- "global" flag matcher.test("foobar") // => true matcher.lastIndex // => 3 (where the regexp stopped scanning) matcher.test("foobar...
...attribute. However, you can configure it to do so: fill_in 'Search contacts', with: 'foo' # => raises "Unable to find field 'Query'" Capybara.enable_aria_label = true # enable [aria-label] support for...
fill_in 'Search contacts', with: 'foo' # => fills in the query "foo" Also see An auto-mapper for ARIA labels and BEM classes in Cucumber selectors