[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [websites/inqlude] /: Extract test which needs online access
From:       Cornelius Schumacher <schumacher () kde ! org>
Date:       2016-10-15 22:49:42
Message-ID: E1bvXlu-0003rJ-Mg () code ! kde ! org
[Download RAW message or body]

Git commit 7b22cec674822dcc264535312e9b3e540bc801ea by Cornelius Schumacher.
Committed on 14/08/2016 at 14:36.
Pushed by cschumac into branch 'master'.

Extract test which needs online access

The tests which reads the actual online inqlude data repo and checks
the generation of the inqlude-all.json file is in the `online` sub
directory now.

All other tests don't access online resources anymore and can be run
without network access. This speeds things up quite a bit and makes
the tests more robust.

M  +6    -1    lib/cli.rb
M  +0    -2    lib/view.rb
M  +3    -2    spec/data/inqlude-all.json
M  +3    -2    spec/data/manifests/awesomelib/awesomelib.2013-09-08.manifest
M  +34   -31   spec/integration/cli_view_spec.rb
A  +64   -0    spec/online/cli_view_spec.rb
A  +5    -0    spec/online/spec_helper.rb
M  +1    -1    spec/unit/manifest_handler_spec.rb
M  +1    -1    spec/unit/manifest_spec.rb

http://commits.kde.org/websites/inqlude/7b22cec674822dcc264535312e9b3e540bc801ea

diff --git a/lib/cli.rb b/lib/cli.rb
index 03580d2..fdd249e 100644
--- a/lib/cli.rb
+++ b/lib/cli.rb
@@ -90,18 +90,23 @@ actual domain."
   def view
     process_global_options options
 
+    output_dir = options[:output_dir]
+    
     if options[:manifest_dir]
       @@settings.manifest_path = options[:manifest_dir]
     end
 
     manifest_handler = ManifestHandler.new(@@settings)
+
+    puts "Creating web site in '#{output_dir}' from \
'#{manifest_handler.settings.manifest_path}'" +
     manifest_handler.read_remote
 
     view = View.new(manifest_handler)
     view.enable_disqus = options[:enable_disqus]
     view.enable_search = !options[:disable_search]
     view.templates = options[:templates]
-    view.create options[:output_dir]
+    view.create output_dir
   end
 
   desc "show <library_name>", "Show library details"
diff --git a/lib/view.rb b/lib/view.rb
index adf3b7f..9f97403 100644
--- a/lib/view.rb
+++ b/lib/view.rb
@@ -24,8 +24,6 @@ class View
   end
 
   def create output_dir
-    puts "Creating web site in '#{output_dir}' from \
                '#{@manifest_handler.settings.manifest_path}'"
-    
     assert_dir output_dir
 
     system "cp #{view_dir}/favicon.ico #{output_dir}"
diff --git a/spec/data/inqlude-all.json b/spec/data/inqlude-all.json
index 4dc8243..65818b6 100644
--- a/spec/data/inqlude-all.json
+++ b/spec/data/inqlude-all.json
@@ -11,7 +11,8 @@
     ],
     "urls": {
       "homepage": "http://example.com",
-      "download": "http://example.com/download"
+      "download": "http://example.com/download",
+      "vcs": "http://example.com/git"
     },
     "licenses": [
       "LGPLv2.1+",
@@ -125,4 +126,4 @@
       "OS X"
     ]
   }
-]
\ No newline at end of file
+]
diff --git a/spec/data/manifests/awesomelib/awesomelib.2013-09-08.manifest \
b/spec/data/manifests/awesomelib/awesomelib.2013-09-08.manifest index \
                670be43..d2bbfc7 100644
--- a/spec/data/manifests/awesomelib/awesomelib.2013-09-08.manifest
+++ b/spec/data/manifests/awesomelib/awesomelib.2013-09-08.manifest
@@ -10,7 +10,8 @@
   ],
   "urls": {
     "homepage": "http://example.com",
-    "download": "http://example.com/download"
+    "download": "http://example.com/download",
+    "vcs": "http://example.com/git"
   },
   "licenses": [
     "LGPLv2.1+",
@@ -28,4 +29,4 @@
     "source": "ftp://example.com/download/awesomelib-0.2.0.tar.gz"
   },
   "group": "kde-frameworks"
-}
\ No newline at end of file
+}
diff --git a/spec/integration/cli_view_spec.rb b/spec/integration/cli_view_spec.rb
index 8200f80..252f2d1 100644
--- a/spec/integration/cli_view_spec.rb
+++ b/spec/integration/cli_view_spec.rb
@@ -44,8 +44,15 @@ describe "Command line interface" do
     
     context "inqlude-all.json" do
       before(:each) do
+        @manifest_dir = given_directory do
+          given_directory_from_data("awesomelib", from: "manifests/awesomelib")
+          given_directory_from_data("newlib", from: "manifests/newlib")
+        end
+
         @output_dir = given_directory
-        run_command(args: ["view", "--output-dir=#{@output_dir}"])
+
+        run_command(args: ["view",  "--offline", "--manifest_dir=#{@manifest_dir}",
+          "--output-dir=#{@output_dir}"])
       end
 
       it "generates view" do
@@ -63,6 +70,8 @@ describe "Command line interface" do
         parsed_data = JSON.parse(data);
 
         settings = Settings.new
+        settings.manifest_path = @manifest_dir
+        settings.offline = true
         handler = ManifestHandler.new settings
         handler.read_remote
 
@@ -73,44 +82,38 @@ describe "Command line interface" do
         data = File.read(File.join(@output_dir, 'inqlude-all.json'))
         parsed_data = JSON.parse(data);
         for element in parsed_data do
-          if element["name"] == "baloo"
+          if element["name"] == "awesomelib"
             library = element
             break
           end
         end
+        
+        expect(library).to be
 
         settings = Settings.new
         handler = ManifestHandler.new settings
+        settings.manifest_path = @manifest_dir
+        settings.offline = true
         handler.read_remote
-        manifest = handler.library("baloo").latest_manifest
-
-        (expect manifest.display_name).to eq library["display_name"]
-        (expect manifest.release_date).to eq library["release_date"]
-        (expect manifest.version).to eq library["version"]
-        (expect manifest.summary).to eq library["summary"]
-        (expect manifest.topics).to eq library["topics"]
-
-        (expect manifest.urls.homepage).to eq library["urls"]["homepage"]
-        (expect manifest.urls.api_docs).to eq library["urls"]["api_docs"]
-        (expect manifest.urls.download).to eq library["urls"]["download"]
-        (expect manifest.urls.tutorial).to eq library["urls"]["tutorial"]
-        (expect manifest.urls.vcs).to eq library["urls"]["vcs"]
-        (expect manifest.urls.description_source).to eq \
                library["urls"]["description_source"]
-        (expect manifest.urls.announcement).to eq library["urls"]["announcement"]
-        (expect manifest.urls.mailing_list).to eq library["urls"]["mailing_list"]
-        (expect manifest.urls.contact).to eq library["urls"]["contact"]
-        (expect manifest.urls.custom).to eq library["urls"]["custom"]
-
-        (expect manifest.licenses).to eq library["licenses"]
-        (expect manifest.description).to eq library["description"]
-        (expect manifest.authors).to eq library["authors"]
-        (expect manifest.maturity).to eq library["maturity"]
-
-        (expect manifest.packages.source).to eq library["packages"]["source"]
-        (expect manifest.packages.openSUSE).to eq library["packages"]["openSUSE"]
-        (expect manifest.packages.windows).to eq library["packages"]["windows"]
-        (expect manifest.packages.ubuntu).to eq library["packages"]["ubuntu"]
-        (expect manifest.packages.osx).to eq library["packages"]["osx"]
+
+        manifest = handler.library("awesomelib").latest_manifest
+
+        (expect manifest.display_name).to eq "Awesomelib"
+        (expect manifest.release_date).to eq "2013-09-08"
+        (expect manifest.version).to eq "0.2.0"
+        (expect manifest.summary).to eq "Awesome library"
+        (expect manifest.topics).to eq ["API"]
+
+        (expect manifest.urls.homepage).to eq "http://example.com"
+        (expect manifest.urls.download).to eq "http://example.com/download"
+        (expect manifest.urls.vcs).to eq "http://example.com/git"
+
+        (expect manifest.licenses).to eq ["LGPLv2.1+", "Commercial"]
+        (expect manifest.description).to eq "This is an awesome library."
+        (expect manifest.authors).to eq ["Cornelius Schumacher \
<schumacher@kde.org>"] +        (expect manifest.maturity).to eq "stable"
+
+        (expect manifest.packages.source).to eq \
"ftp://example.com/download/awesomelib-0.2.0.tar.gz"  end
     end
   end
diff --git a/spec/online/cli_view_spec.rb b/spec/online/cli_view_spec.rb
new file mode 100644
index 0000000..40f1c1a
--- /dev/null
+++ b/spec/online/cli_view_spec.rb
@@ -0,0 +1,64 @@
+require_relative "spec_helper"
+
+include CliTester
+
+describe "Command line interface" do
+  include GivenFilesystemSpecHelpers
+
+  use_given_filesystem
+
+  describe "view" do
+    before(:each) do
+      @output_dir = given_directory
+      run_command(args: ["view", "--output-dir=#{@output_dir}"])
+    end
+
+    it "generates inqlude-all.json from online data" do
+      data = File.read(File.join(@output_dir, 'inqlude-all.json'))
+      parsed_data = JSON.parse(data);
+
+      settings = Settings.new
+      handler = ManifestHandler.new settings
+      handler.read_remote
+
+      expect(handler.libraries.length).to eq parsed_data.length
+
+      for element in parsed_data do
+        if element["name"] == "baloo"
+        library = element
+        break
+        end
+      end
+
+      manifest = handler.library("baloo").latest_manifest
+
+      (expect manifest.display_name).to eq library["display_name"]
+      (expect manifest.release_date).to eq library["release_date"]
+      (expect manifest.version).to eq library["version"]
+      (expect manifest.summary).to eq library["summary"]
+      (expect manifest.topics).to eq library["topics"]
+
+      (expect manifest.urls.homepage).to eq library["urls"]["homepage"]
+      (expect manifest.urls.api_docs).to eq library["urls"]["api_docs"]
+      (expect manifest.urls.download).to eq library["urls"]["download"]
+      (expect manifest.urls.tutorial).to eq library["urls"]["tutorial"]
+      (expect manifest.urls.vcs).to eq library["urls"]["vcs"]
+      (expect manifest.urls.description_source).to eq \
library["urls"]["description_source"] +      (expect manifest.urls.announcement).to \
eq library["urls"]["announcement"] +      (expect manifest.urls.mailing_list).to eq \
library["urls"]["mailing_list"] +      (expect manifest.urls.contact).to eq \
library["urls"]["contact"] +      (expect manifest.urls.custom).to eq \
library["urls"]["custom"] +
+      (expect manifest.licenses).to eq library["licenses"]
+      (expect manifest.description).to eq library["description"]
+      (expect manifest.authors).to eq library["authors"]
+      (expect manifest.maturity).to eq library["maturity"]
+
+      (expect manifest.packages.source).to eq library["packages"]["source"]
+      (expect manifest.packages.openSUSE).to eq library["packages"]["openSUSE"]
+      (expect manifest.packages.windows).to eq library["packages"]["windows"]
+      (expect manifest.packages.ubuntu).to eq library["packages"]["ubuntu"]
+      (expect manifest.packages.osx).to eq library["packages"]["osx"]
+    end
+  end
+end
diff --git a/spec/online/spec_helper.rb b/spec/online/spec_helper.rb
new file mode 100644
index 0000000..8d24c03
--- /dev/null
+++ b/spec/online/spec_helper.rb
@@ -0,0 +1,5 @@
+require "cli_tester"
+require "given_filesystem/spec_helpers"
+require "json"
+
+require_relative "../../lib/inqlude"
diff --git a/spec/unit/manifest_handler_spec.rb b/spec/unit/manifest_handler_spec.rb
index 627b6f6..6c20bc3 100644
--- a/spec/unit/manifest_handler_spec.rb
+++ b/spec/unit/manifest_handler_spec.rb
@@ -145,7 +145,7 @@ describe ManifestHandler do
   end
 
   it "generates inqlude-all.json" do
-    expected_json = File.read(test_data_path("inqlude-all.json"))
+    expected_json = File.read(test_data_path("inqlude-all.json")).chomp
     expect(mh.generate_inqlude_all).to eq expected_json
   end
 end
diff --git a/spec/unit/manifest_spec.rb b/spec/unit/manifest_spec.rb
index ea88443..3356aed 100644
--- a/spec/unit/manifest_spec.rb
+++ b/spec/unit/manifest_spec.rb
@@ -68,7 +68,7 @@ describe Manifest do
   it "writes JSON for release manifest" do
     filename = File.join settings.manifest_path, awesomelib_manifest_file
     manifest = Manifest.parse_file filename
-    expect( manifest.to_json ).to eq File.read( filename )
+    expect( manifest.to_json ).to eq File.read( filename ).chomp
   end
 
   it "writes JSON for generic manifest" do


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic