I've always liked using the Page Object pattern to write concise, namespaced, and composeable capybara helpers:
When /^I register as a new user$/ do
NewUserPage.new(self).tap do |page|
page.visit!
page.form.fill
page.form.submit!
require 'attr_extras' | |
module StarbuzzCoffee | |
class Beverage | |
attr_reader :description | |
def initialize | |
@description = "Unknown Beverage" | |
end |
require "observer" | |
require 'attr_extras' | |
module WeatherMonitoringApp | |
module HeatIndex | |
# rubocop:disable Metrics/AbcSize | |
def self.calculate(t, rh) | |
( | |
16.923 + | |
(0.185212 * t) + |
guard 'rspec' do | |
watch(%r{^(app|config|lib|spec/support)/}) do | |
`git diff --name-only master`.split("\n").select do |path| | |
path =~ %r{spec/.*_spec.rb} | |
end | |
end | |
end |
#!/usr/bin/env ruby | |
require 'image_optim' | |
staged_files = `git diff --cached --name-only --diff-filter=ACM`.split("\n") | |
staged_files.select! { |f| f =~ %r{/images/} } | |
if staged_files.any? | |
image_optim = ImageOptim.new(pngout: false) |
I've always liked using the Page Object pattern to write concise, namespaced, and composeable capybara helpers:
When /^I register as a new user$/ do
NewUserPage.new(self).tap do |page|
page.visit!
page.form.fill
page.form.submit!
I've always wanted to write tests using Spinach. Unlike Cucumber, steps in Spinach are local to the feature they are defined. Therefore, they do not conflict with step definitions in other features.
However, we're using Cucumber in our project. The Cucumber way doesn't allow steps local to a scenario. In fact, it even considers it an anti-pattern.
Last week though, I had an idea: why not stamp each step with a scenario ID so that the step is local to the scenario? Using the spinach example, I ended with something like this:
#<RestClient::Request:0xb72c53a0 | |
@args= | |
{:password=>"********", | |
:method=>:put, | |
:payload=> | |
{:page=> | |
{:message=>"Minor fixes", | |
:title=>"title", | |
:body=> | |
"body"}}, |
Feature: Google Apps authentication | |
As a user I want to be able to register baweb account using my google account. | |
@selenium | |
Scenario: An customer creates account using GoogleID # features/307_google_apps_authentication.feature:5 | |
Given I am anonymous # features/step_definitions/user_steps.rb:1 | |
When I go to the signup page # features/step_definitions/web_steps.rb:23 | |
And I follow "Sign up with your Google Apps Account" # features/step_definitions/web_steps.rb:33 | |
And I fill in "Google Apps Domain:" with "gmail.com" # features/step_definitions/web_steps.rb:39 | |
WARNING: making https request to https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=llya694le36z&scc=1<mpl=default<mplcache=2 without verifying server certificate; no CA path was specified. |
# require 'rake' | |
require 'bundler' | |
Bundler::GemHelper.install_tasks | |
dir = File.dirname(File.expand_path(__FILE__)) | |
# $LOAD_PATH.unshift dir + '/lib/fcg-service-servers' | |
require 'lib/fcg-service-servers/version' | |
require 'rspec/core/rake_task' |
Intro | |
E-|---------------------------------|-10--12--14------12--10----------|---------------------0-----------|-------------0---2-------0-------|- | |
B-|---------------------------------|-10----------------------10------|---------0-----------------------|---------3-------------------3---|- | |
G-|---------------------------------|-11------------------------------|---------0---6-------------------|---------2-----------------------|- | |
D-|---------------------------------|---------------------------------|-----0-------7-----------0-------|-----0---------------0-----------|- | |
A-|---------------------------------|---------------------------------|-------------7-------------------|---------------------------------|- | |
D-|---------------------------------|---------------------------------|-3s5-------------0---------------|-0-------------------------------|- | |