- __meta_kubernetes_namespace target_label: Namespace ### NEW drop RULE ### - action: drop regex: ".*foo.*" source_labels: - __meta_kubernetes_namespace The drop will never occur, because meta_kubernetes_namespace will...

...considers text that is actually visible to a user. Then I should not see "foobear" This is because the Rack::Test driver does not know if an element is visible...

Spreewald offers steps to check that an element is hidden by CSS: Then "foo" should be hidden You can also check that an element is visible: Then "foo" should...

errors.add_to_base('failed') if bad_things? end end ^ # app/models/foo.rb require 'user' class Foo # something happens here end Now, when your environment is booted, Rails will automatically load your...

...models, like User. In our example, when Foo gets loaded, it will require the User class itself again. Since Ruby 1.8 identifies required files by the string you used (as...

# something like has_defaults would be nicer, but fails with e.g. User.new :password => 'foo' self.salt ||= ActiveSupport::SecureRandom.hex(20) if new_record? # this double-hashing technique is explained in...

github.com

...using the json gem, you might run into this error when using JSON.parse: >> json = 'foo'.to_json >> JSON.parse(json) JSON::ParserError: 757: unexpected token at '"foo"' from /.../gems/json-1.7.7/lib/json/common.rb:155:in...

...fix that, use a valid object to build JSON from, e.g. an array: >> JSON.parse([ 'foo' ].to_json).first => "foo" When you do that, remember to select the record from the...

...do it like this: page.within_frame('iframe-id') do fill_in 'E-mail', with: 'foo@bar.com' fill_in 'Password', with: 'secret' click_button 'Submit' end Instead of the frame's [id...

...can use your existing steps like this: When I fill in "E-mail" with "foo@bar.com" inside the login frame Note: Spreewald >= 4.1.0 already includes that step

Consider this class: class Foo private def test puts "Hello" end end While you can say create a block to call that method (using ampersand and colon) on Ruby...

...Foo.new.tap(&:test) Hello => # ... you cannot do that on Ruby 1.9 or 2.0: 1.9.3 > Foo.new.tap(&:test) NoMethodError: private method `test' called for # ^ 2.0.0 > Foo.new.tap(&:test) NoMethodError: private method `test' called for...

apidock.com

...virtual attributes that get and set a string array: post = Post.last puts post.tag_list # ['foo', 'bar', 'baz'] post.tag_list = ['bam'] puts post.tag_list # ['bam'] If you would like to create...

- form_for @post do |form| = form.check_box :tag_list, { :multiple => true }, 'foo', nil = form.check_box :tag_list, { :multiple => true }, 'bar', nil = form.check_box :tag_list, { :multiple => true...

With the most recent spec_candy.rb helpers you can say: User.stub_any_instance(:foo => :bar) user = User.new user.foo # => :bar RSpec 2 (Rails 3) RSpec 2 comes with this feature...

User.any_instance.stub(:foo => :bar) user = User.new user.foo # => :bar RSpec 3 RSpec Mocks 3.3: any_instance allow_any_instance_of(User).to receive(:foo).and_return(:bar) user = User.new

w3.org

You probably commonly used the :last-child CSS meta selector like so: .foo { border-bottom: 1px dashed #000; } .foo:last-child { border-bottom-width: 0; } However, this only...

...Instead, prefer using the + sibling selector. It applies to the element following the other. .foo + .foo { border-top: 1px dashed #000; } Note how we now use a top border instead...

...Ruby objects you may run into problems when encountering fields with NULL values: SELECT foo, bar, foo - bar AS baz FROM plop; +-----+------+------+ | foo | bar | baz | +-----+------+------+ | 30 | 20 | 10 |

...selected value if present and a given alternative if it would select NULL: SELECT foo, bar, foo - IFNULL(bar, 0) AS baz FROM plop; +-----+------+-----+ | foo | bar | baz...

`role_list_from': unknown role `something' (ArgumentError) Consider this task definition: namespace :foo do task :bar, :roles => :something do # do crazy stuff end end Whenever we call foo.bar...

...that is only available for that group of servers, you'll get another error: `foo.bar' is only run for servers matching {:roles=>:something}, but no servers matched To properly fix...

...When I go to the start page Then I should not see "Home of Foo" When our host is "foo.example.com" And I go to the start page

...see "Home of Foo" The host will be stubbed for the remainder of one scenario and restored after each scenario (i.e. you do not need an After step to clean...

Example def test(input) input.gsub /(f)/ do puts $1 'b' end end >> test('foo') f => "boo" >> test('foo'.html_safe) nil => "boo" Wat? More fun: It's not a...

...problem when using inline blocks. >> 'foo'.html_safe.gsub(/(f)/) { puts $1; 'b' } f => "boo" Why? This is because of the way rails_xss implements "unsafe" methods: # vendor/plugins/rails_xss/lib/rails_xss/string_ext.rb UNSAFE_STRING_METHODS = [ ..., "gsub...

...added by calling the indexer method on the DatabaseCleaner module: DatabaseCleaner[:active_record, db: Foo]. The DatabaseCleaner gem itself does not define any cleaners. By default, it's empty.

When using _.extend/_.assign or _.merge, you will modify the destination object. object1 = { foo: 23, bar: 42 } object2 = { bar: 99 } _.extend(object1, object2) // => { foo: 23, bar: 99 } object1 // => { foo: 23, bar...

...you do not want to do that, simply extend into a new object: object1 = { foo: 23, bar: 42 } object2 = { bar: 99 } _.extend({}, object1, object2) // => { foo: 23, bar: 99 } object1 // => { foo...

...use for growing (e.g. to get from [1, 2, 3] to [1, 2, 3, "foo", "foo"] you have to say [1, 2, 3].fill("foo", 3..4) or...

...fill("foo", 3, 2) which are both equally odd-looking) and while we could use it inside our #in_size method it would not make things easier...

...good). But in doing so, it will disconnect the existing connection. Now consider this: Foo.transaction do Foo.create! with_other_database do raise 'Oops' if Bar.count > 9000 end end

...of each line is the connection ID): 1 Connect 1 BEGIN 1 INSERT INTO foos 1 Quit 2 Connect 2 SELECT COUNT(*) FROM bars 2 Quit That's it. Unfortunately...

makandra dev

Sometimes your code has long lines: describe 'foo' do describe 'bar' do really_long_line_really_long_line_really_long_line another_line When you're working with multiple editor...

...panes, such code will often be wider than the pane area: describe 'foo' do | describe 'bar' do | really_long_line_really_long_| another_line | To help with this you can...

...own piece of code before the actual scenario is run which looks like that: @foo Scenario: Do something ... and you place the following snippet into support/env.rb: Before('@foo') do

...This is run every time a @foo tagged scenario is hit" end You can tag RSpec examples like this: it 'does something', :foo => true do ... end What you need is...

makandra dev

...allow the user to pass in arrays as well as scalar values, since Array("foo") == ["foo"] Array(["foo", "bar"]) == ["foo", "bar"] But Array() actually calls to_a on its arguments...

...which may not always do what you expect. For example Array("foo \n bar") == ["foo \n", "bar...

To find a version containing the regular expression foo in the history of any branch: git grep foo $(git rev-list --all) You may also limit the search to a...

...file extension, e.g. Ruby files (.rb) like this: git grep foo $(git rev-list --all) -- *.rb

makandra dev
curl.haxx.se

...b will read cookies from a given file Example The remote server sets a "foo" cookie to value "bar". We tell curl to store them to a file at /tmp/cookies...

...file was generated by libcurl! Edit at your own risk. httpbin.org FALSE / FALSE 0 foo bar To send cookies to a server, use the -b switch. This URL will render...

Given those modules: module A def foo; end def bar; end end module B end When you want to call methods from A inside B you would normally just include...

...cleaner way would be like this: module B module Outside include ::A module_function :foo end end This allows you to use B::Outside.foo or just define a method inside...