...function is provided by PostgreSQL and supports Google-like query grammar: Query Result Message.search('foo bar') Both foo and bar must match somewhere Message.search('foo OR bar')
...bar must match somewhere Message.search('"foo bar"') The phrase foo bar must match in that exact order Message.search('foo -bar') foo must match, but bar must not Searching in multiple...
Jasmine specs for the frontend often need some DOM elements to work with. Because creating them is such a common...
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## Unreleased - Added `Foo#foo` method. ## 1.0.0 - 2017-06-20 ### Breaking changes - Renamed `Foo` to `Bar` - Removed `Baz#method...
...Please use `Qax#method` instead. ### Compatible changes - Added new `Bam#foo` method. ## 0.9.0 - 2017-05-20 ### Compatible changes - Improved performance of `Bam...
...record.errors[:email]).to include("can't be blank") # check for presence of error record.email = 'foo@bar.com' # valid state record.validate expect(record.errors[:email]).to_not include("can't be blank") # check for...
...is_expected.to allow_values('EUR', 'USD', 'GBP', 'CHF').for(:currency) } it { is_expected.not_to allow_values('foo', '€', '', nil).for(:currency) } it 'defaults to EUR' do expect(subject.currency).to eq('EUR') end
...constructs your Address instance: # without :mapping Rails uses keyword arguments Address.new(street_and_number: 'Foo St. 1', zip_code: '12345', city: 'Bar Town') # with a :mapping (even if that is...
...the "identity mapping" that keeps all names the same) Rails uses positional arguments Address.new('Foo St. 1', nil, '12345', 'Bar Town') Did you notice the nil in there? That's...
...hash, but the keys can also be accessed like methods h = ActiveSupport::OrderedOptions.new h['foo'] = 'bar' h.foo = 'bar' # same thing h['foo'] # => 'bar' h.foo # => 'bar' in? (> 3.0 only)
Array.wrap(nil) # => [] Array.wrap([1,2,3]) # => [1,2,3] Array.wrap(1) # => [1] Array.wrap("foo \n bar") # => ["foo \n bar"] Class.class_attributes (> 3.0 only) inheritable class attributes. Subclasses inherit from...
...allow you to indent code like you normally do in HTML mails. ❌ DON'T <%= 'foo' if bar %> "\n" if bar is false "foo\n" if bar is true <%= nil %>
<%= 'foo' %> <% end %> " foo" <%= 'foo' %> <%= 'bar' %> "foo\n\nbar\n" ✔️ DO Write unindented code to get the expected result. <% if bar %> <%= 'bar' %> <% end %> <%= 'foo' %> <%= 'bar' %> Use Form Models to...
...to read and is also suggested by Rubocop's Style/GlobalVars cop. Example before: if 'foo' =~ /foo/ puts $~[1] # => foo end Example after: if 'foo' =~ /foo/ puts $LAST_MATCH_INFO...
end Require pitfall in Rails The English library is not loaded by default in Rails. So you or another library needs to require it. The chances are very high...
...hostname for different apps, and you will stay logged in in each app: http://foo-app.daho.im:3000 => 127.0.0.1 http://bar-app.daho.im:3000 => 127.0.0.1 http://bam-app.daho.im:3000 => 127.0.0.1 Caution It's safe to use daho.im since...
...in your .bashrc: alias dahoim='echo "http://$(basename $PWD).daho.im:3000"' From a project directory (e.g. foo-app) this command will print the link to console that you can click on...
...to have the branch deleted: $ git merge ds/foo Updating 338e82e38..2d4269c81 Fast-forward foo | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 foo > You have just...
...allowing matchers to call other matchers. Example The following test checks that two variables foo and bar (1) have no lowercase characters and (2) end with an exclamation mark:
...foo).to_not match(/[a-z]/) expect(foo).to end_with('!') expect(bar).to_not match(/[a-z]/) expect(bar).to end_with('!') We can extract the repeated matcher chains...
...uses SELECT 1 AS one FROM...
...LIMIT 1 under the hood. In short: Replace foo.count > 0 with foo.any? or foo.count == 0 with foo.none? If you require quick counts and can...
...very liberal equality rules (more like === instead of ==). For example: expect(subject).to receive(:foo).with(MyClass) subject.foo(MyClass) # satisfies the expectation subject.foo(MyClass.new) # also satisfies the expectation expect(subject...
...If you want to expect strict equality, you could use expect(subject).to receive(:foo).with(eq(MyClass)) or expect(subject).to receive(:foo) do |klass| expect(klass).to eq...
...work with properties. Read and write properties (!) // jQuery let value = $input.prop('value') $element.prop('value', 'foo@bar.com') // Native let name = input.name input.name = 'foo@bar.com' // jQuery let src = $image.prop('src') $element.prop('src', 'foo.png')
...let src = image.src input.src = 'foo@.png' Working with CSS class names // jQuery $input.hasClass('active') $input.addClass('active') $input.removeClass('active') $input.toggleClass('active') // Native input.classList.contains('active') input.classList.add('active') input.classList.remove('active') input.classList.toggle('active')
...snake_case) that is also exposed to the JavaScript world (camelCase). # This query matches "foobar", "foo-bar" and "foo_bar" # The query is case insensitive be default. foo.?bar
...way they were added to singleton class. Consider the following code: module A def foo puts "Foo!!" end end module B def self.included(base) base.extend(ClassMethods) end module ClassMethods
puts "Foo!" super end end end class User singleton_class.include(A) include B end User.instance_eval do def foo puts 'Foo' super end end User.foo # => "Foo Foo! Foo!!" User.singleton_class.ancestors # => [# , B...
...of its compressed output. Let's take this function: function fn() { if (a) { return 'foo' } else if (b) { return 'foo' } else { return c() } } console.log(fn()) Terser will reduce this to...
...the following code: console.log(a||b?"foo":c()) Note how: The if statement has been replaced by a tertiary expression. This is often less readable, but it doesn't matter...
...around will not be part of the match. Positive lookahead: /foo(?=bar)/ matches the foo in the foo and the bar but not in this food is bad Negative lookahead...
...lookbehind: /(?<=ma)kandra/ matches the kandra in makandra but not in kandra Negative lookbehind: /(?<!foo)bar/ matches the bar in moo bar but not in foobar Modifiers in Ruby
...standard ruby character classes like \w, \d will only match 7-Bit ASCII characters: "foo" =~ /\w+/ # matches "foo" "füü" =~ /\w+/ # matches "f", ü is not 7-Bit ASCII
...argument matcher with a nested hash: describe 'user' do let(:user) { {id: 1, name: 'Foo', thread: {id: 1, title: 'Bar'} } it do expect(user).to match( hash_including(
...will fail and returns a not very helpful error message: expected {:id => 1, :name => "Foo", :thread => {:id => 1, :title => "Bar"}} to include hash_including(:id => 1, :thread => {:id => 1})
...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...
...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...