-
Open a browser
# start an instance of firefox with selenium-webdriver driver = Selenium::WebDriver.for :firefox # :chrome -> chrome # :ie -> iexplore
- Go to a specified URL
#### | |
# Copyright by mediatainemnt-productions.com | |
# Created by Jan Jezek | |
# 2012 | |
############################ | |
## PLUGIN | |
######### |
@mixin sprite-background($name, $folder) { | |
$sprites: sprite-map("#{$folder}/*.png"); | |
$sprites-retina: sprite-map("#{$folder}@2x/*.png"); | |
background-image: sprite-url($sprites); | |
background-position: sprite-position($sprites, $name); | |
background-repeat: no-repeat; | |
@include inline-block; | |
height: image-height(sprite-file($sprites, $name)); | |
width: image-width(sprite-file($sprites, $name)); |
## Get FFMpeg working on heroku by building binaries using vulcan | |
# also added instructions on how to compile with libmp3lame and libx264 | |
#################################### | |
# INSTALL VULCAN if not done already | |
gem install vulcan | |
################# | |
# CREATE YOUR APP "Foo" |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
# config/locales/en.yml | |
en: | |
exception: | |
show: | |
not_found: | |
title: "Not Found" | |
description: "The page you were looking for does not exists." | |
internal_server_error: | |
title: "Internal Server Error" |
class ActionView::TestCase::TestController | |
def default_url_options(options={}) | |
logged_in = options[ :controller ] =~ /admin/ ? 'members' : nil | |
{ locale: I18n.default_locale, logged_in: logged_in } | |
end | |
end | |
class ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper | |
def call(t, args) | |
logged_in = @options[ :controller ] =~ /admin/ ? 'members' : nil |
Inevitably somewhere in your rails app you display flash messages to your users to inform them that an action has (or hasn't) taken place. Sometimes they need to provide more info, maybe you've just created some new information for them. Why make them sit around, or wonder where they need to go next when you can take them straight to it in the message itself? | |
I've ripped this code out of a project I've been working on and made it a little more generic. Initially I was going to just insert a link in the flash message, but as I was rightly pointed out by my pair and elegant coder extraordinaire, that would mean I'd be polluting my controller with logic and content that should be handled by the view. How do we solve a problem like pollution? | |
First, we updated the controller so that the flash message now looked something like this: | |
flash[:error] = "Username and password do not match. If you have | |
forgotten your password you can %s" | |
The %s is there to use a string substitution later. If you w |
<head> | |
<%= yield :title %> | |
</head> | |
<body> | |
<%= render_breadcrumbs %> | |
<%= yield # regular content %> | |
</body> |