rspec_log 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -2
  3. data/lib/rspec_log.rb +6 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74ff9ac6bb582473d587f82ace8e1289608ae9c2
4
- data.tar.gz: 2960b4b3260d6613b809cb56fa178a74c2ce0148
3
+ metadata.gz: 19420919cee4a7ed0e7b7ade984eade47ec57293
4
+ data.tar.gz: 2166fc4c245e7af3c75b0c8939d8ad10936c0bd2
5
5
  SHA512:
6
- metadata.gz: '08db977b213f4fec9f53b756be5324d8602ead0eaf19553255de6aeabff715311d9eaa4f303146ef715a8e231a22161813db5fd8b07e9d13290ddd869002af73'
7
- data.tar.gz: 4082699b29e31ae4b9d956f45b519f280dffb21db206a161a095c8e83a89b98a5304eaefbaebc93f051b52135a1536996e6047c99328e751c75c7fc5bc8af9f6
6
+ metadata.gz: de6e7823baa91dabd50baed731c6febedfb12995acf7b3d4e0d90cba033c0983be6ec063cf4d0be010b4282590b3eb2135698572a5123ed0d1871da7ceb4e3be
7
+ data.tar.gz: 2e0d8b8c84a4c3322b31759380d42381c7943801d510a634fcbb5fbf543587d467c6ce5e863fec62e10fd019bd9ff2d973dbb18cbdf5bbf5727afb523651bf46
data/README.md CHANGED
@@ -7,6 +7,8 @@ gem 'rspec_log'
7
7
 
8
8
  Setup the test this way in your spec_helper.rb file:
9
9
  ```ruby
10
+ require 'rspec_log'
11
+
10
12
  config.before :suite do
11
13
  logs = RSpecLog.new(newfile: true) # newfile clears the file if it exists
12
14
  end
@@ -15,8 +17,7 @@ config.after :all do
15
17
  logs.write_file
16
18
  end
17
19
 
18
- at_exit { RSpecLog.print_logs_from_file }
19
20
  ```
20
21
  ```ruby
21
- RSpecLog.add_to_log 'Name log', 'context info'
22
+ RSpecLog.add_to_log('Name log', 'context info')
22
23
  ```
@@ -6,19 +6,23 @@ DEFAULT_LOG_FILE = '.rspec_log.yml'.freeze
6
6
  # Class that allows for displaying logs or general messages at that are consistent across rspec tests
7
7
  class RSpecLog
8
8
  def initialize(filename: DEFAULT_LOG_FILE, newfile: false)
9
+ raise 'RSpec must be defined to create RSpec log' if (defined? RSpec).nil?
10
+
9
11
  @filename = filename
10
12
  RSpecLog.write_hash_to_file({}, @filename) if newfile || !File.exist?(filename)
11
13
  RSpecLog.log_hash_set(YAML.load_file(@filename))
14
+
15
+ at_exit { RSpecLog.print_logs_from_file }
12
16
  end
13
17
 
14
18
  # Writes log_hash to, by default, currently set log file or custom file passed to it
15
- def write_file(filename = @filename)
19
+ def write_file(filename: @filename)
16
20
  raise 'Filename is not set, you need to initialize RSpecLog before writing' if filename.nil?
17
21
  RSpecLog.write_hash_to_file(RSpecLog.log_hash, filename)
18
22
  end
19
23
 
20
24
  # Parse the YAML log file and print it out in a nice manner
21
- def self.print_logs_from_file(filename = DEFAULT_LOG_FILE)
25
+ def self.print_logs_from_file(filename: DEFAULT_LOG_FILE)
22
26
  file_contents = YAML.load_file(filename)
23
27
 
24
28
  return puts 'No logs found'.green if file_contents.empty?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Capri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-25 00:00:00.000000000 Z
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake