Module: RSpec::Generator

Defined in:
lib/generator-spec/rspec/macro.rb,
lib/generator-spec/rspec/generator.rb,
lib/generator-spec/rspec/generator/require.rb,
lib/generator-spec/rspec/generator/configure.rb,
lib/generator-spec/rspec/generator/test_case.rb

Defined Under Namespace

Modules: Configure, Macro, Require Classes: TestCase

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.debugObject

Returns the value of attribute debug.



9
10
11
# File 'lib/generator-spec/rspec/generator.rb', line 9

def debug
  @debug
end

.generatorObject

Returns the value of attribute generator.



9
10
11
# File 'lib/generator-spec/rspec/generator.rb', line 9

def generator
  @generator
end

.logfileObject

Returns the value of attribute logfile.



9
10
11
# File 'lib/generator-spec/rspec/generator.rb', line 9

def logfile
  @logfile
end

.loggerObject

Returns the value of attribute logger.



9
10
11
# File 'lib/generator-spec/rspec/generator.rb', line 9

def logger
  @logger
end

.remove_temp_dirObject

Returns the value of attribute remove_temp_dir.



9
10
11
# File 'lib/generator-spec/rspec/generator.rb', line 9

def remove_temp_dir
  @remove_temp_dir
end

.test_method_nameObject

Returns the value of attribute test_method_name.



9
10
11
# File 'lib/generator-spec/rspec/generator.rb', line 9

def test_method_name
  @test_method_name
end

Class Method Details

.configure(&block) ⇒ Object



2
3
4
5
6
7
# File 'lib/generator-spec/rspec/generator/configure.rb', line 2

def self.configure &block
  conf = RSpec::Generator::Configure
  if block
    block.arity < 1 ? conf.instance_eval(&block) : block.call(conf, self)  
  end      
end

.debug?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/generator-spec/rspec/generator.rb', line 11

def debug?
  debug
end

.info(msg) ⇒ Object



15
16
17
# File 'lib/generator-spec/rspec/generator.rb', line 15

def info msg
  Rails.logger.info(msg) if debug?
end

.remove_rails_dir!Object



19
20
21
# File 'lib/generator-spec/rspec/generator.rb', line 19

def remove_rails_dir!
  FileUtils.rm_rf ::TmpRails.root
end

.run_generator(*args, &block) ⇒ Object



23
24
25
26
27
28
# File 'lib/generator-spec/rspec/generator.rb', line 23

def run_generator *args, &block
  generator.run_generator *args
  if block
    block.arity < 1 ? generator.instance_eval(&block) : block.call(generator, self)  
  end      
end

.setup_generator(test_method_name, &block) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/generator-spec/rspec/generator.rb', line 34

def setup_generator test_method_name, &block
  info "-----------------------------------------------------"
  info "#{Time.now} -- setup generator: [#{test_method_name}]"            
  clean! if test_method_name                                                              
  generator = get_generator(test_method_name) #.extend(Rails::Assist::Generators::BasicHelper)
  if block
    block.arity < 1 ? generator.class.instance_eval(&block) : block.call(generator.class)  
  end
end

.with_generator(&block) ⇒ Object



30
31
32
# File 'lib/generator-spec/rspec/generator.rb', line 30

def with_generator &block
  with(get_generator, &block)
end