This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# env.rb | |
Capybara.register_driver :chrome do |app| | |
Capybara::Selenium::Driver.new(app, :browser => :chrome) | |
end | |
Capybara.javascript_driver = :chrome | |
Download chromedriver from http://code.google.com/p/selenium/downloads/list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby 1.8.7 | |
> Date.parse('01/06/2010').to_s | |
=> "2010-06-01" | |
# Ruby 1.9.2 | |
> Date.parse('01/06/2010').to_s | |
=> "2010-01-06" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def csrf_meta_tags | |
if protect_against_forgery? | |
[].tap do |tags| | |
tags << tag('meta', {:name => 'csrf-param', :content => request_forgery_protection_token}) | |
tags << tag('meta', {:name => 'csrf-token', :content => form_authenticity_token}) | |
end.join("\n").html_safe | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given "I am signed in" do | |
user = User.create!(:email => 'alice@example.com', :password => 'password', :password_confirmation => 'password') | |
step 'I go to the homepage' | |
step 'I follow "Sign In"' | |
step %Q|I fill in "user_email" with "#{user.email}"| | |
step 'I fill in "user_password" with "password"' | |
step 'I press "Sign in"' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if form.object.errors.any? %> | |
<div id="error_explanation"> | |
<h2>The following errors prohibited this form from being saved:</h2> | |
<ul> | |
<% form.object.errors.full_messages.each do |message| %> | |
<li><%= message %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>eHarbor</title> | |
<!--[if lt IE 9]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<%= csrf_meta_tag %> | |
<%= stylesheet_link_tag 'application', :media => "all", "data-turbolinks-track" => true %> | |
<%= javascript_include_tag 'application', "data-turbolinks-track" => true %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'book' | |
class BookTest < Test::Unit::TestCase | |
def setup | |
@book = Book.new | |
end | |
def test_should_capitalize_the_first_letter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>eHarbor</title> | |
<%= stylesheet_link_tag 'boilerplate', 'main' %> | |
<%= javascript_include_tag :defaults %> | |
<!--[if IE]> | |
<%= javascript_include_tag 'http://html5shiv.googlecode.com/svn/trunk/html5.js' %> | |
<![endif]--> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When /I see wtf is going on/i do | |
save_and_open_page | |
end | |
When /I want to debug/i do | |
debugger | |
true # never put debugger at the end of a method | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# just add a gem dependency for Timecop or require it yourself | |
Given 'the time is $time' do |time| | |
Timecop.freeze Time.parse(time) | |
end | |
When '$time pass' do |time| | |
Timecop.travel future_time(time) | |
Given 'delayed jobs are run' # we use delayed jobs and have some that get scheduled in the future. | |
end |