Class: Opal::RSpec::ProjectInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/opal/rspec/project_initializer.rb

Overview

Generates conventional files for an rspec project

Constant Summary collapse

DOT_RSPEC_FILE =
'.rspec-opal'
SPEC_HELPER_FILE =
'spec-opal/spec_helper.rb'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ProjectInitializer

Returns a new instance of ProjectInitializer.



13
14
15
16
17
18
19
# File 'lib/opal/rspec/project_initializer.rb', line 13

def initialize(opts={})
  @destination = opts.fetch(:destination, Dir.getwd)
  @stream = opts.fetch(:report_stream, $stdout)
  @template_path = opts.fetch(:template_path) do
    File.expand_path("../project_initializer", __FILE__)
  end
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



8
9
10
# File 'lib/opal/rspec/project_initializer.rb', line 8

def destination
  @destination
end

#streamObject (readonly)

Returns the value of attribute stream.



8
9
10
# File 'lib/opal/rspec/project_initializer.rb', line 8

def stream
  @stream
end

#template_pathObject (readonly)

Returns the value of attribute template_path.



8
9
10
# File 'lib/opal/rspec/project_initializer.rb', line 8

def template_path
  @template_path
end

Instance Method Details

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/opal/rspec/project_initializer.rb', line 21

def run
  puts <<~EOF
    ** Do note, that Opal-RSpec defaults to the following paths:
    ** - config file:    .rspec-opal
    ** - spec directory: spec-opal
    ** - program:        lib-opal
    **
    ** If you want to share Opal specs with Ruby specs, you will
    ** need to put the following into your .rspec-opal:
    **
    ** -Ilib --default-path=spec
  EOF
  copy_template DOT_RSPEC_FILE
  copy_template SPEC_HELPER_FILE
end