everything-core 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6ec10f405f9e3b3bbaf85dba2c298004fb2a0cf8
4
- data.tar.gz: 603c8bf8d70377ab4e613e1489d26e5fbbb35212
2
+ SHA256:
3
+ metadata.gz: 31549f8f23078f98d24bd919d4a8d86c4111c16f1b55f1ac150c1fee8f20fbea
4
+ data.tar.gz: a263ce02a4ed1994348903f3dc65bac7e2d3f1d431126aba9a143c25728c10d3
5
5
  SHA512:
6
- metadata.gz: 7c2420306c0192aae6105c9298954a7ed355e0cfc792ecccf5bd60a016e34ac5164df2ccf7a96e734c1909f9c8e964410405abfbe7402b102ff5f81845559ccb
7
- data.tar.gz: 06b03c77b76c83c908c728abe97ac13478528883cbe6ea8f3ab1431955b99ab1c972342623d06d4643276c280072a060ae9a621c77de5a0a24c464c71e501177
6
+ metadata.gz: f6ca08a99be2b761ba6bdbfcbe188d4c8fd83b51dc3fc399c5183d7049ad678389386ee1b8a41927b41e416ca41a33ac2f619f33aed0d6d5d53ffca9c759a7c4
7
+ data.tar.gz: 8f4b3b5a8ebbf9aa44a14ec632a6bf53dd21af24204d326db6007dbdd8fa6994cd95377ccb144a6fbf4f6267107c5d72a4742538fcb0cb05d47c47a873e0d161
data/Gemfile CHANGED
@@ -3,3 +3,5 @@ source 'https://rubygems.org'
3
3
  # The gem's dependencies are specified in `everything-core.gemspec`.
4
4
  gemspec
5
5
 
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/README.md CHANGED
@@ -102,10 +102,11 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
102
102
  `rake spec` to run the tests. You can also run `bin/console` for an interactive
103
103
  prompt that will allow you to experiment.
104
104
 
105
- To install this gem onto your local machine, run `bundle exec rake install`. To
106
- release a new version, update the version number in `version.rb`, and then run
107
- `bundle exec rake release`, which will create a git tag for the version, push
108
- git commits and tags, and push the `.gem` file to
105
+ To install this gem onto your local machine, run `rake install`. To release
106
+ a new version, update the version number in `lib/everything/version.rb`, and
107
+ commit the version file change. Then you can create a build with `rake build`.
108
+ Then run `rake release`, which will create a git tag for the
109
+ version, push git commits and tags, and push the `.gem` file to
109
110
  [rubygems.org](https://rubygems.org).
110
111
 
111
112
 
data/bin/console CHANGED
@@ -1,16 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'console' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
2
 
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require "rubygems"
14
3
  require "bundler/setup"
4
+ require "everything"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
15
12
 
16
- load Gem.bin_path("everything-core", "console")
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -1,16 +1,6 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'setup' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
8
5
 
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require "rubygems"
14
- require "bundler/setup"
15
-
16
- load Gem.bin_path("everything-core", "setup")
6
+ bundle install
@@ -1,7 +1,4 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'everything/version'
1
+ require_relative 'lib/everything/version'
5
2
 
6
3
  Gem::Specification.new do |spec|
7
4
  spec.name = 'everything-core'
@@ -12,17 +9,25 @@ Gem::Specification.new do |spec|
12
9
  spec.description = %q{Gives you access to pieces within your everything repo.}
13
10
  spec.homepage = 'https://github.com/kyletolle/everything-core'
14
11
  spec.license = 'MIT'
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.1")
15
13
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ['lib']
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = spec.homepage
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
20
25
 
21
26
  spec.add_runtime_dependency 'dotenv', '~> 2.1'
22
27
  spec.add_runtime_dependency 'fastenv', '= 0.0.3'
23
28
 
24
- spec.add_development_dependency 'bundler', '~> 1.11'
25
- spec.add_development_dependency 'rake', '~> 10.5'
29
+ spec.add_development_dependency 'bundler', '~> 2.1'
30
+ spec.add_development_dependency 'rake', '>= 12.3.3'
26
31
  spec.add_development_dependency 'rspec', '~> 3.4'
27
32
  end
28
33
 
@@ -1,3 +1,3 @@
1
1
  module Everything
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everything-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Tolle
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-07 00:00:00.000000000 Z
11
+ date: 2020-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.11'
47
+ version: '2.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.11'
54
+ version: '2.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '10.5'
61
+ version: 12.3.3
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '10.5'
68
+ version: 12.3.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -83,15 +83,7 @@ dependencies:
83
83
  description: Gives you access to pieces within your everything repo.
84
84
  email:
85
85
  - kyle@nullsix.com
86
- executables:
87
- - bundler
88
- - console
89
- - dotenv
90
- - htmldiff
91
- - ldiff
92
- - rake
93
- - rspec
94
- - setup
86
+ executables: []
95
87
  extensions: []
96
88
  extra_rdoc_files: []
97
89
  files:
@@ -104,13 +96,7 @@ files:
104
96
  - LICENSE
105
97
  - README.md
106
98
  - Rakefile
107
- - bin/bundler
108
99
  - bin/console
109
- - bin/dotenv
110
- - bin/htmldiff
111
- - bin/ldiff
112
- - bin/rake
113
- - bin/rspec
114
100
  - bin/setup
115
101
  - everything-core.gemspec
116
102
  - lib/everything.rb
@@ -118,16 +104,12 @@ files:
118
104
  - lib/everything/piece/content.rb
119
105
  - lib/everything/piece/metadata.rb
120
106
  - lib/everything/version.rb
121
- - spec/everything/piece/content_spec.rb
122
- - spec/everything/piece/metadata_spec.rb
123
- - spec/everything/piece_spec.rb
124
- - spec/everything_spec.rb
125
- - spec/spec_helper.rb
126
- - spec/support/pieces.rb
127
107
  homepage: https://github.com/kyletolle/everything-core
128
108
  licenses:
129
109
  - MIT
130
- metadata: {}
110
+ metadata:
111
+ homepage_uri: https://github.com/kyletolle/everything-core
112
+ source_code_uri: https://github.com/kyletolle/everything-core
131
113
  post_install_message:
132
114
  rdoc_options: []
133
115
  require_paths:
@@ -136,22 +118,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
118
  requirements:
137
119
  - - ">="
138
120
  - !ruby/object:Gem::Version
139
- version: '0'
121
+ version: 2.7.1
140
122
  required_rubygems_version: !ruby/object:Gem::Requirement
141
123
  requirements:
142
124
  - - ">="
143
125
  - !ruby/object:Gem::Version
144
126
  version: '0'
145
127
  requirements: []
146
- rubyforge_project:
147
- rubygems_version: 2.6.11
128
+ rubygems_version: 3.1.2
148
129
  signing_key:
149
130
  specification_version: 4
150
131
  summary: Library for working with your `everything` repository.
151
- test_files:
152
- - spec/everything/piece/content_spec.rb
153
- - spec/everything/piece/metadata_spec.rb
154
- - spec/everything/piece_spec.rb
155
- - spec/everything_spec.rb
156
- - spec/spec_helper.rb
157
- - spec/support/pieces.rb
132
+ test_files: []
data/bin/bundler DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'bundler' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require "rubygems"
14
- require "bundler/setup"
15
-
16
- load Gem.bin_path("bundler", "bundler")
data/bin/dotenv DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'dotenv' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require "rubygems"
14
- require "bundler/setup"
15
-
16
- load Gem.bin_path("dotenv", "dotenv")
data/bin/htmldiff DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'htmldiff' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require "rubygems"
14
- require "bundler/setup"
15
-
16
- load Gem.bin_path("diff-lcs", "htmldiff")
data/bin/ldiff DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'ldiff' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require "rubygems"
14
- require "bundler/setup"
15
-
16
- load Gem.bin_path("diff-lcs", "ldiff")
data/bin/rake DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rake' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require "rubygems"
14
- require "bundler/setup"
15
-
16
- load Gem.bin_path("rake", "rake")
data/bin/rspec DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rspec' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require "rubygems"
14
- require "bundler/setup"
15
-
16
- load Gem.bin_path("rspec-core", "rspec")
@@ -1,202 +0,0 @@
1
- require './spec/support/pieces'
2
-
3
- describe Everything::Piece::Content do
4
- shared_context 'with tmp piece markdown file on disk' do
5
- let(:tmp_piece_markdown_path) do
6
- File.join(tmp_piece_path, 'index.md')
7
- end
8
-
9
- let(:given_markdown) do
10
- <<MD
11
- # Piece Title Here
12
-
13
- The body is totally this right here.
14
-
15
- And it might even include multiple lines!
16
- MD
17
- end
18
-
19
- before do
20
- File.open(tmp_piece_markdown_path, 'w') do |markdown_file|
21
- markdown_file.puts given_markdown
22
- end
23
- end
24
- end
25
-
26
- let(:content) do
27
- described_class.new(tmp_piece_path)
28
- end
29
-
30
- describe '#file_name' do
31
- include_context 'with tmp piece on disk'
32
-
33
- let(:expected_file_name) do
34
- 'index.md'
35
- end
36
-
37
- it 'is the markdown file according to everything convention' do
38
- expect(content.file_name).to eq(expected_file_name)
39
- end
40
- end
41
-
42
- describe '#file_path' do
43
- include_context 'with tmp piece on disk'
44
-
45
- let(:expected_file_path) do
46
- "#{tmp_piece_path}/index.md"
47
- end
48
-
49
- it 'is the index.md under the piece' do
50
- expect(content.file_path).to eq(expected_file_path)
51
- end
52
- end
53
-
54
- describe '#title' do
55
- include_context 'with tmp piece on disk'
56
- include_context 'with tmp piece markdown file on disk'
57
-
58
- let(:expected_title) do
59
- 'Piece Title Here'
60
- end
61
-
62
- it 'is the title from the markdown' do
63
- expect(content.title).to eq(expected_title)
64
- end
65
- end
66
-
67
- describe '#body' do
68
- include_context 'with tmp piece on disk'
69
- include_context 'with tmp piece markdown file on disk'
70
-
71
- let(:expected_body) do
72
- <<MD
73
- The body is totally this right here.
74
-
75
- And it might even include multiple lines!
76
- MD
77
- end
78
-
79
- it 'is the body text from the markdown' do
80
- expect(content.body).to eq(expected_body)
81
- end
82
- end
83
-
84
- describe '#raw_markdown' do
85
- include_context 'with tmp piece on disk'
86
- include_context 'with tmp piece markdown file on disk'
87
-
88
- let(:expected_raw_markdown) do
89
- given_markdown
90
- end
91
-
92
- it 'is the markdown from the file' do
93
- expect(content.raw_markdown).to eq(expected_raw_markdown)
94
- end
95
-
96
- it 'memoizes the file read' do
97
- allow(File)
98
- .to receive(:read)
99
- .and_call_original
100
-
101
- 2.times { content.raw_markdown }
102
-
103
- expect(File)
104
- .to have_received(:read)
105
- .exactly(:once)
106
- end
107
- end
108
-
109
- describe '#raw_markdown=' do
110
- include_context 'with tmp piece on disk'
111
-
112
- let(:new_raw_markdown) do
113
- <<MD
114
- # New Markdown
115
-
116
- This is a completely new bit of markdown.
117
- MD
118
- end
119
-
120
- it 'sets the raw_markdown value' do
121
- content.raw_markdown = new_raw_markdown
122
-
123
- expect(content.raw_markdown).to eq(new_raw_markdown)
124
- end
125
- end
126
-
127
- describe '#save' do
128
- let(:tmp_dir) do
129
- Dir.tmpdir
130
- end
131
-
132
- let(:tmp_piece_path) do
133
- File.join(tmp_dir, 'a-test-piece')
134
- end
135
-
136
- before do
137
- content.raw_markdown = "# Ship Shape"
138
- end
139
-
140
- after do
141
- FileUtils.remove_entry(tmp_piece_path)
142
- end
143
-
144
- context 'when the piece directory does not exist' do
145
- it 'creates the folder' do
146
- expect(Dir.exist?(tmp_piece_path)).to eq(false)
147
-
148
- content.save
149
-
150
- expect(Dir.exist?(tmp_piece_path)).to eq(true)
151
- end
152
-
153
- it 'creates the content markdown file' do
154
- expect(File.exist?(content.file_path)).to eq(false)
155
-
156
- content.save
157
-
158
- expect(File.exist?(content.file_path)).to eq(true)
159
- end
160
-
161
- it 'writes the markdown to the file' do
162
- content.save
163
-
164
- expect(File.read(content.file_path)).to eq('# Ship Shape')
165
- end
166
- end
167
-
168
- context 'when the piece directory exists' do
169
- before do
170
- FileUtils.mkdir_p(tmp_piece_path)
171
- end
172
-
173
- context 'when the content file does not exist' do
174
- it 'creates the content markdown file' do
175
- expect(File.exist?(content.file_path)).to eq(false)
176
-
177
- content.save
178
-
179
- expect(File.exist?(content.file_path)).to eq(true)
180
- end
181
-
182
- it 'writes the markdown to the file' do
183
- content.save
184
-
185
- expect(File.read(content.file_path)).to eq('# Ship Shape')
186
- end
187
- end
188
-
189
- context 'when the content file already exists' do
190
- before do
191
- File.write(content.file_path, '# Rolly Polly')
192
- end
193
-
194
- it 'overwrites the file with the correct markdown' do
195
- content.save
196
-
197
- expect(File.read(content.file_path)).to eq('# Ship Shape')
198
- end
199
- end
200
- end
201
- end
202
- end
@@ -1,198 +0,0 @@
1
- require './spec/support/pieces'
2
-
3
- describe Everything::Piece::Metadata do
4
- shared_context 'with tmp piece metadata file on disk' do
5
- let(:tmp_piece_metadata_path) do
6
- File.join(tmp_piece_path, 'index.yaml')
7
- end
8
-
9
- let(:given_yaml) do
10
- <<YAML
11
- ---
12
- public: false
13
- YAML
14
- end
15
-
16
- before do
17
- File.open(tmp_piece_metadata_path, 'w') do |metadata_file|
18
- metadata_file.puts given_yaml
19
- end
20
- end
21
- end
22
-
23
- let(:metadata) do
24
- described_class.new(tmp_piece_path)
25
- end
26
-
27
- describe '#[]' do
28
- include_context 'with tmp piece on disk'
29
-
30
- let(:yaml_double) do
31
- instance_double(Hash)
32
- end
33
- let(:given_key) { 'public' }
34
-
35
- before do
36
- expect(YAML)
37
- .to receive(:load_file)
38
- .and_return(yaml_double)
39
- end
40
-
41
- it 'delegates to the yaml' do
42
- allow(yaml_double)
43
- .to receive(:[])
44
-
45
- metadata[given_key]
46
-
47
- expect(yaml_double)
48
- .to have_received(:[])
49
- .with(given_key)
50
- end
51
- end
52
-
53
- describe '#file_path' do
54
- include_context 'with tmp piece on disk'
55
-
56
- let(:expected_file_path) do
57
- "#{tmp_piece_path}/index.yaml"
58
- end
59
-
60
- it 'is the index.yaml under the piece' do
61
- expect(metadata.file_path).to eq(expected_file_path)
62
- end
63
- end
64
-
65
- describe '#raw_yaml' do
66
- include_context 'with tmp piece on disk'
67
- include_context 'with tmp piece metadata file on disk'
68
-
69
- let(:expected_raw_yaml) do
70
- {
71
- 'public' => false
72
- }
73
- end
74
-
75
- it 'is the yaml as parsed from the file' do
76
- expect(metadata.raw_yaml).to eq(expected_raw_yaml)
77
- end
78
-
79
- it 'memoizes the yaml read' do
80
- allow(YAML)
81
- .to receive(:load_file)
82
- .and_call_original
83
-
84
- metadata.raw_yaml
85
- metadata.raw_yaml
86
-
87
- expect(YAML)
88
- .to have_received(:load_file)
89
- .exactly(:once)
90
- end
91
- end
92
-
93
- describe '#raw_yaml=' do
94
- include_context 'with tmp piece on disk'
95
-
96
- let(:new_raw_yaml) do
97
- <<YAML
98
- ---
99
- public: true
100
- other: okay
101
- YAML
102
- end
103
-
104
- it 'sets the raw_yaml value' do
105
- metadata.raw_yaml = new_raw_yaml
106
-
107
- expect(metadata.raw_yaml).to eq(new_raw_yaml)
108
- end
109
- end
110
-
111
- describe '#save' do
112
- let(:tmp_dir) do
113
- Dir.tmpdir
114
- end
115
-
116
- let(:tmp_piece_path) do
117
- File.join(tmp_dir, 'fake-piece-here')
118
- end
119
-
120
- before do
121
- metadata.raw_yaml = <<YAML
122
- ---
123
- favorite_color: blue
124
- YAML
125
- end
126
-
127
- after do
128
- FileUtils.remove_entry(tmp_piece_path)
129
- end
130
-
131
- context 'when the piece directory does not exist' do
132
- it 'creates the folder' do
133
- expect(Dir.exist?(tmp_piece_path)).to eq(false)
134
-
135
- metadata.save
136
-
137
- expect(Dir.exist?(tmp_piece_path)).to eq(true)
138
- end
139
-
140
- it 'creates the metadata yaml file' do
141
- expect(File.exist?(metadata.file_path)).to eq(false)
142
-
143
- metadata.save
144
-
145
- expect(File.exist?(metadata.file_path)).to eq(true)
146
- end
147
-
148
- it 'writes the yaml to the file' do
149
- metadata.save
150
-
151
- expect(File.read(metadata.file_path)).to eq(<<YAML)
152
- ---
153
- favorite_color: blue
154
- YAML
155
- end
156
- end
157
-
158
- context 'when the piece directory exists' do
159
- before do
160
- FileUtils.mkdir_p(tmp_piece_path)
161
- end
162
-
163
- context 'when the metadata file does not exist' do
164
- it 'creates the metadata yaml file' do
165
- expect(File.exist?(metadata.file_path)).to eq(false)
166
-
167
- metadata.save
168
-
169
- expect(File.exist?(metadata.file_path)).to eq(true)
170
- end
171
-
172
- it 'writes the yaml to the file' do
173
- metadata.save
174
-
175
- expect(File.read(metadata.file_path)).to eq(<<YAML)
176
- ---
177
- favorite_color: blue
178
- YAML
179
- end
180
- end
181
-
182
- context 'when the metadata file already exists' do
183
- before do
184
- File.write(metadata.file_path, "---\nwho: knows")
185
- end
186
-
187
- it 'overwrites the file with the correct yaml' do
188
- metadata.save
189
-
190
- expect(File.read(metadata.file_path)).to eq(<<YAML)
191
- ---
192
- favorite_color: blue
193
- YAML
194
- end
195
- end
196
- end
197
- end
198
- end
@@ -1,195 +0,0 @@
1
- describe Everything::Piece do
2
- let(:given_full_path) do
3
- 'some/fake/path/here-is-our-piece'
4
- end
5
- let(:piece) do
6
- described_class.new(given_full_path)
7
- end
8
-
9
- shared_context 'with content double' do
10
- let(:content_double) do
11
- instance_double(Everything::Piece::Content)
12
- end
13
-
14
- before do
15
- allow(Everything::Piece::Content)
16
- .to receive(:new)
17
- .and_return(content_double)
18
- end
19
- end
20
-
21
- shared_context 'with metadata double' do
22
- let(:metadata_double) do
23
- instance_double(Everything::Piece::Metadata)
24
- end
25
-
26
- before do
27
- allow(Everything::Piece::Metadata)
28
- .to receive(:new)
29
- .and_return(metadata_double)
30
- end
31
- end
32
-
33
- describe '#body' do
34
- include_context 'with content double'
35
-
36
- it 'delegates to the content' do
37
- allow(content_double).to receive(:body)
38
-
39
- piece.body
40
-
41
- expect(content_double).to have_received(:body)
42
- end
43
- end
44
-
45
- describe '#content' do
46
- it 'is an instance of Content' do
47
- expect(piece.content).to be_a(Everything::Piece::Content)
48
- end
49
-
50
- it "is created with the piece's full path" do
51
- expect(Everything::Piece::Content)
52
- .to receive(:new)
53
- .with(given_full_path)
54
-
55
- piece.content
56
- end
57
- end
58
-
59
- describe '#full_path' do
60
- it "returns the piece's full path" do
61
- expect(piece.full_path).to eq(given_full_path)
62
- end
63
- end
64
-
65
- describe '#metadata' do
66
- it 'is an instance of Metadata' do
67
- expect(piece.metadata).to be_a(Everything::Piece::Metadata)
68
- end
69
-
70
- it "is created with the piece's full path" do
71
- expect(Everything::Piece::Metadata)
72
- .to receive(:new)
73
- .with(given_full_path)
74
-
75
- piece.metadata
76
- end
77
- end
78
-
79
- describe '#name' do
80
- let(:expected_name) do
81
- 'here-is-our-piece'
82
- end
83
-
84
- it 'is the last part of the path' do
85
- expect(piece.name).to eq(expected_name)
86
- end
87
- end
88
-
89
- describe '#public?' do
90
- let(:metadata_double) do
91
- instance_double(Everything::Piece::Metadata)
92
- end
93
-
94
- it "returns the metadata's public value" do
95
- allow(Everything::Piece::Metadata)
96
- .to receive(:new)
97
- .and_return(metadata_double)
98
-
99
- expect(metadata_double)
100
- .to receive(:[])
101
- .with('public')
102
- .and_return(false)
103
-
104
- expect(piece.public?).to eq(false)
105
- end
106
- end
107
-
108
- describe '#raw_markdown' do
109
- include_context 'with content double'
110
-
111
- it 'delegates to the content' do
112
- allow(content_double).to receive(:raw_markdown)
113
-
114
- piece.raw_markdown
115
-
116
- expect(content_double).to have_received(:raw_markdown)
117
- end
118
- end
119
-
120
- describe '#raw_markdown=' do
121
- include_context 'with content double'
122
-
123
- it 'delegates to the content' do
124
- allow(content_double).to receive(:raw_markdown=)
125
-
126
- piece.raw_markdown=("# Test markdown")
127
-
128
- expect(content_double)
129
- .to have_received(:raw_markdown=)
130
- .with("# Test markdown")
131
- end
132
- end
133
-
134
- describe '#title' do
135
- include_context 'with content double'
136
-
137
- it 'delegates to the content' do
138
- allow(content_double).to receive(:title)
139
-
140
- piece.title
141
-
142
- expect(content_double).to have_received(:title)
143
- end
144
- end
145
-
146
- describe '#raw_yaml' do
147
- include_context 'with metadata double'
148
-
149
- it 'delegates to the metadata' do
150
- allow(metadata_double).to receive(:raw_yaml)
151
-
152
- piece.raw_yaml
153
-
154
- expect(metadata_double).to have_received(:raw_yaml)
155
- end
156
- end
157
-
158
- describe '#raw_yaml=' do
159
- include_context 'with metadata double'
160
-
161
- it 'delegates to the metadata' do
162
- allow(metadata_double).to receive(:raw_yaml=)
163
-
164
- piece.raw_yaml=("---\nanything: works")
165
-
166
- expect(metadata_double)
167
- .to have_received(:raw_yaml=)
168
- .with("---\nanything: works")
169
- end
170
- end
171
-
172
- describe '#save' do
173
- include_context 'with content double'
174
- include_context 'with metadata double'
175
-
176
- before do
177
- allow(content_double).to receive(:save)
178
- allow(metadata_double).to receive(:save)
179
- end
180
-
181
- it 'calls save on the content' do
182
- piece.save
183
-
184
- expect(content_double)
185
- .to have_received(:save)
186
- end
187
-
188
- it 'calls save on the metadata' do
189
- piece.save
190
-
191
- expect(metadata_double)
192
- .to have_received(:save)
193
- end
194
- end
195
- end
@@ -1,19 +0,0 @@
1
- describe Everything do
2
- it 'has a version number' do
3
- expect(Everything::VERSION).not_to be nil
4
- end
5
-
6
- describe '.path' do
7
- let(:expected_path) do
8
- '/some/path/to/your/everything/repo/'
9
- end
10
-
11
- before do
12
- ENV['EVERYTHING_PATH'] = expected_path
13
- end
14
-
15
- it 'is the path from the environment' do
16
- expect(described_class.path).to eq(expected_path)
17
- end
18
- end
19
- end
data/spec/spec_helper.rb DELETED
@@ -1,99 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'everything'
3
-
4
- # This file was generated by the `rspec --init` command. Conventionally, all
5
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
- # The generated `.rspec` file contains `--require spec_helper` which will cause
7
- # this file to always be loaded, without a need to explicitly require it in any
8
- # files.
9
- #
10
- # Given that it is always loaded, you are encouraged to keep this file as
11
- # light-weight as possible. Requiring heavyweight dependencies from this file
12
- # will add to the boot time of your test suite on EVERY test run, even for an
13
- # individual file that may not need all of that loaded. Instead, consider making
14
- # a separate helper file that requires the additional dependencies and performs
15
- # the additional setup, and require it from the spec files that actually need
16
- # it.
17
- #
18
- # The `.rspec` file also contains a few flags that are not defaults but that
19
- # users commonly want.
20
- #
21
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
- RSpec.configure do |config|
23
- # rspec-expectations config goes here. You can use an alternate
24
- # assertion/expectation library such as wrong or the stdlib/minitest
25
- # assertions if you prefer.
26
- config.expect_with :rspec do |expectations|
27
- # This option will default to `true` in RSpec 4. It makes the `description`
28
- # and `failure_message` of custom matchers include text for helper methods
29
- # defined using `chain`, e.g.:
30
- # be_bigger_than(2).and_smaller_than(4).description
31
- # # => "be bigger than 2 and smaller than 4"
32
- # ...rather than:
33
- # # => "be bigger than 2"
34
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
- end
36
-
37
- # rspec-mocks config goes here. You can use an alternate test double
38
- # library (such as bogus or mocha) by changing the `mock_with` option here.
39
- config.mock_with :rspec do |mocks|
40
- # Prevents you from mocking or stubbing a method that does not exist on
41
- # a real object. This is generally recommended, and will default to
42
- # `true` in RSpec 4.
43
- mocks.verify_partial_doubles = true
44
- end
45
-
46
- # These two settings work together to allow you to limit a spec run
47
- # to individual examples or groups you care about by tagging them with
48
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
- # get run.
50
- config.filter_run :focus
51
- config.run_all_when_everything_filtered = true
52
-
53
- # This setting enables warnings. It's recommended, but in some cases may
54
- # be too noisy due to issues in dependencies.
55
- config.warnings = true
56
-
57
- # Run specs in random order to surface order dependencies. If you find an
58
- # order dependency and want to debug it, you can fix the order by providing
59
- # the seed, which is printed after each run.
60
- # --seed 1234
61
- config.order = :random
62
-
63
- # Seed global randomization in this process using the `--seed` CLI option.
64
- # Setting this allows you to use `--seed` to deterministically reproduce
65
- # test failures related to randomization by passing the same `--seed` value
66
- # as the one that triggered the failure.
67
- Kernel.srand config.seed
68
-
69
- # The settings below are suggested to provide a good initial experience
70
- # with RSpec, but feel free to customize to your heart's content.
71
- =begin
72
- # Limits the available syntax to the non-monkey patched syntax that is
73
- # recommended. For more details, see:
74
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
75
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
76
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
77
- config.disable_monkey_patching!
78
-
79
- # Many RSpec users commonly either run the entire suite or an individual
80
- # file, and it's useful to allow more verbose output when running an
81
- # individual spec file.
82
- if config.files_to_run.one?
83
- # Use the documentation formatter for detailed output,
84
- # unless a formatter has already been configured
85
- # (e.g. via a command-line flag).
86
- config.default_formatter = 'doc'
87
- end
88
-
89
- # Allows RSpec to persist some state between runs in order to support
90
- # the `--only-failures` and `--next-failure` CLI options. We recommend
91
- # you configure your source control system to ignore this file.
92
- config.example_status_persistence_file_path = "spec/examples.txt"
93
-
94
- # Print the 10 slowest examples and example groups at the
95
- # end of the spec run, to help surface which specs are running
96
- # particularly slow.
97
- config.profile_examples = 10
98
- =end
99
- end
@@ -1,13 +0,0 @@
1
- require 'tmpdir'
2
- require 'fileutils'
3
-
4
- RSpec.shared_context 'with tmp piece on disk' do
5
- let!(:tmp_piece_path) do
6
- Dir.mktmpdir
7
- end
8
-
9
- after do
10
- # This will recursively remove everything under that tmp dir.
11
- FileUtils.remove_entry(tmp_piece_path)
12
- end
13
- end