forked from sporkrb/spork
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sporkrb#121 from dchelimsky/support-rspec2
Support rspec2
- Loading branch information
Showing
18 changed files
with
164 additions
and
143 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,107 @@ | ||
require 'rubygems' | ||
|
||
unless $spec_helper_loaded | ||
$spec_helper_loaded = true | ||
|
||
$LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__))) | ||
SPEC_TMP_DIR = File.expand_path('tmp', File.dirname(__FILE__)) | ||
require 'spork' | ||
require 'stringio' | ||
require 'fileutils' | ||
require 'rspec' | ||
|
||
RSpec.configure do |config| | ||
config.before(:each) do | ||
$test_stdout = StringIO.new | ||
$test_stderr = StringIO.new | ||
@current_dir = nil | ||
end | ||
|
||
config.after(:each) do | ||
FileUtils.rm_rf(SPEC_TMP_DIR) if File.directory?(SPEC_TMP_DIR) | ||
|
||
end | ||
|
||
def create_file(filename, contents) | ||
FileUtils.mkdir_p(SPEC_TMP_DIR) unless File.directory?(SPEC_TMP_DIR) | ||
|
||
in_current_dir do | ||
FileUtils.mkdir_p(File.dirname(filename)) | ||
File.open(filename, 'wb') { |f| f << contents } | ||
end | ||
end | ||
SPEC_TMP_DIR = File.expand_path('tmp', File.dirname(__FILE__)) | ||
require 'spork' | ||
require 'stringio' | ||
require 'fileutils' | ||
require 'rspec' | ||
|
||
def create_helper_file(test_framework = FakeFramework) | ||
create_file(test_framework.helper_file, "# stub spec helper file") | ||
end | ||
RSpec.configure do |config| | ||
config.before(:each) do | ||
$test_stdout = StringIO.new | ||
$test_stderr = StringIO.new | ||
@current_dir = nil | ||
end | ||
|
||
def in_current_dir(&block) | ||
Dir.chdir(current_dir, &block) | ||
end | ||
|
||
def current_dir | ||
@current_dir ||= SPEC_TMP_DIR | ||
end | ||
|
||
def change_current_dir(sub_path) | ||
@current_dir = File.expand_path(sub_path, SPEC_TMP_DIR) | ||
end | ||
|
||
def windows? | ||
ENV['OS'] == 'Windows_NT' | ||
end | ||
config.after(:each) do | ||
FileUtils.rm_rf(SPEC_TMP_DIR) if File.directory?(SPEC_TMP_DIR) | ||
end | ||
end | ||
|
||
def create_file(filename, contents) | ||
FileUtils.mkdir_p(SPEC_TMP_DIR) unless File.directory?(SPEC_TMP_DIR) | ||
|
||
in_current_dir do | ||
FileUtils.mkdir_p(File.dirname(filename)) | ||
File.open(filename, 'wb') { |f| f << contents } | ||
end | ||
end | ||
|
||
def create_helper_file(test_framework = FakeFramework) | ||
create_file(test_framework.helper_file, "# stub spec helper file") | ||
end | ||
|
||
module RSpec | ||
module Matchers | ||
class IncludeAStringLike | ||
def initialize(substring_or_regex) | ||
case substring_or_regex | ||
when String | ||
@regex = Regexp.new(Regexp.escape(substring_or_regex)) | ||
when Regexp | ||
@regex = substring_or_regex | ||
else | ||
raise ArgumentError, "don't know what to do with the #{substring_or_regex.class} you provided" | ||
end | ||
end | ||
def in_current_dir(&block) | ||
Dir.chdir(current_dir, &block) | ||
end | ||
|
||
def matches?(list_of_strings) | ||
@list_of_strings = list_of_strings | ||
@list_of_strings.any? { |s| s =~ @regex } | ||
end | ||
def failure_message | ||
"#{@list_of_strings.inspect} expected to include a string like #{@regex.inspect}" | ||
end | ||
def negative_failure_message | ||
"#{@list_of_strings.inspect} expected to not include a string like #{@regex.inspect}, but did" | ||
def current_dir | ||
@current_dir ||= SPEC_TMP_DIR | ||
end | ||
|
||
def change_current_dir(sub_path) | ||
@current_dir = File.expand_path(sub_path, SPEC_TMP_DIR) | ||
end | ||
|
||
def windows? | ||
ENV['OS'] == 'Windows_NT' | ||
end | ||
|
||
|
||
module RSpec | ||
module Matchers | ||
class IncludeAStringLike | ||
def initialize(substring_or_regex) | ||
case substring_or_regex | ||
when String | ||
@regex = Regexp.new(Regexp.escape(substring_or_regex)) | ||
when Regexp | ||
@regex = substring_or_regex | ||
else | ||
raise ArgumentError, "don't know what to do with the #{substring_or_regex.class} you provided" | ||
end | ||
end | ||
|
||
def include_a_string_like(substring_or_regex) | ||
IncludeAStringLike.new(substring_or_regex) | ||
def matches?(list_of_strings) | ||
@list_of_strings = list_of_strings | ||
@list_of_strings.any? { |s| s =~ @regex } | ||
end | ||
def failure_message | ||
"#{@list_of_strings.inspect} expected to include a string like #{@regex.inspect}" | ||
end | ||
def negative_failure_message | ||
"#{@list_of_strings.inspect} expected to not include a string like #{@regex.inspect}, but did" | ||
end | ||
end | ||
end | ||
|
||
module Spork::TestIOStreams | ||
def self.included(klass) | ||
klass.send(:extend, ::Spork::TestIOStreams::ClassMethods) | ||
def include_a_string_like(substring_or_regex) | ||
IncludeAStringLike.new(substring_or_regex) | ||
end | ||
|
||
end | ||
end | ||
|
||
module Spork::TestIOStreams | ||
def self.included(klass) | ||
klass.send(:extend, ::Spork::TestIOStreams::ClassMethods) | ||
end | ||
|
||
def stderr | ||
self.class.stderr | ||
end | ||
|
||
def stdout | ||
self.class.stdout | ||
end | ||
|
||
module ClassMethods | ||
def stderr | ||
self.class.stderr | ||
$test_stderr | ||
end | ||
|
||
def stdout | ||
self.class.stdout | ||
end | ||
|
||
module ClassMethods | ||
def stderr | ||
$test_stderr | ||
end | ||
|
||
def stdout | ||
$test_stdout | ||
end | ||
$test_stdout | ||
end | ||
end | ||
|
||
Dir.glob(File.dirname(__FILE__) + "/support/*.rb").each { |f| require(f) } | ||
end | ||
|
||
Dir.glob(File.dirname(__FILE__) + "/support/*.rb").each { |f| require(f) } |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require File.dirname(__FILE__) + '/../spec_helper' | ||
require 'spec_helper' | ||
|
||
|
||
describe Spork::Diagnoser 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
require File.dirname(__FILE__) + '/../../spec_helper' | ||
require File.dirname(__FILE__) + "/../test_framework_shared_examples" | ||
require 'spec_helper' | ||
require 'spork/test_framework_shared_examples' | ||
|
||
describe Spork::TestFramework::Cucumber do | ||
before(:each) do | ||
@klass = Spork::TestFramework::Cucumber | ||
@server = @klass.new | ||
end | ||
|
||
it_should_behave_like "a TestFramework" | ||
it_behaves_like "a TestFramework" | ||
end |
Oops, something went wrong.