Sha256: 9887c3669ecc152c72cf91e8b3857ad1a037b77b0c493995fde82f21d4f3640a

Contents?: true

Size: 1.6 KB

Versions: 10

Compression:

Stored size: 1.6 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|
  @path = "/tmp/example_spec.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 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

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

10 entries across 10 versions & 3 rubygems

Version Path
dchelimsky-rspec-1.1.11.5 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.11.6 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.11.7 features/step_definitions/running_rspec.rb
dchelimsky-rspec-1.1.12 features/step_definitions/running_rspec.rb
rspec-1.1.12 features/step_definitions/running_rspec.rb
spree-0.6.0 vendor/plugins/rspec/features/step_definitions/running_rspec.rb
spree-0.7.1 vendor/plugins/rspec/features/step_definitions/running_rspec.rb
spree-0.7.0 vendor/plugins/rspec/features/step_definitions/running_rspec.rb
spree-0.8.0 vendor/plugins/rspec/features/step_definitions/running_rspec.rb
spree-0.8.1 vendor/plugins/rspec/features/step_definitions/running_rspec.rb