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.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/rspec_log.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19420919cee4a7ed0e7b7ade984eade47ec57293
|
4
|
+
data.tar.gz: 2166fc4c245e7af3c75b0c8939d8ad10936c0bd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
22
|
+
RSpecLog.add_to_log('Name log', 'context info')
|
22
23
|
```
|
data/lib/rspec_log.rb
CHANGED
@@ -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
|
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
|
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
|
+
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-
|
11
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|