thor_dleavitt 0.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/CHANGELOG.md +139 -0
  4. data/LICENSE.md +20 -0
  5. data/README.md +35 -0
  6. data/Thorfile +30 -0
  7. data/bin/thor_dleavitt +6 -0
  8. data/lib/thor/actions.rb +318 -0
  9. data/lib/thor/actions/create_file.rb +105 -0
  10. data/lib/thor/actions/create_link.rb +60 -0
  11. data/lib/thor/actions/directory.rb +119 -0
  12. data/lib/thor/actions/empty_directory.rb +137 -0
  13. data/lib/thor/actions/file_manipulation.rb +317 -0
  14. data/lib/thor/actions/inject_into_file.rb +109 -0
  15. data/lib/thor/base.rb +654 -0
  16. data/lib/thor/command.rb +136 -0
  17. data/lib/thor/core_ext/hash_with_indifferent_access.rb +80 -0
  18. data/lib/thor/core_ext/io_binary_read.rb +12 -0
  19. data/lib/thor/core_ext/ordered_hash.rb +100 -0
  20. data/lib/thor/error.rb +32 -0
  21. data/lib/thor/group.rb +282 -0
  22. data/lib/thor/invocation.rb +172 -0
  23. data/lib/thor/parser.rb +4 -0
  24. data/lib/thor/parser/argument.rb +74 -0
  25. data/lib/thor/parser/arguments.rb +171 -0
  26. data/lib/thor/parser/option.rb +121 -0
  27. data/lib/thor/parser/options.rb +218 -0
  28. data/lib/thor/rake_compat.rb +72 -0
  29. data/lib/thor/runner.rb +322 -0
  30. data/lib/thor/shell.rb +88 -0
  31. data/lib/thor/shell/basic.rb +422 -0
  32. data/lib/thor/shell/color.rb +148 -0
  33. data/lib/thor/shell/html.rb +127 -0
  34. data/lib/thor/util.rb +270 -0
  35. data/lib/thor/version.rb +3 -0
  36. data/lib/thor_dleavitt.rb +473 -0
  37. data/spec/actions/create_file_spec.rb +170 -0
  38. data/spec/actions/create_link_spec.rb +95 -0
  39. data/spec/actions/directory_spec.rb +169 -0
  40. data/spec/actions/empty_directory_spec.rb +129 -0
  41. data/spec/actions/file_manipulation_spec.rb +382 -0
  42. data/spec/actions/inject_into_file_spec.rb +135 -0
  43. data/spec/actions_spec.rb +331 -0
  44. data/spec/base_spec.rb +291 -0
  45. data/spec/command_spec.rb +80 -0
  46. data/spec/core_ext/hash_with_indifferent_access_spec.rb +48 -0
  47. data/spec/core_ext/ordered_hash_spec.rb +115 -0
  48. data/spec/exit_condition_spec.rb +19 -0
  49. data/spec/fixtures/application.rb +2 -0
  50. data/spec/fixtures/app{1}/README +3 -0
  51. data/spec/fixtures/bundle/execute.rb +6 -0
  52. data/spec/fixtures/bundle/main.thor +1 -0
  53. data/spec/fixtures/command.thor +10 -0
  54. data/spec/fixtures/doc/%file_name%.rb.tt +1 -0
  55. data/spec/fixtures/doc/COMMENTER +11 -0
  56. data/spec/fixtures/doc/README +3 -0
  57. data/spec/fixtures/doc/block_helper.rb +3 -0
  58. data/spec/fixtures/doc/config.rb +1 -0
  59. data/spec/fixtures/doc/config.yaml.tt +1 -0
  60. data/spec/fixtures/doc/excluding/%file_name%.rb.tt +1 -0
  61. data/spec/fixtures/enum.thor +10 -0
  62. data/spec/fixtures/group.thor +128 -0
  63. data/spec/fixtures/invoke.thor +118 -0
  64. data/spec/fixtures/path with spaces b/data/spec/fixtures/path with → spaces +0 -0
  65. data/spec/fixtures/preserve/script.sh +3 -0
  66. data/spec/fixtures/script.thor +220 -0
  67. data/spec/fixtures/subcommand.thor +17 -0
  68. data/spec/group_spec.rb +222 -0
  69. data/spec/helper.rb +67 -0
  70. data/spec/invocation_spec.rb +108 -0
  71. data/spec/parser/argument_spec.rb +53 -0
  72. data/spec/parser/arguments_spec.rb +66 -0
  73. data/spec/parser/option_spec.rb +202 -0
  74. data/spec/parser/options_spec.rb +400 -0
  75. data/spec/rake_compat_spec.rb +72 -0
  76. data/spec/register_spec.rb +197 -0
  77. data/spec/runner_spec.rb +241 -0
  78. data/spec/shell/basic_spec.rb +330 -0
  79. data/spec/shell/color_spec.rb +95 -0
  80. data/spec/shell/html_spec.rb +31 -0
  81. data/spec/shell_spec.rb +47 -0
  82. data/spec/subcommand_spec.rb +30 -0
  83. data/spec/thor_spec.rb +499 -0
  84. data/spec/util_spec.rb +196 -0
  85. data/thor.gemspec +24 -0
  86. metadata +191 -0
@@ -0,0 +1,170 @@
1
+ require 'helper'
2
+ require 'thor/actions'
3
+
4
+ describe Thor::Actions::CreateFile do
5
+ before do
6
+ ::FileUtils.rm_rf(destination_root)
7
+ end
8
+
9
+ def create_file(destination=nil, config={}, options={})
10
+ @base = MyCounter.new([1, 2], options, { :destination_root => destination_root })
11
+ allow(@base).to receive(:file_name).and_return('rdoc')
12
+
13
+ @action = Thor::Actions::CreateFile.new(@base, destination, "CONFIGURATION",
14
+ { :verbose => !@silence }.merge(config))
15
+ end
16
+
17
+ def invoke!
18
+ capture(:stdout) { @action.invoke! }
19
+ end
20
+
21
+ def revoke!
22
+ capture(:stdout) { @action.revoke! }
23
+ end
24
+
25
+ def silence!
26
+ @silence = true
27
+ end
28
+
29
+ describe "#invoke!" do
30
+ it "creates a file" do
31
+ create_file("doc/config.rb")
32
+ invoke!
33
+ expect(File.exists?(File.join(destination_root, "doc/config.rb"))).to be_true
34
+ end
35
+
36
+ it "does not create a file if pretending" do
37
+ create_file("doc/config.rb", {}, :pretend => true)
38
+ invoke!
39
+ expect(File.exists?(File.join(destination_root, "doc/config.rb"))).to be_false
40
+ end
41
+
42
+ it "shows created status to the user" do
43
+ create_file("doc/config.rb")
44
+ expect(invoke!).to eq(" create doc/config.rb\n")
45
+ end
46
+
47
+ it "does not show any information if log status is false" do
48
+ silence!
49
+ create_file("doc/config.rb")
50
+ expect(invoke!).to be_empty
51
+ end
52
+
53
+ it "returns the given destination" do
54
+ capture(:stdout) do
55
+ expect(create_file("doc/config.rb").invoke!).to eq("doc/config.rb")
56
+ end
57
+ end
58
+
59
+ it "converts encoded instructions" do
60
+ create_file("doc/%file_name%.rb.tt")
61
+ invoke!
62
+ expect(File.exists?(File.join(destination_root, "doc/rdoc.rb.tt"))).to be_true
63
+ end
64
+
65
+ describe "when file exists" do
66
+ before do
67
+ create_file("doc/config.rb")
68
+ invoke!
69
+ end
70
+
71
+ describe "and is identical" do
72
+ it "shows identical status" do
73
+ create_file("doc/config.rb")
74
+ invoke!
75
+ expect(invoke!).to eq(" identical doc/config.rb\n")
76
+ end
77
+ end
78
+
79
+ describe "and is not identical" do
80
+ before do
81
+ File.open(File.join(destination_root, 'doc/config.rb'), 'w'){ |f| f.write("FOO = 3") }
82
+ end
83
+
84
+ it "shows forced status to the user if force is given" do
85
+ expect(create_file("doc/config.rb", {}, :force => true)).not_to be_identical
86
+ expect(invoke!).to eq(" force doc/config.rb\n")
87
+ end
88
+
89
+ it "shows skipped status to the user if skip is given" do
90
+ expect(create_file("doc/config.rb", {}, :skip => true)).not_to be_identical
91
+ expect(invoke!).to eq(" skip doc/config.rb\n")
92
+ end
93
+
94
+ it "shows forced status to the user if force is configured" do
95
+ expect(create_file("doc/config.rb", :force => true)).not_to be_identical
96
+ expect(invoke!).to eq(" force doc/config.rb\n")
97
+ end
98
+
99
+ it "shows skipped status to the user if skip is configured" do
100
+ expect(create_file("doc/config.rb", :skip => true)).not_to be_identical
101
+ expect(invoke!).to eq(" skip doc/config.rb\n")
102
+ end
103
+
104
+ it "shows conflict status to the user" do
105
+ expect(create_file("doc/config.rb")).not_to be_identical
106
+ expect($stdin).to receive(:gets).and_return('s')
107
+ file = File.join(destination_root, 'doc/config.rb')
108
+
109
+ content = invoke!
110
+ expect(content).to match(/conflict doc\/config\.rb/)
111
+ expect(content).to match(/Overwrite #{file}\? \(enter "h" for help\) \[Ynaqdh\]/)
112
+ expect(content).to match(/skip doc\/config\.rb/)
113
+ end
114
+
115
+ it "creates the file if the file collision menu returns true" do
116
+ create_file("doc/config.rb")
117
+ expect($stdin).to receive(:gets).and_return('y')
118
+ expect(invoke!).to match(/force doc\/config\.rb/)
119
+ end
120
+
121
+ it "skips the file if the file collision menu returns false" do
122
+ create_file("doc/config.rb")
123
+ expect($stdin).to receive(:gets).and_return('n')
124
+ expect(invoke!).to match(/skip doc\/config\.rb/)
125
+ end
126
+
127
+ it "executes the block given to show file content" do
128
+ create_file("doc/config.rb")
129
+ expect($stdin).to receive(:gets).and_return('d')
130
+ expect($stdin).to receive(:gets).and_return('n')
131
+ expect(@base.shell).to receive(:system).with(/diff -u/)
132
+ invoke!
133
+ end
134
+ end
135
+ end
136
+ end
137
+
138
+ describe "#revoke!" do
139
+ it "removes the destination file" do
140
+ create_file("doc/config.rb")
141
+ invoke!
142
+ revoke!
143
+ expect(File.exists?(@action.destination)).to be_false
144
+ end
145
+
146
+ it "does not raise an error if the file does not exist" do
147
+ create_file("doc/config.rb")
148
+ revoke!
149
+ expect(File.exists?(@action.destination)).to be_false
150
+ end
151
+ end
152
+
153
+ describe "#exists?" do
154
+ it "returns true if the destination file exists" do
155
+ create_file("doc/config.rb")
156
+ expect(@action.exists?).to be_false
157
+ invoke!
158
+ expect(@action.exists?).to be_true
159
+ end
160
+ end
161
+
162
+ describe "#identical?" do
163
+ it "returns true if the destination file exists and is identical" do
164
+ create_file("doc/config.rb")
165
+ expect(@action.identical?).to be_false
166
+ invoke!
167
+ expect(@action.identical?).to be_true
168
+ end
169
+ end
170
+ end
@@ -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