{"action":"created","comment":{"url":"https://api.github.com/repos/yast/yast-network/pulls/comments/50951028","id":50951028,"diff_hunk":"@@ -0,0 +1,374 @@\n+#! /usr/bin/env rspec\n+\n+require_relative \"test_helper\"\n+\n+require \"yast\"\n+\n+Yast.import \"YaPI::NETWORK\"\n+Yast.import \"NetworkInterfaces\"\n+Yast.import \"Routing\"\n+Yast.import \"IP\"\n+Yast.import \"Service\"\n+Yast.import \"DNS\"\n+Yast.import \"LanItems\"\n+\n+describe Yast::YaPI::NETWORK do\n+  include YaPINetworkStub\n+\n+  describe \".Write\" do\n+\n+    context \"with routes\" do\n+      # Mock the system to do not break anything\n+      before do\n+        allow(Yast::Routing).to receive(:Read)\n+        allow(Yast::Routing).to receive(:Routes)\n+        allow(Yast::Routing).to receive(:Write)\n+      end\n+\n+      subject { Yast::YaPI::NETWORK.Write(\"route\" => route) }\n+\n+      let(:success) { { \"error\" => \"\", \"exit\" => \"0\" } }\n+\n+      context \"with no gateway in the default route\" do\n+        let(:route) { { \"default\" => nil } }\n+\n+        it \"returns success\" do\n+          expect(subject).to eq success\n+        end\n+\n+        it \"empties the routes\" do\n+          expect(Yast::Routing).to receive(:Routes=).with []\n+          subject\n+        end\n+      end\n+\n+      context \"with empty gateway in the default  route\" do\n+        let(:route) { { \"default\" => { \"via\" => \"\" } } }\n+\n+        it \"returns success\" do\n+          expect(subject).to eq success\n+        end\n+\n+        it \"empties the routes\" do\n+          expect(Yast::Routing).to receive(:Routes=).with []\n+          subject\n+        end\n+      end\n+\n+      context \"with a gateway in the default route\" do\n+        let(:route) { { \"default\" => { \"via\" => \"TheIP\" } } }\n+        before do\n+          expect(Yast::IP).to receive(:Check4).with(\"TheIP\").and_return valid\n+        end\n+\n+        context \"if it's a valid IP4\" do\n+          let(:valid) { true }\n+\n+          it \"returns success\" do\n+            expect(subject).to eq success\n+          end\n+\n+          it \"correctly modifies the routes\" do\n+            expect(Yast::Routing).to receive(:Routes=).with(\n+              [\n+                {\n+                  \"destination\" => \"default\",\n+                  \"gateway\"     => \"TheIP\",\n+                  \"netmask\"     => \"-\",\n+                  \"device\"      => \"-\"\n+                }\n+              ]\n+            )\n+            subject\n+          end\n+        end\n+\n+        context \"if it's not a valid IP4\" do\n+          let(:valid) { false }\n+\n+          it \"returns failure\" do\n+            res = subject\n+            expect(res[\"exit\"]).to eq \"-1\"\n+            expect(res[\"error\"]).to_not be_empty","path":"test/yapi_network_test.rb","position":92,"original_position":92,"commit_id":"3d56ce9e68f4de3be4f33dcc5dd4142681fed549","original_commit_id":"3d56ce9e68f4de3be4f33dcc5dd4142681fed549","user":{"login":"mchf","id":1579239,"avatar_url":"https://avatars.githubusercontent.com/u/1579239?v=3","gravatar_id":"","url":"https://api.github.com/users/mchf","html_url":"https://github.com/mchf","followers_url":"https://api.github.com/users/mchf/followers","following_url":"https://api.github.com/users/mchf/following{/other_user}","gists_url":"https://api.github.com/users/mchf/gists{/gist_id}","starred_url":"https://api.github.com/users/mchf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mchf/subscriptions","organizations_url":"https://api.github.com/users/mchf/orgs","repos_url":"https://api.github.com/users/mchf/repos","events_url":"https://api.github.com/users/mchf/events{/privacy}","received_events_url":"https://api.github.com/users/mchf/received_events","type":"User","site_admin":false},"body":"NP: ```not_to``` is better readable.","created_at":"2016-01-27T07:57:50Z","updated_at":"2016-01-27T07:57:50Z","html_url":"https://github.com/yast/yast-network/pull/379#discussion_r50951028","pull_request_url":"https://api.github.com/repos/yast/yast-network/pulls/379","_links":{"self":{"href":"https://api.github.com/repos/yast/yast-network/pulls/comments/50951028"},"html":{"href":"https://github.com/yast/yast-network/pull/379#discussion_r50951028"},"pull_request":{"href":"https://api.github.com/repos/yast/yast-network/pulls/379"}}},"pull_request":{"url":"https://api.github.com/repos/yast/yast-network/pulls/379","id":56864673,"html_url":"https://github.com/yast/yast-network/pull/379","diff_url":"https://github.com/yast/yast-network/pull/379.diff","patch_url":"https://github.com/yast/yast-network/pull/379.patch","issue_url":"https://api.github.com/repos/yast/yast-network/issues/379","number":379,"state":"open","locked":false,"title":"Added rspect tests for YaPI::NETWORK","user":{"login":"teclator","id":7056681,"avatar_url":"https://avatars.githubusercontent.com/u/7056681?v=3","gravatar_id":"","url":"https://api.github.com/users/teclator","html_url":"https://github.com/teclator","followers_url":"https://api.github.com/users/teclator/followers","following_url":"https://api.github.com/users/teclator/following{/other_user}","gists_url":"https://api.github.com/users/teclator/gists{/gist_id}","starred_url":"https://api.github.com/users/teclator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teclator/subscriptions","organizations_url":"https://api.github.com/users/teclator/orgs","repos_url":"https://api.github.com/users/teclator/repos","events_url":"https://api.github.com/users/teclator/events{/privacy}","received_events_url":"https://api.github.com/users/teclator/received_events","type":"User","site_admin":false},"body":"I added unit tests for Write and Read that was covered by the old testsuite tests.\r\n\r\nTo cover the 100% of the old tests others unit tests should be added to the modules involved.","created_at":"2016-01-22T09:33:45Z","updated_at":"2016-01-27T07:57:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51d10619eaa7f8d6f287483c87023b3a1d0908d6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yast/yast-network/pulls/379/commits","review_comments_url":"https://api.github.com/repos/yast/yast-network/pulls/379/comments","review_comment_url":"https://api.github.com/repos/yast/yast-network/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yast/yast-network/issues/379/comments","statuses_url":"https://api.github.com/repos/yast/yast-network/statuses/3d56ce9e68f4de3be4f33dcc5dd4142681fed549","head":{"label":"yast:yapi_network_test","ref":"yapi_network_test","sha":"3d56ce9e68f4de3be4f33dcc5dd4142681fed549","user":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"repo":{"id":4368160,"name":"yast-network","full_name":"yast/yast-network","owner":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yast/yast-network","description":"YaST module network","fork":false,"url":"https://api.github.com/repos/yast/yast-network","forks_url":"https://api.github.com/repos/yast/yast-network/forks","keys_url":"https://api.github.com/repos/yast/yast-network/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yast/yast-network/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yast/yast-network/teams","hooks_url":"https://api.github.com/repos/yast/yast-network/hooks","issue_events_url":"https://api.github.com/repos/yast/yast-network/issues/events{/number}","events_url":"https://api.github.com/repos/yast/yast-network/events","assignees_url":"https://api.github.com/repos/yast/yast-network/assignees{/user}","branches_url":"https://api.github.com/repos/yast/yast-network/branches{/branch}","tags_url":"https://api.github.com/repos/yast/yast-network/tags","blobs_url":"https://api.github.com/repos/yast/yast-network/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yast/yast-network/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yast/yast-network/git/refs{/sha}","trees_url":"https://api.github.com/repos/yast/yast-network/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yast/yast-network/statuses/{sha}","languages_url":"https://api.github.com/repos/yast/yast-network/languages","stargazers_url":"https://api.github.com/repos/yast/yast-network/stargazers","contributors_url":"https://api.github.com/repos/yast/yast-network/contributors","subscribers_url":"https://api.github.com/repos/yast/yast-network/subscribers","subscription_url":"https://api.github.com/repos/yast/yast-network/subscription","commits_url":"https://api.github.com/repos/yast/yast-network/commits{/sha}","git_commits_url":"https://api.github.com/repos/yast/yast-network/git/commits{/sha}","comments_url":"https://api.github.com/repos/yast/yast-network/comments{/number}","issue_comment_url":"https://api.github.com/repos/yast/yast-network/issues/comments{/number}","contents_url":"https://api.github.com/repos/yast/yast-network/contents/{+path}","compare_url":"https://api.github.com/repos/yast/yast-network/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yast/yast-network/merges","archive_url":"https://api.github.com/repos/yast/yast-network/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yast/yast-network/downloads","issues_url":"https://api.github.com/repos/yast/yast-network/issues{/number}","pulls_url":"https://api.github.com/repos/yast/yast-network/pulls{/number}","milestones_url":"https://api.github.com/repos/yast/yast-network/milestones{/number}","notifications_url":"https://api.github.com/repos/yast/yast-network/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yast/yast-network/labels{/name}","releases_url":"https://api.github.com/repos/yast/yast-network/releases{/id}","deployments_url":"https://api.github.com/repos/yast/yast-network/deployments","created_at":"2012-05-18T10:24:50Z","updated_at":"2016-01-13T18:48:47Z","pushed_at":"2016-01-26T14:40:18Z","git_url":"git://github.com/yast/yast-network.git","ssh_url":"git@github.com:yast/yast-network.git","clone_url":"https://github.com/yast/yast-network.git","svn_url":"https://github.com/yast/yast-network","homepage":"http://en.opensuse.org/Portal:YaST","size":24031,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":2,"forks":18,"open_issues":2,"watchers":5,"default_branch":"master"}},"base":{"label":"yast:master","ref":"master","sha":"e06f8272741ae6a7ee6965f034821f22dc5187ec","user":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"repo":{"id":4368160,"name":"yast-network","full_name":"yast/yast-network","owner":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yast/yast-network","description":"YaST module network","fork":false,"url":"https://api.github.com/repos/yast/yast-network","forks_url":"https://api.github.com/repos/yast/yast-network/forks","keys_url":"https://api.github.com/repos/yast/yast-network/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yast/yast-network/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yast/yast-network/teams","hooks_url":"https://api.github.com/repos/yast/yast-network/hooks","issue_events_url":"https://api.github.com/repos/yast/yast-network/issues/events{/number}","events_url":"https://api.github.com/repos/yast/yast-network/events","assignees_url":"https://api.github.com/repos/yast/yast-network/assignees{/user}","branches_url":"https://api.github.com/repos/yast/yast-network/branches{/branch}","tags_url":"https://api.github.com/repos/yast/yast-network/tags","blobs_url":"https://api.github.com/repos/yast/yast-network/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yast/yast-network/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yast/yast-network/git/refs{/sha}","trees_url":"https://api.github.com/repos/yast/yast-network/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yast/yast-network/statuses/{sha}","languages_url":"https://api.github.com/repos/yast/yast-network/languages","stargazers_url":"https://api.github.com/repos/yast/yast-network/stargazers","contributors_url":"https://api.github.com/repos/yast/yast-network/contributors","subscribers_url":"https://api.github.com/repos/yast/yast-network/subscribers","subscription_url":"https://api.github.com/repos/yast/yast-network/subscription","commits_url":"https://api.github.com/repos/yast/yast-network/commits{/sha}","git_commits_url":"https://api.github.com/repos/yast/yast-network/git/commits{/sha}","comments_url":"https://api.github.com/repos/yast/yast-network/comments{/number}","issue_comment_url":"https://api.github.com/repos/yast/yast-network/issues/comments{/number}","contents_url":"https://api.github.com/repos/yast/yast-network/contents/{+path}","compare_url":"https://api.github.com/repos/yast/yast-network/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yast/yast-network/merges","archive_url":"https://api.github.com/repos/yast/yast-network/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yast/yast-network/downloads","issues_url":"https://api.github.com/repos/yast/yast-network/issues{/number}","pulls_url":"https://api.github.com/repos/yast/yast-network/pulls{/number}","milestones_url":"https://api.github.com/repos/yast/yast-network/milestones{/number}","notifications_url":"https://api.github.com/repos/yast/yast-network/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yast/yast-network/labels{/name}","releases_url":"https://api.github.com/repos/yast/yast-network/releases{/id}","deployments_url":"https://api.github.com/repos/yast/yast-network/deployments","created_at":"2012-05-18T10:24:50Z","updated_at":"2016-01-13T18:48:47Z","pushed_at":"2016-01-26T14:40:18Z","git_url":"git://github.com/yast/yast-network.git","ssh_url":"git@github.com:yast/yast-network.git","clone_url":"https://github.com/yast/yast-network.git","svn_url":"https://github.com/yast/yast-network","homepage":"http://en.opensuse.org/Portal:YaST","size":24031,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":2,"forks":18,"open_issues":2,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yast/yast-network/pulls/379"},"html":{"href":"https://github.com/yast/yast-network/pull/379"},"issue":{"href":"https://api.github.com/repos/yast/yast-network/issues/379"},"comments":{"href":"https://api.github.com/repos/yast/yast-network/issues/379/comments"},"review_comments":{"href":"https://api.github.com/repos/yast/yast-network/pulls/379/comments"},"review_comment":{"href":"https://api.github.com/repos/yast/yast-network/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yast/yast-network/pulls/379/commits"},"statuses":{"href":"https://api.github.com/repos/yast/yast-network/statuses/3d56ce9e68f4de3be4f33dcc5dd4142681fed549"}}}}