Skip to content

Instantly share code, notes, and snippets.

View dchelimsky's full-sized avatar

David Chelimsky dchelimsky

  • Retired
  • Chicago, IL, USA
View GitHub Profile
given "logged in" do
login
end
given "anonymous" do end
describe "Homepage: url(:home)", :given => "logged in" do
before(:each) do
@rack = request(:home)
end
Scenario: withdraw cash
Given I have [starting balance] in my checking account
When I withdraw [withdrawal amount]
Then I should have [resulting balance] in my my checking account
| starting balance | withdrawal amount | resulting balance |
| 20 | 7 | 13 |
GIVENS = {}
def given name, &block
GIVENS[name] = &block
end
config.extend_group_on(:given) do |given, group|
group.before(:each) do
GIVENS[give].call
end
module Autotest::Growl
def self.growl title, msg, img, pri=0, stick=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
end
def self.strip_command_line_format(text)
result = text.gsub(/\e\[(\d+)m/,"")
result.gsub!("\n","")
end
module OnOptionExample
GIVENS = {}
def self.given name, &block
GIVENS[name] = block
end
given "@value = 10" do
@value = 10
end
require 'spec'
module Spec
module Macros
end
class << self
def define_macros
Spec::Macros.extend Module.new { yield }
end
Autotest.add_hook :initialize do |at|
unless ARGV.empty?
if Dir["app"].empty?
at.find_directories = ARGV.length == 1 ? ["spec/#{ARGV.first}","lib/#{ARGV.first}"] : ARGV.dup
else
at.find_directories = ARGV.length == 1 ? ["spec/#{ARGV.first}","app/#{ARGV.first}"] : ARGV.dup
end
end
end
module ControllerMacros
module InstanceMethods
def should_render template
it "should render the #{template} template" do
do_request
response.should render_template(template)
end
end
>> foo = Group.create(:name => 'Foo')
=> #<Group id: 4, name: "Foo">
>> bar = Group.find(4)
=> #<Group id: 4, name: "Foo">
>> bar.update_attributes(:name => 'Bar')
=> true
>> bar
=> #<Group id: 4, name: "Bar">
>> foo
=> #<Group id: 4, name: "Foo">
Feature: Compile C code into Ruby extensions.
In order to automate compilation process.
As a Gem developer.
I want rake tasks compile source code for me.
Scenario: Compile single extension
Given a safe project directory
And scaffold code for extension 'extension_one'
And 'tmp' folder is deleted