Sha256: 06b1779dd4cf96106c29ca3f9e6a72691bfd93cf7794251be506ec9e1d8dd801

Contents?: true

Size: 1.7 KB

Versions: 11

Compression:

Stored size: 1.7 KB

Contents

Given /^the file (.*)$/ do |relative_path|
  @path = File.expand_path(File.join(File.dirname(__FILE__), "..", "support", relative_path))
  unless File.exist?(@path)
    raise "could not find file at #{@path}"
  end
end

Given /^the following spec:$/ do |spec|
  dir = File.join(File.dirname(__FILE__), "/../../tmp")
  FileUtils.mkdir(dir) unless test ?d, dir
  @path = "#{dir}/current_example.rb"
  File.open(@path, "w") do |f|
    f.write spec
  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 command/
      args = interpreter.gsub('spec command','')
      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

Then /^the (.*) should not 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_not smart_match(string_or_regex)
end

Then /^the exit code should be (\d+)$/ do |exit_code|
  if @exit_code != exit_code.to_i
    raise "Did not exit with #{exit_code}, but with #{@exit_code}. Standard error:\n#{@stderr}"
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
dchelimsky-rspec-1.1.99.1 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.99.13 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.99.2 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.99.3 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.99.4 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.99.5 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.99.6 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.99.7 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.99.8 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.99.9 features/step_definitions/running_rspec.rb
rspec-1.2.0 features/step_definitions/running_rspec.rb