Here is a short summary of Cucumber hooks in Ruby taken from https://github.com/cucumber/cucumber-ruby. Note that the
BeforeStep is currently not existing in the Ruby implementation of Cucumber.
Before hooks run before the first step of each scenario.
Before do |scenario| ... end
After hooks run after the last step of each scenario, even when the step result is
For outputting a given String in HTML, you mostly want to replace line breaks with
You can use
simple_format, but it has side effects like keeping some HTML.
If you only care about line breaks, you might be better off using a small, specialized helper method:
def format_linebreaks(text) safe_text = h(text) paragraphs = split_paragraphs(safe_text).map(&:html_safe) html = ''.html_safe paragraphs.each do |paragraph| html << content_tag(:p, paragraph) end
<input type="file"> accepts a single file. You can allow multiple files via
<input type="file" multiple>.
But sometimes, selecting multiple files is not enough and can be cumbersome for the user. Enter
<input type="file" webkitdirectory multiple>
webkitdirectory switches the browser's file picker to select a directory. All files inside that directory, and inside any nested subdirectories, will be selected for the file input.
This can be useful when users want to upload all files from a nested dire...
Versions 2.9.0, 2.99.0 and 3.0.0 of our gem Spreewald have been released.
an email should have been sent with:does now support wildcards (
*at the end of a line to ignore the rest of the line,
*as single character in a line to ignore multiple lines). The step also has better error messages if an email could not be found.
show me the emailsgot an option to display only the email headers. Additionally, a new step `show me the email( header)?s...
Our applications not only need to be functional, they need to be fast.
But, to quote Donald Knuth,
premature optimization is the root of all evil (or at least most of it) in programming
The reasoning is that you should not waste your time optimizing code where it does not even matter. However, I believe there are some kinds of optimizations you should do right away, because
This is an attempt to list some of those things:
There is a common view that extracting text from a PDF document should not be too difficult. After all, the text is right there in front of our eyes and humans consume PDF content all the time with great success. Why would it be difficult to automatically extract the text data?
Turns out, much how working with human names is difficult due to numerous edge cases and incorrect assumptions, working with PDFs is difficult due to the extreme flexibility given by the PDF format.
Git commits should be very deliberate, and only contain changes that you really want to be in there. In order to reduce the chance to accidentally commit something you didn't intend, review your changes before committing.
git add -N . # Add all paths, but not their contents git add -p
Git will now show you all your changes in small chunks and ask you in an interactive mode whether you really want to add them.
The most helpful commands are
Note: Modern Rails has two build pipelines, the asset pipeline (or "Sprockets") and Webpacker. The principles below apply for both, but the examples shown are for Sprockets.
Form fields can be rendered as noneditable by setting the
disabled or the
readonly attribute. Be aware of the differences:
Browser specific behavior:
After a recent Ubuntu update I didn't see the main menu bar of the RubyMine IDE (
File | Edit | View | ...) anymore.
This could be solved by changing a RubyMine registry entry:
ctrl + alt + n> click on
registry> click on
linux.native.menuand disable the checkbox
After rebooting RubyMine, you'll have gotten the menu bar back.
This card existed before, but was outdated due to browser implementation changes. The information below is validated for the current list of browsers we support.
By default your
body elements are only as high as the actual page content. If you only have two lines of text in your page, your
body elements will only be around 40 pixels high, regardless of the size of your browser window.
You might be surprised by this, since setting a
background on either
body does cover the enti...
CSP hat zum Ziel einen Browser-seitigen Mechanismus zu schaffen um einige Angriffe auf Webseiten zu verhindern, hauptsächlich XSS-Angriffe.
XSS = Cross Site Scripting. Passiert wenn ein User ungefiltertes HTML in die Webseite einfügen kann.
<div class="comment"> Danke für den interessanten Beitrag! <script>alert('you have been hacked')</script> </div>
Rails löst das Problem weitgehend, aber
Most forms have a single submit button that will save the record when pressed.
Sometimes a form needs additional submit buttons like "accept" or "reject". Such buttons usually attempt a state transition while updating the record.
To process a form with multiple buttons, your server-side code will need to know which button was pressed. To do so you can give each submit button a different
[formaction] attribute. This will override the ...
Nokogiri is great. It will even fix invalid HTML for you, like a browser would (e.g. move block elements out of parents which are specified to not allow them).
>> Nokogiri::HTML.fragment("<h1><p>foo</p><span>bar</span></h1>").to_s => "<h1></h1><p>foo</p><span>bar</span>"
While this is mostly useful, browsers are actually fine with a bit of badly formatted HTML. And you don't want to be the one to blame when the SEO guy complains about an empty
To avoid said behavior, use
Nokogiri::XML instead of
Nokogiri::HTML when par...
Speaker today is Henning Koch, Head of Development at makandra.
This talk will be in German with English slides.
Some of the questions we will answer in this talk:
newkeyword construct an object?
Test Driven Development is the paradigm to "first write a test, then implement the code". This guide shows how to apply it in practice, with Cucumber and RSpec as integration and unit test frameworks.
I like to view TDD as a process with three levels:
During development you are frequently changing levels. It may look something like this:
Integration _ _ Code \__ ___ __/ Spec \____/ \__...