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
s = "test 'a' and 'b' and 'c'" | |
arguments = s.scan /'\w+'/ | |
=> ["'a'", "'b'", "'c'"] |
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
targets 1,2,3,4 | |
def targets(*targets) | |
@targets=[targets] | |
end | |
@targets | |
=> [1,2,3,4] |
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
namespace MockingCSharp | |
{ | |
public class ImplementingMockableClass | |
{ | |
IInterface mockedClass; | |
public ImplementingMockableClass (IInterface mockable) | |
{ | |
mockedClass = mockable; | |
} | |
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 'java' | |
require 'out.jar' | |
include_class Java::ImplementingMockableClass | |
i = ImplementingMockableClass.new(v) | |
puts i.output_string | |
class ClassWithInterface | |
def get_string | |
"mocked" |
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 find_files_in(directories, include, exclude=nil) | |
files = [] | |
directories.each do |d| | |
found = Dir.glob("#{d}/bin/#{@build_type}/#{include}"); | |
found = found - Dir.glob("#{d}/bin/#{@build_type}/#{exclude}") unless exclude.nil? | |
files = files + found | |
end | |
return files | |
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
C:\ironruby\bin>ispec myspec.rb | |
0.9.3.0 | |
. | |
Finished in 0.1406214 seconds | |
1 example, 0 failures |
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'm on|I go to) the search page$/ do | |
@browser.goto 'http://www.google.com/' | |
end | |
When /^I search for \"(.*)\"$/ do |query| | |
@browser.text_field(:name, 'q').set(query) | |
@browser.button(:name, 'btnG').click | |
end | |
Then /^I should be on the search page$/ do |
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
# Taken from https://gist.github.com/225061/2ecbd30eb13ca1edbb918249d0e834964ab58d6b | |
module Webrat | |
class SeleniumSession | |
extend Forwardable | |
# Add more methods of webrat/core/session when needed | |
def_delegators :current_scope, :field_labeled, :table_at, :css_search | |
def within(selector) | |
scopes.push(Webrat::Scope.from_scope(self, current_scope, selector)) |
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
#!/usr/bin/env ruby | |
$:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib') | |
require 'rubygems' | |
require 'cucumber/rspec_neuter' | |
require 'cucumber/cli/main' | |
begin | |
# The dup is to keep ARGV intact, so that tools like ruby-debug can respawn. | |
failure = Cucumber::Cli::Main.execute(ARGV.dup) | |
Kernel.exit(failure ? 1 : 0) |
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
stubbed = stub 'System::Web::HttpRequestBase | |
.application_path.return("123") && | |
.file_path.return("456")' | |
puts stubbed | |
puts stubbed.application_path | |
puts stubbed.file_path | |