diff --git a/Rakefile b/Rakefile index 429072a50..83faa9342 100644 --- a/Rakefile +++ b/Rakefile @@ -5,6 +5,7 @@ require 'rubygems' require 'hoe' require 'spec/version' require 'spec/rake/spectask' +require 'cucumber/rake/task' class Hoe def extra_deps @@ -19,6 +20,7 @@ Hoe.new('rspec', Spec::VERSION::STRING) do |p| p.description = "Behaviour Driven Development for Ruby." p.rubyforge_name = 'rspec' p.developer('RSpec Development Team', 'rspec-devel@rubyforge.org') + p.extra_deps = [["cucumber",">= 0.1.13"]] p.remote_rdoc_dir = "rspec/#{Spec::VERSION::STRING}" end @@ -26,7 +28,7 @@ end Rake.application.instance_variable_get('@tasks').delete(task) end -task :verify_rcov => [:spec, :stories] +task :verify_rcov => [:spec, :features, :stories] task :default => :verify_rcov # # Some of the tasks are in separate files since they are also part of the website documentation @@ -46,6 +48,9 @@ Spec::Rake::SpecTask.new do |t| end end +desc "Run Cucumber features" +Cucumber::Rake::Task.new do; end + desc "Run all stories" task :stories do ruby "stories/all.rb --colour --format plain" diff --git a/stories/example_groups/autogenerated_docstrings b/features/example_groups/autogenerated_docstrings.feature similarity index 98% rename from stories/example_groups/autogenerated_docstrings rename to features/example_groups/autogenerated_docstrings.feature index 982987ae7..1240d7e8e 100644 --- a/stories/example_groups/autogenerated_docstrings +++ b/features/example_groups/autogenerated_docstrings.feature @@ -1,4 +1,4 @@ -Story: autogenerated docstrings +Feature: autogenerated docstrings As an RSpec user I want examples to generate their own names diff --git a/features/step_definitions/running_rspec.rb b/features/step_definitions/running_rspec.rb new file mode 100644 index 000000000..a0031f146 --- /dev/null +++ b/features/step_definitions/running_rspec.rb @@ -0,0 +1,32 @@ +Given /^the file (.*)$/ do |relative_path| + @path = File.expand_path(File.join(File.dirname(__FILE__), "..", "resources", relative_path)) + unless File.exist?(@path) + raise "could not find file at #{@path}" + end +end + +When /^I run it with the (.*)$/ do |interpreter| + stderr_file = Tempfile.new('rspec') + stderr_file.close + @stdout = case(interpreter) + when /^ruby interpreter/ + args = interpreter.gsub('ruby interpreter','') + ruby("#{@path}#{args}", stderr_file.path) + when /^spec script/ + args = interpreter.gsub('spec script','') + spec("#{@path}#{args}", stderr_file.path) + when 'CommandLine object' then cmdline(@path, stderr_file.path) + else raise "Unknown interpreter: #{interpreter}" + end + @stderr = IO.read(stderr_file.path) + @exit_code = $?.to_i +end + +Then /^the (.*) should match (.*)$/ do |stream, string_or_regex| + written = case(stream) + when 'stdout' then @stdout + when 'stderr' then @stderr + else raise "Unknown stream: #{stream}" + end + written.should smart_match(string_or_regex) +end diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 000000000..5e2a49f75 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,25 @@ +require 'tempfile' +require File.dirname(__FILE__) + '/../../spec/ruby_forker' +require File.dirname(__FILE__) + '/../../stories/resources/matchers/smart_match' + +require 'spec/expectations' +require 'spec/matchers' + +module RspecWorld + include Spec::Expectations + include Spec::Matchers + include RubyForker + + def spec(args, stderr) + ruby("#{File.dirname(__FILE__) + '/../../bin/spec'} #{args}", stderr) + end + + def cmdline(args, stderr) + ruby("#{File.dirname(__FILE__) + '/../../resources/helpers/cmdline.rb'} #{args}", stderr) + end +end + +World do |world| + world.extend(RspecWorld) + world +end