warp-dir 1.1.0 → 1.1.1

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
2
  SHA1:
3
- metadata.gz: daa0b8f3d4f2854f1cb925278c911c4e16421337
4
- data.tar.gz: e1efe07eb17d0e598cac69c54931b41e0b2cef84
3
+ metadata.gz: 038c1bf836f10b44823ae7fdc6acbafb1ed9d356
4
+ data.tar.gz: dd8a492fc4f52bf96f38aa385f5d9a67a37a44ed
5
5
  SHA512:
6
- metadata.gz: f6e61ed9ddb3a12d51379c3e1a705cd0ce28047d0fc53a3b3b28487448e9f7c8faa4542c38470555a9ea4b77c8c56441206cebb70f0cf18475523e26d99da561
7
- data.tar.gz: fab101991fdc54788398109ccadb3aa4d0b10d9fa8fbbb75fc4b992f05f6d47796a18d4327565b202afdf621e5e1f63e00fcf07dae65b4a62a2d560d2e2f2cc8
6
+ metadata.gz: bbf7666d599530708775ae4cada2604c8244ca8e175af66f64c89f0bced139ec40a5c7394630599be08c0ed65e73832ce5160a165644d20a6e2c9017c63cd220
7
+ data.tar.gz: 9ae73bb486069adcae90e411e48266f97dfa2c6b5b99e34f085c4cbdfb2758c891d0714c0ffe150dbd15a9a567194802d592dfbe30511d7f027c3c9d453ca707
data/.idea/warp-dir.iml CHANGED
@@ -10,27 +10,38 @@
10
10
  </facet>
11
11
  </component>
12
12
  <component name="ModuleRunConfigurationManager">
13
- <configuration default="false" name="IRB console: warp-dir" type="IrbRunConfigurationType" factoryName="IRB console" temporary="true">
13
+ <configuration default="false" name="All Specs" type="RSpecRunConfigurationType" factoryName="RSpec">
14
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
14
15
  <module name="warp-dir" />
15
- <IRB_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
16
- <IRB_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$" />
17
- <IRB_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
18
- <IRB_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
19
- <IRB_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
16
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
17
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
18
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
19
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
20
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
20
21
  <envs />
21
- <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
22
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
22
23
  <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
23
24
  <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
24
25
  <COVERAGE_PATTERN ENABLED="true">
25
26
  <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
26
27
  </COVERAGE_PATTERN>
27
28
  </EXTENSION>
28
- <IRB_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$APPLICATION_HOME_DIR$/rb/testing/runner/irb.rb" />
29
- <IRB_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="--prompt simple" />
30
- <IRB_RUN_CONFIG NAME="IS_RAILS_CONSOLE" VALUE="false" />
29
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="$MODULE_DIR$/spec" />
30
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
31
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
32
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
33
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
34
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="ALL_IN_FOLDER" />
35
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
36
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
37
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
38
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
39
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
40
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
41
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="true" />
31
42
  <method />
32
43
  </configuration>
33
- <configuration default="false" name="All Specs" type="RSpecRunConfigurationType" factoryName="RSpec">
44
+ <configuration default="false" name="Run spec 'store_spec': warp-dir" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
34
45
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
35
46
  <module name="warp-dir" />
36
47
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -38,7 +49,9 @@
38
49
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
39
50
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
40
51
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
41
- <envs />
52
+ <envs>
53
+ <env name="JRUBY_OPTS" value="-X+O" />
54
+ </envs>
42
55
  <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
43
56
  <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
44
57
  <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
@@ -46,22 +59,22 @@
46
59
  <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
47
60
  </COVERAGE_PATTERN>
48
61
  </EXTENSION>
49
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="$MODULE_DIR$/spec" />
50
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
62
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
63
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/warp/dir/store_spec.rb" />
51
64
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
52
65
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
53
66
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
54
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="ALL_IN_FOLDER" />
67
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
55
68
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
56
69
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
57
70
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
58
71
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
59
72
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
60
73
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
61
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="true" />
74
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
62
75
  <method />
63
76
  </configuration>
64
- <configuration default="false" name="Warp::Dir::Command::Install#run when shell files do not exist should return :error type response: warp-dir" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
77
+ <configuration default="false" name="Warp::Dir::Store with no existin warprc file creates the file when adding points: warp-dir" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
65
78
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
66
79
  <module name="warp-dir" />
67
80
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -80,10 +93,10 @@
80
93
  </COVERAGE_PATTERN>
81
94
  </EXTENSION>
82
95
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
83
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/warp/dir/commands/install_spec.rb" />
96
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/warp/dir/store_spec.rb" />
84
97
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
85
98
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
86
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Warp::Dir::Command::Install#run when shell files do not exist should return :error type response" />
99
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Warp::Dir::Store with no existin warprc file creates the file when adding points" />
87
100
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
88
101
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
89
102
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
@@ -94,7 +107,7 @@
94
107
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
95
108
  <method />
96
109
  </configuration>
97
- <configuration default="false" name="Warp::Dir::App::CLI: warp-dir" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
110
+ <configuration default="false" name="Warp::Dir::Store: warp-dir" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
98
111
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
99
112
  <module name="warp-dir" />
100
113
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -113,10 +126,10 @@
113
126
  </COVERAGE_PATTERN>
114
127
  </EXTENSION>
115
128
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
116
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/warp/dir/commands/install_spec.rb" />
129
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/warp/dir/store_spec.rb" />
117
130
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
118
131
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
119
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Warp::Dir::Command::Install" />
132
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Warp::Dir::Store" />
120
133
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
121
134
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
122
135
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
@@ -127,7 +140,7 @@
127
140
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
128
141
  <method />
129
142
  </configuration>
130
- <configuration default="false" name="Warp::Dir::App::CLI when running command with a point arg, such as ls &lt;point&gt; no flags should default to -al: warp-dir" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
143
+ <configuration default="false" name="Warp::Dir::App::CLI: warp-dir" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
131
144
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
132
145
  <module name="warp-dir" />
133
146
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -149,7 +162,7 @@
149
162
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/warp/dir/app/cli_spec.rb" />
150
163
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
151
164
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
152
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Warp::Dir::App::CLI when running command with a point arg, such as ls &lt;point&gt; no flags should default to -al" />
165
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Warp::Dir::App::CLI" />
153
166
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
154
167
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
155
168
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
@@ -160,7 +173,7 @@
160
173
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
161
174
  <method />
162
175
  </configuration>
163
- <configuration default="false" name="Warp::Dir::App::CLI: warp-dir (1)" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
176
+ <configuration default="false" name="Warp::Dir::App::CLI when running command with a point arg, such as add &lt;point&gt; when point exists with --force should overwrite existing point: warp-dir" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
164
177
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
165
178
  <module name="warp-dir" />
166
179
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -182,7 +195,7 @@
182
195
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/warp/dir/app/cli_spec.rb" />
183
196
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
184
197
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
185
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Warp::Dir::App::CLI" />
198
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Warp::Dir::App::CLI when running command with a point arg, such as add &lt;point&gt; when point exists with --force should overwrite existing point" />
186
199
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
187
200
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
188
201
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
@@ -5,8 +5,16 @@ module Warp
5
5
  module Serializer
6
6
  class Dotfile < Base
7
7
 
8
+ def warprc_file_path
9
+ Warp::Dir.absolute(config.warprc)
10
+ end
11
+
8
12
  def restore!
9
- File.open(Warp::Dir.absolute(config.warprc), "r") do |f|
13
+ unless File.exist?(warprc_file_path)
14
+ STDERR.puts "No warprc file found in the path #{warprc_file_path}" if config.debug
15
+ return
16
+ end
17
+ File.open(warprc_file_path, 'r') do |f|
10
18
  f.each_line do |line|
11
19
  line = line.chomp
12
20
  next if line.blank?
@@ -20,7 +28,7 @@ module Warp
20
28
  end
21
29
 
22
30
  def persist!
23
- File.open(Warp::Dir.absolute(config.warprc), 'w') do |file|
31
+ File.open(warprc_file_path, 'wt') do |file|
24
32
  buffer = ''
25
33
  store.points.each do |point|
26
34
  buffer << "#{point.name}:#{point.relative_path}\n"
@@ -1,6 +1,6 @@
1
1
  module Warp
2
2
  module Dir
3
- VERSION = '1.1.0'
3
+ VERSION = '1.1.1'
4
4
  end
5
5
  end
6
6
 
data/spec/spec_helper.rb CHANGED
@@ -31,12 +31,13 @@ end
31
31
  RSpec.configure do |config|
32
32
  config.before do
33
33
  Warp::Dir::App::Response.disable_exit!
34
+ srand 117
34
35
  end
35
36
  end
36
37
 
37
38
  RSpec.shared_context :fake_serializer do
38
39
  let(:file) { @file ||= ::Tempfile.new('warp-dir') }
39
- let(:config) { Warp::Dir::Config.new(config: file.path) }
40
+ let(:config) { Warp::Dir::Config.new(warprc: file.path) }
40
41
  let(:serializer) {
41
42
  @initialized_store ||= FakeSerializer ||= Class.new(Warp::Dir::Serializer::Base) do
42
43
  def persist!;
@@ -55,12 +56,13 @@ end
55
56
 
56
57
  RSpec.shared_context :fixture_file do
57
58
  let(:fixture_file) { 'spec/fixtures/warprc'}
59
+ let(:warprc_args) { " --config #{fixture_file}" }
58
60
  let(:config_path) { '/tmp/warprc' }
59
61
  let(:file) {
60
62
  FileUtils.cp(fixture_file, config_path)
61
63
  File.new(config_path)
62
64
  }
63
- let(:config) { Warp::Dir::Config.new(config: file.path) }
65
+ let(:config) { Warp::Dir::Config.new(warprc: file.path) }
64
66
  end
65
67
 
66
68
  RSpec.shared_context :initialized_store do
@@ -13,7 +13,7 @@ RSpec.describe Warp::Dir::Command::Install do
13
13
 
14
14
  context 'when shell files do not exist' do
15
15
  it 'should return :error type response' do
16
- expect('install --dotfile ~/.do_not_exist').to output(/not found/)
16
+ expect("install #{warprc_args} --dotfile ~/.do_not_exist").to output(/not found/)
17
17
  end
18
18
  end
19
19
  end
@@ -5,100 +5,125 @@ require 'warp/dir/store'
5
5
  require 'tempfile'
6
6
 
7
7
  RSpec.describe Warp::Dir::Store do
8
- include_context :fake_serializer
9
- include_context :initialized_store
10
8
 
11
- context 'when store responds to common methods on collections' do
12
- let(:point_name) { 'moo' }
13
- let(:point_path) { ENV['HOME'] + '/tmp/12398485' }
9
+ describe 'with no existin warprc file' do
10
+ let(:config_path) { "/tmp/warprc#{srand()}" }
11
+ let(:config) { Warp::Dir::Config.new(warprc: config_path) }
14
12
  let(:store) { Warp::Dir::Store.new(config) }
15
- let(:p1) { Warp::Dir::Point.new('p', ENV['HOME'] + '/workspace') }
16
- let(:p2) { Warp::Dir::Point.new('n', ENV['HOME'] + '/workspace/new-project') }
17
13
 
18
- it 'should be able to have an empty store' do
19
- expect(store.points).to be_empty
14
+ after do
15
+ File.unlink(config_path) if File.exists?(config_path)
20
16
  end
21
17
 
22
- it 'should respond to #size and return 0' do
23
- expect(store.size).to eql(0)
18
+ it 'does not fail for find requests' do
19
+ expect(File.exist?(config.warprc)).to be_falsey, config.warprc
20
+ expect { store['mypoint'] }.to raise_error(Warp::Dir::Errors::PointNotFound)
24
21
  end
25
22
 
26
- it 'it should respond to #<< and add a new point' do
27
- store.add(point: p1)
28
- store.add(point: p2)
29
- store << Warp::Dir::Point.new('123', '436')
30
- expect(store.size).to eql(3)
23
+ it 'creates the file when adding points' do
24
+ expect(File.exist?(config.warprc)).to be_falsey, config.warprc
25
+ expect(store.size).to eql(0)
26
+ store.add(point_name: 'mypoint', point_path: '/tmp')
27
+ expect(File.exist?(config.warprc)).to be_falsey, config.warprc
31
28
  end
32
29
  end
33
30
 
34
- context 'when the data storeis empty' do
35
- let(:point_name) { 'moo' }
36
- let(:point_path) { ENV['HOME'] + '/tmp/12398485' }
37
- let(:store) { Warp::Dir::Store.new(config) }
31
+ describe 'with an exiting warprc file' do
32
+ include_context :fake_serializer
33
+ include_context :initialized_store
38
34
 
39
- it 'should be able to initialize the Store' do
40
- expect(store.points).to be_empty
41
- end
35
+ context 'when store responds to common methods on collections' do
36
+ let(:point_name) { 'moo' }
37
+ let(:point_path) { ENV['HOME'] + '/tmp/12398485' }
38
+ let(:store) { Warp::Dir::Store.new(config) }
39
+ let(:p1) { Warp::Dir::Point.new('p', ENV['HOME'] + '/workspace') }
40
+ let(:p2) { Warp::Dir::Point.new('n', ENV['HOME'] + '/workspace/new-project') }
42
41
 
43
- it 'should respond to #size and return 0' do
44
- expect(store.size).to eql(0)
45
- end
42
+ it 'should be able to have an empty store' do
43
+ expect(store.points).to be_empty
44
+ end
46
45
 
47
- it 'it should respond to #<< and add a new point' do
48
- expect(store.size).to eql(0)
49
- store << Warp::Dir::Point.new('123', '436')
50
- expect(store.size).to eql(1)
51
- end
46
+ it 'should respond to #size and return 0' do
47
+ expect(store.size).to eql(0)
48
+ end
52
49
 
53
- it 'should be able to add a new point to the Store' do
54
- store.add(point_name: point_name, point_path: point_path)
55
- corrected_path = Warp::Dir.absolute point_path
56
- expect(store[point_name].path).to eql(corrected_path)
50
+ it 'it should respond to #<< and add a new point' do
51
+ store.add(point: p1)
52
+ store.add(point: p2)
53
+ store << Warp::Dir::Point.new('123', '436')
54
+ expect(store.size).to eql(3)
55
+ end
57
56
  end
58
57
 
59
- it 'should not be able to add a different point with the same name' do
60
- store.add(point_name: point_name, point_path: point_path)
61
- # double adding the same point is ok
62
- expect { store.add(point_name: point_name, point_path: point_path) }.to_not raise_error
63
- # adding another point pointing to the same name is not OK
64
- expect { store.add(point_name: point_name, point_path: point_path + '98984') }.to raise_error(Warp::Dir::Errors::PointAlreadyExists)
65
- end
58
+ context 'when the data storeis empty' do
59
+ let(:point_name) { 'moo' }
60
+ let(:point_path) { ENV['HOME'] + '/tmp/12398485' }
61
+ let(:store) { Warp::Dir::Store.new(config) }
66
62
 
67
- it 'should be able to add multiple points to the Store' do
68
- store.add(point_name: 'm1', point_path: '123')
69
- store.add(point_name: 'm2', point_path: '456')
70
- expect(store['m1'].path).to eql('123')
71
- expect(store['m2'].path).to eql('456')
72
- end
73
- end
63
+ it 'should be able to initialize the Store' do
64
+ expect(store.points).to be_empty
65
+ end
74
66
 
75
- context 'data store contains some warp points already' do
76
- let(:store) { Warp::Dir::Store.new(config) }
77
- before do
78
- store.add(point_name: 'm1', point_path: 'A1')
79
- store.add(point_name: 'm2', point_path: 'A2')
80
- store.save!
81
- end
67
+ it 'should respond to #size and return 0' do
68
+ expect(store.size).to eql(0)
69
+ end
82
70
 
83
- describe 'reading data' do
84
- let(:new_store) { Warp::Dir::Store.new(config) }
71
+ it 'it should respond to #<< and add a new point' do
72
+ expect(store.size).to eql(0)
73
+ store << Warp::Dir::Point.new('123', '436')
74
+ expect(store.size).to eql(1)
75
+ end
85
76
 
86
- it 'should restore correctly compared to last saved' do
87
- expect(new_store['m1'].path).to eql('A1')
88
- expect(new_store['m2'].path).to eql('A2')
77
+ it 'should be able to add a new point to the Store' do
78
+ store.add(point_name: point_name, point_path: point_path)
79
+ corrected_path = Warp::Dir.absolute point_path
80
+ expect(store[point_name].path).to eql(corrected_path)
89
81
  end
90
82
 
91
- it 'should not allow overwriting without a force flag' do
83
+ it 'should not be able to add a different point with the same name' do
84
+ store.add(point_name: point_name, point_path: point_path)
85
+ # double adding the same point is ok
86
+ expect { store.add(point_name: point_name, point_path: point_path) }.to_not raise_error
92
87
  # adding another point pointing to the same name is not OK
93
- expect { new_store.add(point_name: 'm1', point_path: '98984') }.to raise_error(Warp::Dir::Errors::PointAlreadyExists)
88
+ expect { store.add(point_name: point_name, point_path: point_path + '98984') }.to raise_error(Warp::Dir::Errors::PointAlreadyExists)
94
89
  end
95
90
 
96
- it 'should be able to find previously saved item' do
97
- expect(new_store['m1']).to eql(Warp::Dir::Point.new('m1', 'A1'))
91
+ it 'should be able to add multiple points to the Store' do
92
+ store.add(point_name: 'm1', point_path: '123')
93
+ store.add(point_name: 'm2', point_path: '456')
94
+ expect(store['m1'].path).to eql('123')
95
+ expect(store['m2'].path).to eql('456')
98
96
  end
97
+ end
98
+
99
+ context 'data store contains some warp points already' do
100
+ let(:store) { Warp::Dir::Store.new(config) }
101
+ before do
102
+ store.add(point_name: 'm1', point_path: 'A1')
103
+ store.add(point_name: 'm2', point_path: 'A2')
104
+ store.save!
105
+ end
106
+
107
+ describe 'reading data' do
108
+ let(:new_store) { Warp::Dir::Store.new(config) }
109
+
110
+ it 'should restore correctly compared to last saved' do
111
+ expect(new_store['m1'].path).to eql('A1')
112
+ expect(new_store['m2'].path).to eql('A2')
113
+ end
114
+
115
+ it 'should not allow overwriting without a force flag' do
116
+ # adding another point pointing to the same name is not OK
117
+ expect { new_store.add(point_name: 'm1', point_path: '98984') }.to raise_error(Warp::Dir::Errors::PointAlreadyExists)
118
+ end
119
+
120
+ it 'should be able to find previously saved item' do
121
+ expect(new_store['m1']).to eql(Warp::Dir::Point.new('m1', 'A1'))
122
+ end
99
123
 
100
- it 'should be able to handle when it doesnt find a given element' do
101
- expect { new_store['ASDSADAS'] }.to raise_error(Warp::Dir::Errors::PointNotFound)
124
+ it 'should be able to handle when it doesnt find a given element' do
125
+ expect { new_store['ASDSADAS'] }.to raise_error(Warp::Dir::Errors::PointNotFound)
126
+ end
102
127
  end
103
128
  end
104
129
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warp-dir
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul