Class: RspecWorld

Inherits:
Object show all
Extended by:
Forwardable
Includes:
RubyForker, Spec::Expectations, Spec::Matchers
Defined in:
lib/vendor/plugins/rspec/features/support/env.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Spec::Matchers

#be, #be_a, #be_a_kind_of, #be_an_instance_of, #be_close, #change, clear_generated_description, #eql, #equal, #exception_from, #exist, #fail, #fail_with, generated_description, #have, #have_at_least, #have_at_most, #include, #map_specs, #match, #method_missing, #raise_error, #respond_to, #run_with, #satisfy, #simple_matcher, #throw_symbol, #with_ruby, #wrap_expectation

Methods included from Spec::Matchers::DSL

#create, #define

Methods included from Spec::Expectations

fail_with

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spec::Matchers

Class Method Details

.cmdline_fileObject



25
26
27
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 25

def self.cmdline_file
  @cmdline_file ||= File.expand_path(File.join(File.dirname(__FILE__), "/../../resources/helpers/cmdline.rb"))
end

.rspec_libObject



29
30
31
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 29

def self.rspec_lib
  @rspec_lib ||= File.join(working_dir, "/../../lib")
end

.spec_commandObject



21
22
23
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 21

def self.spec_command
  @spec_command ||= File.expand_path(File.join(File.dirname(__FILE__), "/../../bin/spec"))
end

.working_dirObject



17
18
19
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 17

def self.working_dir
  @working_dir ||= File.expand_path(File.join(File.dirname(__FILE__), "/../../tmp/cucumber-generated-files"))
end

Instance Method Details

#cmdline(args) ⇒ Object



37
38
39
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 37

def cmdline(args)
  ruby("#{cmdline_file} #{args}")
end

#create_directory(dirname) ⇒ Object



46
47
48
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 46

def create_directory(dirname)
  FileUtils.mkdir_p File.join(working_dir, dirname)
end

#create_file(file_name, contents) ⇒ Object



41
42
43
44
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 41

def create_file(file_name, contents)
  file_path = File.join(working_dir, file_name)
  File.open(file_path, "w") { |f| f << contents }
end

#last_exit_codeObject



58
59
60
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 58

def last_exit_code
  @exit_code
end

#last_stderrObject



54
55
56
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 54

def last_stderr
  @stderr
end

#last_stdoutObject



50
51
52
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 50

def last_stdout
  @stdout
end

#ruby(args) ⇒ Object

it seems like this, and the last_* methods, could be moved into RubyForker– is that being used anywhere but the features?



63
64
65
66
67
68
69
70
71
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 63

def ruby(args)
  stderr_file = Tempfile.new('rspec')
  stderr_file.close
  Dir.chdir(working_dir) do
    @stdout = super("-I #{rspec_lib} #{args}", stderr_file.path)
  end
  @stderr = IO.read(stderr_file.path)
  @exit_code = $?.to_i
end

#spec(args) ⇒ Object



33
34
35
# File 'lib/vendor/plugins/rspec/features/support/env.rb', line 33

def spec(args)
  ruby("#{spec_command} #{args}")
end