fig 2.0.0.pre.alpha.3 → 2.0.0.pre.alpha.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fig/application_configuration.rb +2 -1
  3. data/lib/fig/command/options/parser.rb +4 -2
  4. data/lib/fig/command/options.rb +1 -1
  5. data/lib/fig/command.rb +17 -8
  6. data/lib/fig/figrc.rb +41 -14
  7. data/lib/fig/protocol/file.rb +3 -1
  8. data/lib/fig/protocol/ftp.rb +5 -5
  9. data/lib/fig/repository.rb +15 -11
  10. data/lib/fig/spec_utils.rb +312 -0
  11. data/lib/fig/url_access_disallowed_error.rb +5 -0
  12. data/lib/fig/version.rb +1 -1
  13. data/spec/application_configuration_spec.rb +73 -0
  14. data/spec/command/clean_spec.rb +62 -0
  15. data/spec/command/command_line_vs_package_spec.rb +32 -0
  16. data/spec/command/dump_package_definition_spec.rb +104 -0
  17. data/spec/command/environment_variables_spec.rb +62 -0
  18. data/spec/command/grammar_asset_spec.rb +391 -0
  19. data/spec/command/grammar_command_spec.rb +88 -0
  20. data/spec/command/grammar_environment_variable_spec.rb +384 -0
  21. data/spec/command/grammar_retrieve_spec.rb +74 -0
  22. data/spec/command/grammar_spec.rb +87 -0
  23. data/spec/command/grammar_spec_helper.rb +23 -0
  24. data/spec/command/include_file_spec.rb +73 -0
  25. data/spec/command/listing_spec.rb +1574 -0
  26. data/spec/command/miscellaneous_spec.rb +145 -0
  27. data/spec/command/publish_local_and_updates_spec.rb +32 -0
  28. data/spec/command/publishing_retrieval_spec.rb +423 -0
  29. data/spec/command/publishing_spec.rb +596 -0
  30. data/spec/command/running_commands_spec.rb +354 -0
  31. data/spec/command/suppress_includes_spec.rb +65 -0
  32. data/spec/command/suppress_warning_include_statement_missing_version_spec.rb +134 -0
  33. data/spec/command/update_lock_response_spec.rb +47 -0
  34. data/spec/command/usage_errors_spec.rb +481 -0
  35. data/spec/command_options_spec.rb +184 -0
  36. data/spec/command_spec.rb +49 -0
  37. data/spec/deparser/v1_spec.rb +64 -0
  38. data/spec/environment_variables_spec.rb +91 -0
  39. data/spec/figrc_spec.rb +144 -0
  40. data/spec/parser_spec.rb +398 -0
  41. data/spec/repository_spec.rb +117 -0
  42. data/spec/runtime_environment_spec.rb +357 -0
  43. data/spec/spec_helper.rb +1 -0
  44. data/spec/split_repo_url_spec.rb +190 -0
  45. data/spec/statement/asset_spec.rb +203 -0
  46. data/spec/statement/configuration_spec.rb +41 -0
  47. data/spec/support/formatters/seed_spitter.rb +12 -0
  48. data/spec/working_directory_maintainer_spec.rb +102 -0
  49. metadata +58 -7
@@ -0,0 +1,73 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
+
5
+ require 'fig/application_configuration'
6
+
7
+ REPOSITORY_TEST_URL = 'http://example.com'
8
+ WHITELIST_TEST_URL = 'http://foo.com'
9
+
10
+ describe 'ApplicationConfiguration' do
11
+ def new_configuration()
12
+ config = Fig::ApplicationConfiguration.new
13
+
14
+ config.base_whitelisted_url = REPOSITORY_TEST_URL
15
+ config.remote_download_url = REPOSITORY_TEST_URL
16
+ config.remote_upload_url = REPOSITORY_TEST_URL
17
+
18
+ return config
19
+ end
20
+
21
+ it 'allows arbitrary urls when there is no whitelist' do
22
+ config = new_configuration
23
+ config.url_access_allowed?('').should == true
24
+ end
25
+
26
+ it 'allows the repo url when whitelist is empty' do
27
+ config = new_configuration
28
+ config.push_dataset({'url whitelist' => []})
29
+ config.url_access_allowed?(REPOSITORY_TEST_URL).should == true
30
+ end
31
+
32
+ it 'disallows a non-repo url when whitelist is empty' do
33
+ config = new_configuration
34
+ config.push_dataset({'url whitelist' => []})
35
+ config.url_access_allowed?('').should == false
36
+ end
37
+
38
+ it 'disallows a url that starts with a whitelisted url that is a hostname only' do
39
+ config = new_configuration
40
+ config.push_dataset({'url whitelist' => []})
41
+ config.url_access_allowed?(REPOSITORY_TEST_URL + 'x').should == false
42
+ end
43
+
44
+ it 'allows a full url with empty whitelist' do
45
+ config = new_configuration
46
+ config.push_dataset({'url whitelist' => []})
47
+ config.url_access_allowed?(REPOSITORY_TEST_URL + '/x').should == true
48
+ end
49
+
50
+ it 'allows a url when it\'s on the whitelist' do
51
+ config = new_configuration
52
+ config.push_dataset({'url whitelist' => [REPOSITORY_TEST_URL]})
53
+ config.url_access_allowed?(REPOSITORY_TEST_URL + '/x').should == true
54
+ end
55
+
56
+ it 'disallows a url when it\'s not on the whitelist' do
57
+ config = new_configuration
58
+ config.push_dataset({'url whitelist' => [WHITELIST_TEST_URL]})
59
+ config.url_access_allowed?('http://bar.com' + '/x').should == false
60
+ end
61
+
62
+ it 'disallows a non-repo url when whitelist is not empty' do
63
+ config = new_configuration
64
+ config.push_dataset({'url whitelist' => [WHITELIST_TEST_URL]})
65
+ config.url_access_allowed?('').should == false
66
+ end
67
+
68
+ it 'disallows a url with a different port (but the first part matches)' do
69
+ config = new_configuration
70
+ config.push_dataset({'url whitelist' => [WHITELIST_TEST_URL+':2000']})
71
+ config.url_access_allowed?(WHITELIST_TEST_URL+':20001').should == false
72
+ end
73
+ end
@@ -0,0 +1,62 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ describe 'Fig' do
6
+ describe '--clean' do
7
+ before(:each) do
8
+ clean_up_test_environment
9
+ set_up_test_environment
10
+ cleanup_home_and_remote
11
+ end
12
+
13
+ it 'cleans a named package from the FIG_HOME' do
14
+ fig(%w<--publish foo/1.2.3 --set FOO=BAR>)[2].should == 0
15
+ fig(%w<--clean foo/1.2.3>)[2].should == 0
16
+ fail unless not File.directory? FIG_HOME + '/packages/foo/1.2.3'
17
+ end
18
+
19
+ it 'cleans a named package from the FIG_HOME and does not clean packages differing only by version' do
20
+ input = <<-END
21
+ config default
22
+ set FOO=BAR
23
+ end
24
+ END
25
+ fig(%w<--publish foo/1.2.3>, input)[2].should == 0
26
+ fig(%w<--publish foo/4.5.6>, input)[2].should == 0
27
+ fig(%w<--clean foo/1.2.3>)[2].should == 0
28
+ fail unless File.directory? FIG_HOME + '/packages/foo/4.5.6'
29
+ end
30
+
31
+ it 'should complain if you clean without a package descriptor' do
32
+ out, err, exit_code = fig(%w<--clean>, :no_raise_on_error => true)
33
+ err.should =~ /need to specify a descriptor/i
34
+ exit_code.should_not == 0
35
+ end
36
+
37
+ it %q<should complain if local repository isn't in the expected format version> do
38
+ fig(%w<--publish foo/1.2.3 --set FOO=BAR>)[2].should == 0
39
+
40
+ set_local_repository_format_to_future_version()
41
+ out, err, exit_code =
42
+ fig(%w<--clean foo/1.2.3>, :no_raise_on_error => true)
43
+ err.should =~
44
+ /Local repository is in version \d+ format. This version of fig can only deal with repositories in version \d+ format\./
45
+ exit_code.should_not == 0
46
+ end
47
+
48
+ %w< --update --update-if-missing >.each do
49
+ |option|
50
+
51
+ it %Q<should complain if #{option} is specified> do
52
+ fig(%w<--publish foo/1.2.3 --set FOO=BAR>)[2].should == 0
53
+
54
+ out, err, exit_code =
55
+ fig([option, '--clean', 'foo/1.2.3'], :no_raise_on_error => true)
56
+ err.should =~
57
+ /because they disagree on whether the base package should be loaded/
58
+ exit_code.should_not == 0
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ describe 'Fig' do
6
+ before(:each) do
7
+ clean_up_test_environment
8
+ set_up_test_environment
9
+ end
10
+
11
+ describe 'command-line options vs package files' do
12
+ it %q<gives a "--set" option priority over a "set" statement> do
13
+ input = <<-END
14
+ config default
15
+ set TEST=package.fig
16
+ end
17
+ END
18
+ fig(%w<--set TEST=command-line --get TEST>, input)[0].should ==
19
+ 'command-line'
20
+ end
21
+
22
+ it %q<gives an "--add" option priority over an "append" statement> do
23
+ input = <<-END
24
+ config default
25
+ add TEST_PATH=package.fig
26
+ end
27
+ END
28
+ fig(%w<--append TEST_PATH=command-line --get TEST_PATH>, input)[0].should ==
29
+ "command-line#{File::PATH_SEPARATOR}package.fig"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,104 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ describe 'Fig' do
6
+ describe 'package definition dumping' do
7
+ before(:each) do
8
+ clean_up_test_environment
9
+ set_up_test_environment
10
+ end
11
+
12
+ describe '--dump-package-definition-text' do
13
+ it %q<dumps the contents of a published package> do
14
+ input = <<-END
15
+ config default
16
+ set FOO=BAR
17
+ end
18
+ END
19
+ fig(%w<--publish foo/1.2.3>, input, :fork => false)
20
+
21
+ out, err =
22
+ fig(%w<foo/1.2.3 --dump-package-definition-text>, :fork => false)
23
+
24
+ # Content from the input.
25
+ out.should =~ /set FOO=BAR/
26
+
27
+ # Content that is added by publishing.
28
+ out.should =~ /publishing information for/i
29
+
30
+ err.should == ''
31
+ end
32
+
33
+ it %q<dumps the contents an unpublished package> do
34
+ input = <<-END
35
+ config default
36
+ set FOO=BAR
37
+ end
38
+ END
39
+ out, err =
40
+ fig(%w<--dump-package-definition-text>, input, :fork => false)
41
+
42
+ out.should == input.strip
43
+ err.should == ''
44
+ end
45
+
46
+ it %q<fails if there is no text> do
47
+ out, err, exit_code = fig(
48
+ %w<--dump-package-definition-text>,
49
+ :no_raise_on_error => true,
50
+ :fork => false
51
+ )
52
+ err.should =~ /no text/
53
+ out.should == ''
54
+ exit_code.should_not == 0
55
+ end
56
+ end
57
+
58
+ describe '--dump-package-definition-parsed' do
59
+ it %q<dumps the contents of a published package> do
60
+ input = <<-END
61
+ config default
62
+ set FOO=BAR
63
+ end
64
+ END
65
+ fig(%w<--publish foo/1.2.3>, input, :fork => false, :fork => false)
66
+
67
+ out, err =
68
+ fig(%w<foo/1.2.3 --dump-package-definition-parsed>, :fork => false)
69
+
70
+ # Content from the input.
71
+ out.should =~ /set FOO=BAR/
72
+
73
+ err.should == ''
74
+ end
75
+
76
+ it %q<dumps the contents an unpublished package> do
77
+ input = <<-END
78
+ config default
79
+ set FOO=BAR
80
+ end
81
+ END
82
+ out, err =
83
+ fig(%w<--dump-package-definition-parsed>, input, :fork => false)
84
+
85
+ [input, out].each do
86
+ |string|
87
+
88
+ string.gsub!(/^[ ]+/, '')
89
+ string.gsub!(/[ ]+/, ' ')
90
+ string.strip!
91
+ end
92
+
93
+ out.should be_include input
94
+ err.should == ''
95
+ end
96
+
97
+ it %q<emits the synthetic package if there is no text> do
98
+ out, err = fig(%w<--dump-package-definition-parsed>, :fork => false)
99
+ out.should =~ / ^ \s* config \s+ default \s+ end \s* \z /x
100
+ err.should == ''
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,62 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ describe 'Fig' do
6
+ describe 'environment variables' do
7
+ before(:each) do
8
+ clean_up_test_environment
9
+ set_up_test_environment
10
+
11
+ # These shouldn't matter because the commands shouldn't look at the repositories.
12
+ set_local_repository_format_to_future_version()
13
+ set_remote_repository_format_to_future_version()
14
+ end
15
+
16
+ it 'sets variable from command line' do
17
+ fig(%w<--set FOO=BAR --get FOO>)[0].should == 'BAR'
18
+
19
+ fig(%w<--set NO_VALUE_WITH_EQUALS= --list-variables>)[0].should ==
20
+ 'NO_VALUE_WITH_EQUALS='
21
+ fig(%w<--set NO_VALUE_WITHOUT_EQUALS --list-variables>)[0].should ==
22
+ 'NO_VALUE_WITHOUT_EQUALS='
23
+ end
24
+
25
+ it 'sets variable from fig file' do
26
+ input = <<-END
27
+ config default
28
+ set FOO=BAR
29
+ end
30
+ END
31
+ fig(%w<--get FOO>, input)[0].should == 'BAR'
32
+ end
33
+
34
+ it 'appends variable from command line with --add' do
35
+ fig(%w<--add PATH=foo --get PATH>).should ==
36
+ ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}", '', 0]
37
+ end
38
+
39
+ it 'appends variable from command line with --append' do
40
+ fig(%w<--append PATH=foo --get PATH>).should ==
41
+ ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}", '', 0]
42
+ end
43
+
44
+ it 'appends variable from fig file' do
45
+ input = <<-END
46
+ config default
47
+ add PATH=foo
48
+ end
49
+ END
50
+ fig(%w<--get PATH>, input).should ==
51
+ ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}", '', 0]
52
+ end
53
+
54
+ it 'appends empty variable' do
55
+ fig(%w<--append XYZZY=foo --get XYZZY>).should == ['foo', '', 0]
56
+ end
57
+
58
+ it %q<doesn't expand variables without packages> do
59
+ fig(%w<--set FOO=@bar --get FOO>)[0].should == '@bar'
60
+ end
61
+ end
62
+ end