Commit 0aa0fbb

mo <mo.khan@gmail.com>
2018-03-05 02:58:10
add specs for metadata show and list.
1 parent f0efecf
Changed files (2)
spec
saml
kit
cli
support
spec/saml/kit/cli/commands/metadata_spec.rb
@@ -1,14 +1,39 @@
 require 'tempfile'
 
 RSpec.describe Saml::Kit::Cli::Commands::Metadata do
+  let(:entity_id) { 'https://saml-kit-proof.herokuapp.com/metadata' }
+
   describe "#register" do
     let(:env) { "SAMLKITRC=#{Tempfile.new('saml-kit').path}" }
-    let(:command) { "metadata register #{url}" }
-    let(:url) { 'https://saml-kit-proof.herokuapp.com/metadata' }
+    let(:command) { "metadata register #{entity_id}" }
 
     specify { expect(status).to be_success }
-    specify { expect(output).to include(url) }
+    specify { expect(output).to include(entity_id) }
     specify { expect(output).to match(/EntityDescriptor/) }
     specify { expect(output).to match(/opening connection to saml-kit-proof.herokuapp.com:443.../) }
   end
+
+  describe "#show" do
+    before :each do
+      env = "SAMLKITRC=#{Tempfile.new('saml-kit').path}"
+      execute("metadata register #{entity_id}", env: env)
+    end
+
+    let(:command) { "metadata show #{entity_id}" }
+
+    specify { expect(status).to be_success }
+    specify { expect(output).to include(entity_id) }
+  end
+
+  describe "#list" do
+    before :each do
+      env = "SAMLKITRC=#{Tempfile.new('saml-kit').path}"
+      execute("metadata register #{entity_id}", env: env)
+    end
+
+    let(:command) { "metadata list" }
+
+    specify { expect(status).to be_success }
+    specify { expect(output).to include(entity_id) }
+  end
 end
spec/support/shell_helpers.rb
@@ -2,9 +2,9 @@ RSpec.shared_context "shell execution" do
   subject { execute(command) }
   let(:status) { subject[0] }
   let(:output) { subject[1] }
-  let(:env) {  }
+  let(:env) { }
 
-  def execute(command, mute: false)
+  def execute(command, mute: false, env: self.env)
     full_command = "#{env} bundle exec ruby ./exe/saml-kit #{command} 2>&1"
     puts full_command unless mute
     output = `#{full_command}`