...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...
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...
...with a GET request, even if the requesting method is PATCH or DELETE: def foo redirect_to '/bar', status: :see_other end See Modern HTTP Status codes for redirecting for...
...and will return an enumerator. This is what allows you to do things like ['foo', 'bar', 'baz'].each.with_index.collect { |name, index| name * index } # -> ["", "bar", "bazbaz"] If you write your own each...
...for :freeze support. As an example, consider the following Yaml file: --- message: - hello - universe foo: bar: baz: "example" We can now load it as usual, but pass freeze: true.
...YAML.safe_load_file('example.yml', freeze: true) => {"message"=>["hello", "universe"], "foo"=>{"bar"=>{"baz"=>"example"}}} The Hash itself is frozen: >> test.frozen? => true And no matter how deep you dig, everything inside that...
...Use define_singleton_method instead: module SomeTrait as_trait do |name| define_singleton_method :foo do puts name end end
...parameters as described below. If possible, specify allowed parameters explicitly, e.g. url_for(params.permit(:foo, :bar)). Rails 7.1+ url_for(path_params: request.path_parameters, params: request.query_parameters) Rails versions before...
The sprintf method has a reference by name format option: sprintf("% d : % f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000 sprintf("%{foo}f", { :foo => 1 }) # => "1f" The format identifier % stands for...
...parentheses (()) are not optional in JavaScript function calls. Understand the difference between function pointers (foo) and function invocations (foo()). Notice the parallels between blocks ("procs", "lambdas") in Ruby and function...
...index when your query is well-formed: mysql> EXPLAIN SELECT * FROM users WHERE email = 'foo@example.com'; +----+-------------+-------+-------+----------------------+----------------------+---------+-------+------+-------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+----------------------+----------------------+---------+-------+------+-------+
By file Only commits that introduced changes to a specific file git log -- foo.rb bar.rb Note In case the file was renamed or moved the --follow option can be...
git log --follow -- foo.rb By content If you want to know when a specific line of code was added in the project git log -S"def function_name"
...using Capybara, functions like click_link or expectations like expect(page).to have_css('.foo') already retry internally. See other card for in depth explanation At makandra we use Spreewald...
...sets the value to the specified query parameter more Example const params = new URLSearchParams('foo=bar') params.append('baz', 'baq') params.toString() // 'foo=bar&baz=baq' params.delete('baz') params.toString() // 'foo=bar'
params.has('foo') // true params.set('foo', 'baz') params.toString() // 'foo=baz' Working with URLs You can also easily use the URLSearchParams API if you have an URL or an URL...
CONCAT('foo', 'bar', NULL) = NULL the NULL always wins in MySQL. If you would rather treat NULL as an empty string, use CONCAT_WS (concatenation with separator) instead...
...CONCAT_WS('', 'foo', 'bar', NULL) = 'foobar' PostgreSQL In PostgreSQL the NULL is not viral in CONCAT: CONCAT('foo', 'bar', NULL) = 'foobar...
echo "Hello $NAME!" } $ hello # $?=1 bash: 1: provide name as first parameter $ hello Foo # $?=1 Hello Foo! Parameter with default hello() { NAME=${1:-Marvin} echo "Hello $NAME!" }
$ hello Foo # $?=1
it { should allow_value("email@addresse.foo").for(:sender) } it { should_not allow_value("foo").for(:sender) } # Rspec 3 expect syntax it { is_expected.to allow_value("email@addresse.foo").for(:sender) } it { is_expected.not...
...to allow_value("foo").for(:sender) } end Errors that may occur if you do use should validate_format_of(...): NoMethodError: private method `gsub' called for /\A[a-z0-9\-_]+\z...
...for sidekiq works as expected and the retries total duration fits. # Example: TestWorker.perform_async('foo', 'bar') class TestWorker include Sidekiq::Worker def perform(*args) raise 'This is a test error...
Typhoeus has a different way of representing array params in a get request than RestClient. Typhoeus: http://example.com/?foo[0]=1&foo[1]=2&foo[2]=3
...to remove blank values from collections (e.g. arrays). Remove nil values from an array ['foo', nil].compact # => ['foo'] # You can use the splat operator to ignore nil values when constructing...
['foo', *nil] # => ['foo'] Remove blank values from collections Array array = [1, "", nil, 2, " ", [], {}, false, true] # Any Rails version array.reject(&:blank?) # => [1, 2, true] # Since Rails 6.1+ array.compact_blank...
...If the mocked property is a simple value, it will not work: const x = { foo: 1 } console.log(x.foo) // 1 spyOnProperty(x, 'foo').and.returnValue(2) // Throws: Error: : Property foo does not...
...it can be mocked with Jasmine. You can use it like this: const x = { foo: 1 } console.log(x.foo) // 1 spyOnValueProperty(x, 'foo').and.returnValue(2) expect(x.foo).toBe(2)
...share some attributes and traits: FactoryBot.define do factory :user do screen_name 'john' email 'foo@bar.de' trait :with_profile do age 18 description 'lorem ipsum' end end factory :client do
...name 'John Doe' email 'foo@bar.de' trait :with_profile do age 18 description 'lorem ipsum' end end end You can re-use the shared fields by defining a trait outside the...
...scope to pluck all the ids of the relation: # Modern Rails User.where("users.name LIKE 'Foo Bar'").ids # Rails 3.2+ equivalent User.where("users.name LIKE 'Foo Bar'").pluck(:id) # Edge rider equivalent...
User.where("users.name LIKE 'Foo Bar'").collect_ids
Check if an object (or its prototype) has a property CoffeeScript var hasFoo = 'foo' of object JavaScript var hasFoo = 'foo' in object; Iterate through all properties of an object...