...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...

...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

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...

...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...

DevOps Curriculum

...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...

...on your module's singleton class: module SomeTrait as_trait do define_singleton_method :foo do # ... end end end Using def (has caveats!) Alternatively, you can def the method on...

...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...

...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...

...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...

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...

stackoverflow.com

...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...

...was removed from the DOM } attributeChangedCallback(attribute, oldValue, newValue) { // the given attribute was changed } foo() { // a custom method } } customElements.define('my-element', MyElement) Note that this class automatically describes the JavaScript...

...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

tenderlovemaking.com

...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...

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...

mise.jdx.dev

...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

...JSON, and then escaping all code points above 127 using unicode escape sequences: escapeHighASCII('{"foo":"xäy"}') // => '{"foo":"x\\u00e4y"}' Escaping high ASCII in JavaScript function escapeHighASCII(string) { let unicodeEscape = (char...

...Use the new tag syntax Cucumber 1/2 Cucumber 3 @tag @tag ~@tag not @tag @foo, @bar (@foo or @bar) So you need to replace a hook like this: AfterStep('~@javascript...

masilotti.com

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...

...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

u.to_h => {:gid=>1, :email=>"hans@peter.de", :name=>"Hans Peter"} u.foo NoMethodError: undefined method `foo' for # compare objects: UserPreview.new(1, 'hans@peter.de', 'Hans Peter') == UserPreview.new(1, 'hans@peter.de', 'Hans Peter') => true

...image to one that is based on Alpine Linux. Debian image sorting: bar Bar foo Foo Alpine image sorting: Bar Foo bar foo Explanation Alpine Linux is a very slim...