Class: Rspec2db

Inherits:
RSpec::Core::Formatters::BaseTextFormatter
  • Object
show all
Includes:
DBUtils, RSpecConfigurationHelper
Defined in:
lib/rspec2db.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RSpecConfigurationHelper

check_rspec_options, #extract_rspec_core_version, generate_local_config, insert_rspec2db_formatter, load_config, load_local_config, #load_snippet_extractor, override_default_config, #print_example_failed_content

Methods included from DBUtils

build_stats, #connect_to_db, create_rspec_db, #create_test_case, #create_test_run, #create_test_suite, migrate_rspec_db, #update_test_run

Constructor Details

#initialize(output) ⇒ Rspec2db

Returns a new instance of Rspec2db.



34
35
36
37
38
39
40
41
42
# File 'lib/rspec2db.rb', line 34

def initialize(output)
  @output = output || StringIO.new
  @global_file_lock = '/tmp/rspec2db.lock'
  @config = RSpecConfigurationHelper.load_config
  connect_to_db @config
  @test_suite = create_test_suite(@config)
  @test_run = create_test_run(@test_suite, @config)
  @screenshot_event = {}
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



25
26
27
# File 'lib/rspec2db.rb', line 25

def config
  @config
end

#example_groupObject (readonly)

Returns the value of attribute example_group.



25
26
27
# File 'lib/rspec2db.rb', line 25

def example_group
  @example_group
end

#global_file_lockObject (readonly)

Returns the value of attribute global_file_lock.



25
26
27
# File 'lib/rspec2db.rb', line 25

def global_file_lock
  @global_file_lock
end

#outputObject (readonly)

Returns the value of attribute output.



25
26
27
# File 'lib/rspec2db.rb', line 25

def output
  @output
end

#resultsObject (readonly)

Returns the value of attribute results.



25
26
27
# File 'lib/rspec2db.rb', line 25

def results
  @results
end

#test_runObject (readonly)

Returns the value of attribute test_run.



25
26
27
# File 'lib/rspec2db.rb', line 25

def test_run
  @test_run
end

#test_suiteObject (readonly)

Returns the value of attribute test_suite.



25
26
27
# File 'lib/rspec2db.rb', line 25

def test_suite
  @test_suite
end

Instance Method Details

#dump_failures(notification) ⇒ Object



82
83
# File 'lib/rspec2db.rb', line 82

def dump_failures(notification)
end

#dump_pending(notification) ⇒ Object



76
77
# File 'lib/rspec2db.rb', line 76

def dump_pending(notification)
end

#dump_profile(notification) ⇒ Object



79
80
# File 'lib/rspec2db.rb', line 79

def dump_profile(notification)
end

#dump_summary(notification) ⇒ Object



99
100
101
# File 'lib/rspec2db.rb', line 99

def dump_summary(notification)
  update_test_run(@test_run, notification, @global_file_lock)
end

#example_failed(notification) ⇒ Object



66
67
68
# File 'lib/rspec2db.rb', line 66

def example_failed(notification)
  @current_test_case = create_test_case(@test_run, @example_group, notification.example, @config['options']['backtrace'], @screenshot_event)
end

#example_group_finished(notification) ⇒ Object



51
52
# File 'lib/rspec2db.rb', line 51

def example_group_finished(notification)
end

#example_group_started(notification) ⇒ Object



47
48
49
# File 'lib/rspec2db.rb', line 47

def example_group_started(notification)
  @example_group = notification.group
end

#example_passed(notification) ⇒ Object



57
58
59
60
# File 'lib/rspec2db.rb', line 57

def example_passed(notification)
  
  @current_test_case = create_test_case(@test_run, @example_group, notification.example, @config['options']['backtrace'], @screenshot_event)
end

#example_pending(notification) ⇒ Object



62
63
64
# File 'lib/rspec2db.rb', line 62

def example_pending(notification)
  @current_test_case = create_test_case(@test_run, @example_group, notification.example, @config['options']['backtrace'], @screenshot_event)
end

#example_started(example) ⇒ Object



54
55
# File 'lib/rspec2db.rb', line 54

def example_started(example)
end

#message(notification) ⇒ Object



70
71
# File 'lib/rspec2db.rb', line 70

def message(notification)
end

#screenshot_saved(notification) ⇒ Object



85
86
87
88
89
90
# File 'lib/rspec2db.rb', line 85

def screenshot_saved(notification)
  @screenshot_event.merge!(
    screenshot_path: notification[:screenshot_path],
    example: notification[:example]
  )
end

#screenshot_uploaded(notification) ⇒ Object



92
93
94
95
96
97
# File 'lib/rspec2db.rb', line 92

def screenshot_uploaded(notification)
  @screenshot_event.merge!(
    screenshot_url: notification[:screenshot_url],
    example: notification[:example]
  )
end

#seed(seed) ⇒ Object



103
104
# File 'lib/rspec2db.rb', line 103

def seed(seed)
end

#start(notification) ⇒ Object



44
45
# File 'lib/rspec2db.rb', line 44

def start(notification)
end

#start_dump(notification) ⇒ Object



73
74
# File 'lib/rspec2db.rb', line 73

def start_dump(notification)
end