spec/cli_spec.rb in apiaryio-0.3.1 vs spec/cli_spec.rb in apiaryio-0.3.2
- old
+ new
@@ -1,9 +1,41 @@
require 'spec_helper'
describe Apiary::CLI do
- it 'pass the test' do
- expect(true).to be_truthy
+ # Don't let Thor fold or truncate lines
+ ENV['THOR_COLUMNS'] = '1000'
+
+ # The documentation that ought to match the code
+ READMETEXT = open("README.md") {|f| f.read}
+
+ it 'has help' do
+ help = open('|ruby bin/apiary help') {|f| f.read}
+ expect(help).to include("Commands:")
+ expect(help.lines.count).to be >= 5
end
+ it 'has README.md' do
+ expect(READMETEXT).to include("apiary help")
+ expect(READMETEXT.lines.count).to be >= 5
+ end
+
+ # Confirm that all subcommands are documented, verbatim
+ ([""] + (open('|ruby bin/apiary help', 'r') {|f| f.readlines}
+ .map {|l| /^ +apiary /.match(l)?l:nil}
+ .map {|l| /^ *apiary help/.match(l)?nil:l}
+ .compact
+ .map {|l| /^ *apiary ([^ ]*)/.match(l)[1] + " " }
+ )
+ ).each do |cmd|
+
+ it "includes help #{cmd}in README.md" do
+ helptext = open("|ruby bin/apiary help #{cmd}") {|f| f.read}
+
+ expect(helptext).to include("apiary #{cmd.strip}")
+ expect(READMETEXT).to include("apiary #{cmd.strip}")
+ expect(READMETEXT).to include(helptext)
+
+ end
+ end
end
+