acquia_toolbelt 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/.gitignore +7 -0
  2. data/.ruby-version +1 -0
  3. data/.travis.yml +7 -0
  4. data/CONTRIBUTING.md +11 -0
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +55 -0
  7. data/Guardfile +5 -0
  8. data/LICENSE +19 -0
  9. data/README.md +149 -0
  10. data/Rakefile +1 -0
  11. data/acquia_toolbelt.gemspec +34 -0
  12. data/bin/acquia +9 -0
  13. data/lib/acquia_toolbelt/cli/api.rb +164 -0
  14. data/lib/acquia_toolbelt/cli/auth.rb +31 -0
  15. data/lib/acquia_toolbelt/cli/database.rb +237 -0
  16. data/lib/acquia_toolbelt/cli/deploy.rb +36 -0
  17. data/lib/acquia_toolbelt/cli/domain.rb +177 -0
  18. data/lib/acquia_toolbelt/cli/environment.rb +71 -0
  19. data/lib/acquia_toolbelt/cli/file.rb +31 -0
  20. data/lib/acquia_toolbelt/cli/server.rb +67 -0
  21. data/lib/acquia_toolbelt/cli/site.rb +28 -0
  22. data/lib/acquia_toolbelt/cli/ssh.rb +78 -0
  23. data/lib/acquia_toolbelt/cli/svn.rb +73 -0
  24. data/lib/acquia_toolbelt/cli/task.rb +74 -0
  25. data/lib/acquia_toolbelt/cli/ui.rb +44 -0
  26. data/lib/acquia_toolbelt/cli.rb +103 -0
  27. data/lib/acquia_toolbelt/error.rb +4 -0
  28. data/lib/acquia_toolbelt/thor.rb +95 -0
  29. data/lib/acquia_toolbelt/version.rb +3 -0
  30. data/lib/acquia_toolbelt.rb +4 -0
  31. data/lib/vendor/thor/CHANGELOG.md +139 -0
  32. data/lib/vendor/thor/Gemfile +20 -0
  33. data/lib/vendor/thor/LICENSE.md +20 -0
  34. data/lib/vendor/thor/README.md +35 -0
  35. data/lib/vendor/thor/lib/thor/actions/create_file.rb +105 -0
  36. data/lib/vendor/thor/lib/thor/actions/create_link.rb +60 -0
  37. data/lib/vendor/thor/lib/thor/actions/directory.rb +119 -0
  38. data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +137 -0
  39. data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +317 -0
  40. data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
  41. data/lib/vendor/thor/lib/thor/actions.rb +318 -0
  42. data/lib/vendor/thor/lib/thor/base.rb +654 -0
  43. data/lib/vendor/thor/lib/thor/command.rb +136 -0
  44. data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +80 -0
  45. data/lib/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
  46. data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +100 -0
  47. data/lib/vendor/thor/lib/thor/error.rb +32 -0
  48. data/lib/vendor/thor/lib/thor/group.rb +282 -0
  49. data/lib/vendor/thor/lib/thor/invocation.rb +172 -0
  50. data/lib/vendor/thor/lib/thor/parser/argument.rb +74 -0
  51. data/lib/vendor/thor/lib/thor/parser/arguments.rb +171 -0
  52. data/lib/vendor/thor/lib/thor/parser/option.rb +121 -0
  53. data/lib/vendor/thor/lib/thor/parser/options.rb +218 -0
  54. data/lib/vendor/thor/lib/thor/parser.rb +4 -0
  55. data/lib/vendor/thor/lib/thor/rake_compat.rb +72 -0
  56. data/lib/vendor/thor/lib/thor/runner.rb +322 -0
  57. data/lib/vendor/thor/lib/thor/shell/basic.rb +422 -0
  58. data/lib/vendor/thor/lib/thor/shell/color.rb +148 -0
  59. data/lib/vendor/thor/lib/thor/shell/html.rb +127 -0
  60. data/lib/vendor/thor/lib/thor/shell.rb +88 -0
  61. data/lib/vendor/thor/lib/thor/util.rb +270 -0
  62. data/lib/vendor/thor/lib/thor/version.rb +3 -0
  63. data/lib/vendor/thor/lib/thor.rb +474 -0
  64. data/lib/vendor/thor/spec/actions/create_file_spec.rb +170 -0
  65. data/lib/vendor/thor/spec/actions/create_link_spec.rb +95 -0
  66. data/lib/vendor/thor/spec/actions/directory_spec.rb +169 -0
  67. data/lib/vendor/thor/spec/actions/empty_directory_spec.rb +129 -0
  68. data/lib/vendor/thor/spec/actions/file_manipulation_spec.rb +382 -0
  69. data/lib/vendor/thor/spec/actions/inject_into_file_spec.rb +135 -0
  70. data/lib/vendor/thor/spec/actions_spec.rb +331 -0
  71. data/lib/vendor/thor/spec/base_spec.rb +291 -0
  72. data/lib/vendor/thor/spec/command_spec.rb +80 -0
  73. data/lib/vendor/thor/spec/core_ext/hash_with_indifferent_access_spec.rb +48 -0
  74. data/lib/vendor/thor/spec/core_ext/ordered_hash_spec.rb +115 -0
  75. data/lib/vendor/thor/spec/exit_condition_spec.rb +19 -0
  76. data/lib/vendor/thor/spec/fixtures/application.rb +2 -0
  77. data/lib/vendor/thor/spec/fixtures/app{1}/README +3 -0
  78. data/lib/vendor/thor/spec/fixtures/bundle/execute.rb +6 -0
  79. data/lib/vendor/thor/spec/fixtures/bundle/main.thor +1 -0
  80. data/lib/vendor/thor/spec/fixtures/command.thor +10 -0
  81. data/lib/vendor/thor/spec/fixtures/doc/%file_name%.rb.tt +1 -0
  82. data/lib/vendor/thor/spec/fixtures/doc/COMMENTER +11 -0
  83. data/lib/vendor/thor/spec/fixtures/doc/README +3 -0
  84. data/lib/vendor/thor/spec/fixtures/doc/block_helper.rb +3 -0
  85. data/lib/vendor/thor/spec/fixtures/doc/components/.empty_directory +0 -0
  86. data/lib/vendor/thor/spec/fixtures/doc/config.rb +1 -0
  87. data/lib/vendor/thor/spec/fixtures/doc/config.yaml.tt +1 -0
  88. data/lib/vendor/thor/spec/fixtures/doc/excluding/%file_name%.rb.tt +1 -0
  89. data/lib/vendor/thor/spec/fixtures/enum.thor +10 -0
  90. data/lib/vendor/thor/spec/fixtures/group.thor +128 -0
  91. data/lib/vendor/thor/spec/fixtures/invoke.thor +118 -0
  92. data/lib/vendor/thor/spec/fixtures/path with spaces +0 -0
  93. data/lib/vendor/thor/spec/fixtures/preserve/script.sh +3 -0
  94. data/lib/vendor/thor/spec/fixtures/script.thor +220 -0
  95. data/lib/vendor/thor/spec/fixtures/subcommand.thor +17 -0
  96. data/lib/vendor/thor/spec/group_spec.rb +222 -0
  97. data/lib/vendor/thor/spec/helper.rb +67 -0
  98. data/lib/vendor/thor/spec/invocation_spec.rb +108 -0
  99. data/lib/vendor/thor/spec/parser/argument_spec.rb +53 -0
  100. data/lib/vendor/thor/spec/parser/arguments_spec.rb +66 -0
  101. data/lib/vendor/thor/spec/parser/option_spec.rb +202 -0
  102. data/lib/vendor/thor/spec/parser/options_spec.rb +400 -0
  103. data/lib/vendor/thor/spec/rake_compat_spec.rb +72 -0
  104. data/lib/vendor/thor/spec/register_spec.rb +197 -0
  105. data/lib/vendor/thor/spec/runner_spec.rb +241 -0
  106. data/lib/vendor/thor/spec/shell/basic_spec.rb +330 -0
  107. data/lib/vendor/thor/spec/shell/color_spec.rb +95 -0
  108. data/lib/vendor/thor/spec/shell/html_spec.rb +31 -0
  109. data/lib/vendor/thor/spec/shell_spec.rb +47 -0
  110. data/lib/vendor/thor/spec/subcommand_spec.rb +30 -0
  111. data/lib/vendor/thor/spec/thor_spec.rb +499 -0
  112. data/lib/vendor/thor/spec/util_spec.rb +196 -0
  113. data/lib/vendor/thor/thor.gemspec +24 -0
  114. data/script/release +50 -0
  115. data/script/setup_build +6 -0
  116. data/script/test +23 -0
  117. data/spec/auth_spec.rb +15 -0
  118. data/spec/cassettes/databases/all_databases.json +1 -0
  119. data/spec/cassettes/databases/copy_database_from_dev_to_stage.json +1 -0
  120. data/spec/cassettes/databases/create_a_database_backup.json +1 -0
  121. data/spec/cassettes/databases/create_a_new_database.json +1 -0
  122. data/spec/cassettes/databases/delete_a_database.json +1 -0
  123. data/spec/cassettes/databases/get_all_existing_databases.json +1 -0
  124. data/spec/cassettes/databases/list_all_database_backups.json +1 -0
  125. data/spec/cassettes/databases/view_database_instance_details.json +1 -0
  126. data/spec/cassettes/deploy/release_vcs_branch.json +1 -0
  127. data/spec/cassettes/domains/create_new_domain.json +1 -0
  128. data/spec/cassettes/domains/delete_a_domain.json +1 -0
  129. data/spec/cassettes/domains/get_all_existing_domains.json +1 -0
  130. data/spec/cassettes/domains/list_all_dev_domains.json +1 -0
  131. data/spec/cassettes/domains/move_from_dev_to_stage.json +1 -0
  132. data/spec/cassettes/domains/purge_varnish_cache.json +1 -0
  133. data/spec/cassettes/environments/all_environments.json +1 -0
  134. data/spec/cassettes/environments/disable_live_development.json +1 -0
  135. data/spec/cassettes/environments/enable_live_development.json +1 -0
  136. data/spec/cassettes/files/copy_from_dev_to_stage.json +1 -0
  137. data/spec/cassettes/servers/all_dev_servers.json +1 -0
  138. data/spec/cassettes/servers/all_prod_servers.json +1 -0
  139. data/spec/cassettes/sites/all_sites.json +1 -0
  140. data/spec/cassettes/ssh/all_sshkeys.json +1 -0
  141. data/spec/cassettes/svn/all_svnusers.json +1 -0
  142. data/spec/cassettes/tasks/all_tasks.json +1 -0
  143. data/spec/databases_spec.rb +78 -0
  144. data/spec/deploy_spec.rb +12 -0
  145. data/spec/domains_spec.rb +59 -0
  146. data/spec/environments_spec.rb +35 -0
  147. data/spec/files_spec.rb +11 -0
  148. data/spec/helper.rb +104 -0
  149. data/spec/servers_spec.rb +59 -0
  150. data/spec/sites_spec.rb +19 -0
  151. data/spec/ssh_spec.rb +19 -0
  152. data/spec/svn_spec.rb +11 -0
  153. data/spec/tasks_spec.rb +11 -0
  154. metadata +158 -4
@@ -0,0 +1,95 @@
1
+ require 'helper'
2
+ require 'thor/actions'
3
+ require 'tempfile'
4
+
5
+ describe Thor::Actions::CreateLink do
6
+ before do
7
+ @hardlink_to = File.join(Dir.tmpdir, 'linkdest.rb')
8
+ ::FileUtils.rm_rf(destination_root)
9
+ ::FileUtils.rm_rf(@hardlink_to)
10
+ end
11
+
12
+ def create_link(destination=nil, config={}, options={})
13
+ @base = MyCounter.new([1,2], options, { :destination_root => destination_root })
14
+ allow(@base).to receive(:file_name).and_return('rdoc')
15
+
16
+ @tempfile = Tempfile.new("config.rb")
17
+
18
+ @action = Thor::Actions::CreateLink.new(@base, destination, @tempfile.path,
19
+ { :verbose => !@silence }.merge(config))
20
+ end
21
+
22
+ def invoke!
23
+ capture(:stdout) { @action.invoke! }
24
+ end
25
+
26
+ def revoke!
27
+ capture(:stdout) { @action.revoke! }
28
+ end
29
+
30
+ def silence!
31
+ @silence = true
32
+ end
33
+
34
+ describe "#invoke!" do
35
+ it "creates a symbolic link for :symbolic => true" do
36
+ create_link("doc/config.rb", :symbolic => true)
37
+ invoke!
38
+ destination_path = File.join(destination_root, "doc/config.rb")
39
+ expect(File.exists?(destination_path)).to be_true
40
+ expect(File.symlink?(destination_path)).to be_true
41
+ end
42
+
43
+ it "creates a hard link for :symbolic => false" do
44
+ create_link(@hardlink_to, :symbolic => false)
45
+ invoke!
46
+ destination_path = @hardlink_to
47
+ expect(File.exists?(destination_path)).to be_true
48
+ expect(File.symlink?(destination_path)).to be_false
49
+ end
50
+
51
+ it "creates a symbolic link by default" do
52
+ create_link("doc/config.rb")
53
+ invoke!
54
+ destination_path = File.join(destination_root, "doc/config.rb")
55
+ expect(File.exists?(destination_path)).to be_true
56
+ expect(File.symlink?(destination_path)).to be_true
57
+ end
58
+
59
+ it "does not create a link if pretending" do
60
+ create_link("doc/config.rb", {}, :pretend => true)
61
+ invoke!
62
+ expect(File.exists?(File.join(destination_root, "doc/config.rb"))).to be_false
63
+ end
64
+
65
+ it "shows created status to the user" do
66
+ create_link("doc/config.rb")
67
+ expect(invoke!).to eq(" create doc/config.rb\n")
68
+ end
69
+
70
+ it "does not show any information if log status is false" do
71
+ silence!
72
+ create_link("doc/config.rb")
73
+ expect(invoke!).to be_empty
74
+ end
75
+ end
76
+
77
+ describe "#identical?" do
78
+ it "returns true if the destination link exists and is identical" do
79
+ create_link("doc/config.rb")
80
+ expect(@action.identical?).to be_false
81
+ invoke!
82
+ expect(@action.identical?).to be_true
83
+ end
84
+ end
85
+
86
+ describe "#revoke!" do
87
+ it "removes the symbolic link of non-existent destination" do
88
+ create_link("doc/config.rb")
89
+ invoke!
90
+ File.delete(@tempfile.path)
91
+ revoke!
92
+ expect(File.symlink?(@action.destination)).to be_false
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,169 @@
1
+ require 'helper'
2
+ require 'thor/actions'
3
+
4
+ describe Thor::Actions::Directory do
5
+ before do
6
+ ::FileUtils.rm_rf(destination_root)
7
+ allow(invoker).to receive(:file_name).and_return("rdoc")
8
+ end
9
+
10
+ def invoker
11
+ @invoker ||= WhinyGenerator.new([1,2], {}, { :destination_root => destination_root })
12
+ end
13
+
14
+ def revoker
15
+ @revoker ||= WhinyGenerator.new([1,2], {}, { :destination_root => destination_root, :behavior => :revoke })
16
+ end
17
+
18
+ def invoke!(*args, &block)
19
+ capture(:stdout){ invoker.directory(*args, &block) }
20
+ end
21
+
22
+ def revoke!(*args, &block)
23
+ capture(:stdout){ revoker.directory(*args, &block) }
24
+ end
25
+
26
+ def exists_and_identical?(source_path, destination_path)
27
+ %w(config.rb README).each do |file|
28
+ source = File.join(source_root, source_path, file)
29
+ destination = File.join(destination_root, destination_path, file)
30
+
31
+ expect(File.exists?(destination)).to be_true
32
+ expect(FileUtils.identical?(source, destination)).to be_true
33
+ end
34
+ end
35
+
36
+ describe "#invoke!" do
37
+ it "raises an error if the source does not exist" do
38
+ expect {
39
+ invoke! "unknown"
40
+ }.to raise_error(Thor::Error, /Could not find "unknown" in any of your source paths/)
41
+ end
42
+
43
+ it "does not create a directory in pretend mode" do
44
+ invoke! "doc", "ghost", :pretend => true
45
+ expect(File.exists?("ghost")).to be_false
46
+ end
47
+
48
+ it "copies the whole directory recursively to the default destination" do
49
+ invoke! "doc"
50
+ exists_and_identical?("doc", "doc")
51
+ end
52
+
53
+ it "copies the whole directory recursively to the specified destination" do
54
+ invoke! "doc", "docs"
55
+ exists_and_identical?("doc", "docs")
56
+ end
57
+
58
+ it "copies only the first level files if recursive" do
59
+ invoke! ".", "commands", :recursive => false
60
+
61
+ file = File.join(destination_root, "commands", "group.thor")
62
+ expect(File.exists?(file)).to be_true
63
+
64
+ file = File.join(destination_root, "commands", "doc")
65
+ expect(File.exists?(file)).to be_false
66
+
67
+ file = File.join(destination_root, "commands", "doc", "README")
68
+ expect(File.exists?(file)).to be_false
69
+ end
70
+
71
+ it "ignores files within excluding/ directories when exclude_pattern is provided" do
72
+ invoke! "doc", "docs", :exclude_pattern => /excluding\//
73
+ file = File.join(destination_root, "docs", "excluding", "rdoc.rb")
74
+ expect(File.exists?(file)).to be_false
75
+ end
76
+
77
+ it "copies and evaluates files within excluding/ directory when no exclude_pattern is present" do
78
+ invoke! "doc", "docs"
79
+ file = File.join(destination_root, "docs", "excluding", "rdoc.rb")
80
+ expect(File.exists?(file)).to be_true
81
+ expect(File.read(file)).to eq("BAR = BAR\n")
82
+ end
83
+
84
+ it "copies files from the source relative to the current path" do
85
+ invoker.inside "doc" do
86
+ invoke! "."
87
+ end
88
+ exists_and_identical?("doc", "doc")
89
+ end
90
+
91
+ it "copies and evaluates templates" do
92
+ invoke! "doc", "docs"
93
+ file = File.join(destination_root, "docs", "rdoc.rb")
94
+ expect(File.exists?(file)).to be_true
95
+ expect(File.read(file)).to eq("FOO = FOO\n")
96
+ end
97
+
98
+ it "copies directories and preserves file mode" do
99
+ invoke! "preserve", "preserved", :mode => :preserve
100
+ original = File.join(source_root, "preserve", "script.sh")
101
+ copy = File.join(destination_root, "preserved", "script.sh")
102
+ expect(File.stat(original).mode).to eq(File.stat(copy).mode)
103
+ end
104
+
105
+ it "copies directories" do
106
+ invoke! "doc", "docs"
107
+ file = File.join(destination_root, "docs", "components")
108
+ expect(File.exists?(file)).to be_true
109
+ expect(File.directory?(file)).to be_true
110
+ end
111
+
112
+ it "does not copy .empty_directory files" do
113
+ invoke! "doc", "docs"
114
+ file = File.join(destination_root, "docs", "components", ".empty_directory")
115
+ expect(File.exists?(file)).to be_false
116
+ end
117
+
118
+ it "copies directories even if they are empty" do
119
+ invoke! "doc/components", "docs/components"
120
+ file = File.join(destination_root, "docs", "components")
121
+ expect(File.exists?(file)).to be_true
122
+ end
123
+
124
+ it "does not copy empty directories twice" do
125
+ content = invoke!("doc/components", "docs/components")
126
+ expect(content).not_to match(/exist/)
127
+ end
128
+
129
+ it "logs status" do
130
+ content = invoke!("doc")
131
+ expect(content).to match(/create doc\/README/)
132
+ expect(content).to match(/create doc\/config\.rb/)
133
+ expect(content).to match(/create doc\/rdoc\.rb/)
134
+ expect(content).to match(/create doc\/components/)
135
+ end
136
+
137
+ it "yields a block" do
138
+ checked = false
139
+ invoke!("doc") do |content|
140
+ checked ||= !!(content =~ /FOO/)
141
+ end
142
+ expect(checked).to be_true
143
+ end
144
+
145
+ it "works with glob characters in the path" do
146
+ content = invoke!("app{1}")
147
+ expect(content).to match(/create app\{1\}\/README/)
148
+ end
149
+ end
150
+
151
+ describe "#revoke!" do
152
+ it "removes the destination file" do
153
+ invoke! "doc"
154
+ revoke! "doc"
155
+
156
+ expect(File.exists?(File.join(destination_root, "doc", "README"))).to be_false
157
+ expect(File.exists?(File.join(destination_root, "doc", "config.rb"))).to be_false
158
+ expect(File.exists?(File.join(destination_root, "doc", "components"))).to be_false
159
+ end
160
+
161
+ it "works with glob characters in the path" do
162
+ invoke! "app{1}"
163
+ expect(File.exists?(File.join(destination_root, "app{1}", "README"))).to be_true
164
+
165
+ revoke! "app{1}"
166
+ expect(File.exists?(File.join(destination_root, "app{1}", "README"))).to be_false
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,129 @@
1
+ require 'helper'
2
+ require 'thor/actions'
3
+
4
+ describe Thor::Actions::EmptyDirectory do
5
+ before do
6
+ ::FileUtils.rm_rf(destination_root)
7
+ end
8
+
9
+ def empty_directory(destination, options={})
10
+ @action = Thor::Actions::EmptyDirectory.new(base, destination)
11
+ end
12
+
13
+ def invoke!
14
+ capture(:stdout) { @action.invoke! }
15
+ end
16
+
17
+ def revoke!
18
+ capture(:stdout) { @action.revoke! }
19
+ end
20
+
21
+ def base
22
+ @base ||= MyCounter.new([1,2], {}, { :destination_root => destination_root })
23
+ end
24
+
25
+ describe "#destination" do
26
+ it "returns the full destination with the destination_root" do
27
+ expect(empty_directory('doc').destination).to eq(File.join(destination_root, 'doc'))
28
+ end
29
+
30
+ it "takes relative root into account" do
31
+ base.inside('doc') do
32
+ expect(empty_directory('contents').destination).to eq(File.join(destination_root, 'doc', 'contents'))
33
+ end
34
+ end
35
+ end
36
+
37
+ describe "#relative_destination" do
38
+ it "returns the relative destination to the original destination root" do
39
+ base.inside('doc') do
40
+ expect(empty_directory('contents').relative_destination).to eq('doc/contents')
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "#given_destination" do
46
+ it "returns the destination supplied by the user" do
47
+ base.inside('doc') do
48
+ expect(empty_directory('contents').given_destination).to eq('contents')
49
+ end
50
+ end
51
+ end
52
+
53
+ describe "#invoke!" do
54
+ it "copies the file to the specified destination" do
55
+ empty_directory("doc")
56
+ invoke!
57
+ expect(File.exists?(File.join(destination_root, "doc"))).to be_true
58
+ end
59
+
60
+ it "shows created status to the user" do
61
+ empty_directory("doc")
62
+ expect(invoke!).to eq(" create doc\n")
63
+ end
64
+
65
+ it "does not create a directory if pretending" do
66
+ base.inside("foo", :pretend => true) do
67
+ empty_directory("ghost")
68
+ end
69
+ expect(File.exists?(File.join(base.destination_root, "ghost"))).to be_false
70
+ end
71
+
72
+ describe "when directory exists" do
73
+ it "shows exist status" do
74
+ empty_directory("doc")
75
+ invoke!
76
+ expect(invoke!).to eq(" exist doc\n")
77
+ end
78
+ end
79
+ end
80
+
81
+ describe "#revoke!" do
82
+ it "removes the destination file" do
83
+ empty_directory("doc")
84
+ invoke!
85
+ revoke!
86
+ expect(File.exists?(@action.destination)).to be_false
87
+ end
88
+ end
89
+
90
+ describe "#exists?" do
91
+ it "returns true if the destination file exists" do
92
+ empty_directory("doc")
93
+ expect(@action.exists?).to be_false
94
+ invoke!
95
+ expect(@action.exists?).to be_true
96
+ end
97
+ end
98
+
99
+ context "protected methods" do
100
+ describe "#convert_encoded_instructions" do
101
+ before do
102
+ empty_directory("test_dir")
103
+ allow(@action.base).to receive(:file_name).and_return("expected")
104
+ end
105
+
106
+ it "accepts and executes a 'legal' %\w+% encoded instruction" do
107
+ expect(@action.send(:convert_encoded_instructions, "%file_name%.txt")).to eq("expected.txt")
108
+ end
109
+
110
+ it "accepts and executes a private %\w+% encoded instruction" do
111
+ @action.base.extend Module.new {
112
+ private
113
+ def private_file_name
114
+ "expected"
115
+ end
116
+ }
117
+ expect(@action.send(:convert_encoded_instructions, "%private_file_name%.txt")).to eq("expected.txt")
118
+ end
119
+
120
+ it "ignores an 'illegal' %\w+% encoded instruction" do
121
+ expect(@action.send(:convert_encoded_instructions, "%some_name%.txt")).to eq("%some_name%.txt")
122
+ end
123
+
124
+ it "ignores incorrectly encoded instruction" do
125
+ expect(@action.send(:convert_encoded_instructions, "%some.name%.txt")).to eq("%some.name%.txt")
126
+ end
127
+ end
128
+ end
129
+ end