Commit f0efecf

mo <mo.khan@gmail.com>
2018-03-05 02:51:09
add spec for metadata registration.
1 parent 727c090
Changed files (2)
spec
saml
kit
cli
support
spec/saml/kit/cli/commands/metadata_spec.rb
@@ -0,0 +1,14 @@
+require 'tempfile'
+
+RSpec.describe Saml::Kit::Cli::Commands::Metadata do
+  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' }
+
+    specify { expect(status).to be_success }
+    specify { expect(output).to include(url) }
+    specify { expect(output).to match(/EntityDescriptor/) }
+    specify { expect(output).to match(/opening connection to saml-kit-proof.herokuapp.com:443.../) }
+  end
+end
spec/support/shell_helpers.rb
@@ -2,9 +2,10 @@ RSpec.shared_context "shell execution" do
   subject { execute(command) }
   let(:status) { subject[0] }
   let(:output) { subject[1] }
+  let(:env) {  }
 
   def execute(command, mute: false)
-    full_command = "bundle exec ruby ./exe/saml-kit #{command} 2>&1"
+    full_command = "#{env} bundle exec ruby ./exe/saml-kit #{command} 2>&1"
     puts full_command unless mute
     output = `#{full_command}`
     [$?, output]