Sha256: a26c232a9969185da8356425c08288fb687d3fe1198a35d36c15914a109ee69e

Contents?: true

Size: 1.63 KB

Versions: 57

Compression:

Stored size: 1.63 KB

Contents

steps_for :running_rspec do

  Given("the file $relative_path") 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 $interpreter") 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 exit code should be $exit_code") 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
  
  Then("the $stream should match $regex") 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 $stream should not match $regex") 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
end

Version data entries

57 entries across 57 versions & 10 rubygems

Version Path
dchelimsky-rspec-1.1.10 stories/resources/steps/running_rspec.rb
dchelimsky-rspec-1.1.11.1 stories/resources/steps/running_rspec.rb
dchelimsky-rspec-1.1.11 stories/resources/steps/running_rspec.rb
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec/stories/resources/steps/running_rspec.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec/stories/resources/steps/running_rspec.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec/stories/resources/steps/running_rspec.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec/stories/resources/steps/running_rspec.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/stories/resources/steps/running_rspec.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/stories/resources/steps/running_rspec.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/stories/resources/steps/running_rspec.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/stories/resources/steps/running_rspec.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/stories/resources/steps/running_rspec.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/stories/resources/steps/running_rspec.rb
mack-0.8.2 lib/gems/rspec-1.1.11/stories/resources/steps/running_rspec.rb
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/stories/resources/steps/running_rspec.rb
picolena-0.1.1 rails_plugins/rspec/stories/resources/steps/running_rspec.rb
picolena-0.1.0 rails_plugins/rspec/stories/resources/steps/running_rspec.rb
picolena-0.1.2 rails_plugins/rspec/stories/resources/steps/running_rspec.rb
picolena-0.1.3 rails_plugins/rspec/stories/resources/steps/running_rspec.rb
picolena-0.1.4 rails_plugins/rspec/stories/resources/steps/running_rspec.rb