summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ohai/plugins/haskell.rb4
-rw-r--r--spec/unit/plugins/haskell_spec.rb24
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/ohai/plugins/haskell.rb b/lib/ohai/plugins/haskell.rb
index b3fa2335..d3070e04 100644
--- a/lib/ohai/plugins/haskell.rb
+++ b/lib/ohai/plugins/haskell.rb
@@ -79,9 +79,11 @@ Ohai.plugin(:Haskell) do
# Sample output:
# Version 1.1.0, Git revision 0e9430aad55841b5ff2c6c2851f0548c16bce7cf (3540 commits) x86_64 hpack-0.13.0
+ # or
+ # Version 1.2.0 x86_64 hpack-0.14.0
if so.exitstatus == 0
haskell[:stack] = Mash.new
- haskell[:stack][:version] = so.stdout.split[1][0..-2]
+ haskell[:stack][:version] = /Version ([^\s,]*)/.match(so.stdout)[1] rescue nil
haskell[:stack][:description] = so.stdout.chomp
end
rescue Ohai::Exceptions::Exec
diff --git a/spec/unit/plugins/haskell_spec.rb b/spec/unit/plugins/haskell_spec.rb
index 05e632c2..7dc53b69 100644
--- a/spec/unit/plugins/haskell_spec.rb
+++ b/spec/unit/plugins/haskell_spec.rb
@@ -27,7 +27,8 @@ describe Ohai::System, "plugin haskell" do
let(:ghc_out) { "The Glorious Glasgow Haskell Compilation System, version 7.6.3" }
let(:ghci_out) { "The Glorious Glasgow Haskell Compilation System, version 7.6.3" }
let(:cabal_out) { "cabal-install version 1.16.0.2\nusing version 1.16.0 of the Cabal library" }
- let(:stack_out) { "Version 1.1.0, Git revision 0e9430aad55841b5ff2c6c2851f0548c16bce7cf (3540 commits) x86_64 hpack-0.13.0" }
+ let(:stack_out) { "Version 1.2.0 x86_64 hpack-0.14.0" }
+ let(:stack_out_git) { "Version 1.1.0, Git revision 0e9430aad55841b5ff2c6c2851f0548c16bce7cf (3540 commits) x86_64 hpack-0.13.0" }
def setup_plugin
allow(plugin).to receive(:shell_out)
@@ -100,7 +101,7 @@ describe Ohai::System, "plugin haskell" do
end
it "set languages[:haskell][:stack][:version]" do
- expect(plugin[:languages][:haskell][:stack][:version]).to eql("1.1.0")
+ expect(plugin[:languages][:haskell][:stack][:version]).to eql("1.2.0")
end
it "set languages[:haskell][:stack][:description]" do
@@ -108,6 +109,25 @@ describe Ohai::System, "plugin haskell" do
end
end
+ context "if haskell/stack prerelease is installed" do
+
+ before(:each) do
+ setup_plugin
+ allow(plugin).to receive(:shell_out)
+ .with("stack --version")
+ .and_return(mock_shell_out(0, stack_out_git, ""))
+ plugin.run
+ end
+
+ it "set languages[:haskell][:stack][:version]" do
+ expect(plugin[:languages][:haskell][:stack][:version]).to eql("1.1.0")
+ end
+
+ it "set languages[:haskell][:stack][:description]" do
+ expect(plugin[:languages][:haskell][:stack][:description]).to eql(stack_out_git)
+ end
+ end
+
context "if haskell is NOT installed" do
before(:each) do