Browse files

Commands: fix "convert" and add tests

  • Loading branch information...
1 parent 1bc95f6 commit 4ba52e8d9cfa2701c5444512cc91aea2401c9cd7 @kyrylo committed Mar 25, 2013
Showing with 13 additions and 1 deletion.
  1. +5 −1 lib/pry-theme/commands.rb
  2. +8 −0 spec/commands_spec.rb
View
6 lib/pry-theme/commands.rb
@@ -88,7 +88,7 @@ def def_convert(cmd)
opt.run do |opts, args|
if color_model_option_only?(opts)
output.puts 'Provide a color value to be converted'
- elsif color_model_option_and_other_one?(opts)
+ elsif color_model_option_and_other_one?(opts) || without_color_model?(opts)
convert_color(opts, args)
else
output.puts 'You must provide the `-m` and one of the rest switches.'
@@ -276,6 +276,10 @@ def color_model_option_and_other_one?(opts)
opts[:m] && (opts[:h] || opts[:r] || opts[:t])
end
+ def without_color_model?(opts)
+ !opts[:m] && (opts[:h] || opts[:r] || opts[:t])
+ end
+
def installed?(theme)
theme['name'] == 'README.md' ||
ThemeList.themes.map(&:name).include?(theme['name'])
View
8 spec/commands_spec.rb
@@ -122,6 +122,14 @@ def this_is_a_method
end
end
+ it "warns when no switches given" do
+ pry_eval('pry-theme convert').should =~ /You must provide the `-m`/
+ end
+
+ it "warns on incorrect usage" do
+ pry_eval('pry-theme convert dqwdwq').should =~ /You must provide the `-m`/
+ end
+
describe "conversion from term" do
if PryTheme.tput_colors == 256
it "with implicit model" do

0 comments on commit 4ba52e8

Please sign in to comment.