mvnizer 0.6.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +52 -0
- data/.travis.yml +5 -2
- data/CHANGELOG.org +24 -0
- data/Dockerfile +19 -0
- data/Gemfile +9 -13
- data/Gemfile.lock +40 -104
- data/README.org +8 -7
- data/Rakefile +1 -23
- data/conf/default.yml +2 -2
- data/lib/mvnizer/templates/pom.xml.erb +3 -3
- data/lib/mvnizer/version.rb +1 -1
- data/mvnizer.gemspec +16 -109
- metadata +9 -136
- data/features/new_project.feature +0 -39
- data/features/search_artefact.feature +0 -14
- data/features/step_definitions/pom_steps.rb +0 -18
- data/features/support/env.rb +0 -24
- data/spec/commands/add_dependency_spec.rb +0 -25
- data/spec/commands/new_project_spec.rb +0 -38
- data/spec/commands/new_war_project_spec.rb +0 -58
- data/spec/commands/project_factory_spec.rb +0 -22
- data/spec/commands/search_artefact_spec.rb +0 -94
- data/spec/configuration_spec.rb +0 -28
- data/spec/coordinate_parser_spec.rb +0 -92
- data/spec/dummy.txt.erb +0 -1
- data/spec/dummy_pom.xml +0 -30
- data/spec/mvnize_spec.rb +0 -100
- data/spec/project_spec.rb +0 -29
- data/spec/spec_helper.rb +0 -11
- data/spec/task_helper_spec.rb +0 -66
metadata
CHANGED
@@ -1,127 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mvnizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sébastien Le Callonnec
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: httparty
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.16.2
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.16.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: nokogiri
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.2
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.8.2
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "<"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '11.0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "<"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '11.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.99.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 2.99.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec-mocks
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 2.99.4
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.99.4
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: fakefs
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.14.2
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.14.2
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: jeweler
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 2.3.9
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 2.3.9
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: aruba
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.14.5
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.14.5
|
11
|
+
date: 2020-10-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
125
13
|
description: Bootstrap a Maven project without the pain of archetypes.
|
126
14
|
email: sebastien@weblogism.com
|
127
15
|
executables:
|
@@ -131,9 +19,11 @@ extra_rdoc_files:
|
|
131
19
|
- LICENSE.txt
|
132
20
|
- README.org
|
133
21
|
files:
|
22
|
+
- ".gitignore"
|
134
23
|
- ".rspec"
|
135
24
|
- ".travis.yml"
|
136
25
|
- CHANGELOG.org
|
26
|
+
- Dockerfile
|
137
27
|
- Gemfile
|
138
28
|
- Gemfile.lock
|
139
29
|
- LICENSE.txt
|
@@ -142,10 +32,6 @@ files:
|
|
142
32
|
- TODO.org
|
143
33
|
- bin/mvnizer
|
144
34
|
- conf/default.yml
|
145
|
-
- features/new_project.feature
|
146
|
-
- features/search_artefact.feature
|
147
|
-
- features/step_definitions/pom_steps.rb
|
148
|
-
- features/support/env.rb
|
149
35
|
- lib/mvnizer.rb
|
150
36
|
- lib/mvnizer/commands.rb
|
151
37
|
- lib/mvnizer/commands/add_dependency.rb
|
@@ -174,24 +60,11 @@ files:
|
|
174
60
|
- ragel/coordinate.rb
|
175
61
|
- ragel/coordinate.rl
|
176
62
|
- ragel/test_coord.rb
|
177
|
-
- spec/commands/add_dependency_spec.rb
|
178
|
-
- spec/commands/new_project_spec.rb
|
179
|
-
- spec/commands/new_war_project_spec.rb
|
180
|
-
- spec/commands/project_factory_spec.rb
|
181
|
-
- spec/commands/search_artefact_spec.rb
|
182
|
-
- spec/configuration_spec.rb
|
183
|
-
- spec/coordinate_parser_spec.rb
|
184
|
-
- spec/dummy.txt.erb
|
185
|
-
- spec/dummy_pom.xml
|
186
|
-
- spec/mvnize_spec.rb
|
187
|
-
- spec/project_spec.rb
|
188
|
-
- spec/spec_helper.rb
|
189
|
-
- spec/task_helper_spec.rb
|
190
63
|
homepage: http://github.com/tychobrailleur/mvnizer
|
191
64
|
licenses:
|
192
65
|
- MIT
|
193
66
|
metadata: {}
|
194
|
-
post_install_message:
|
67
|
+
post_install_message:
|
195
68
|
rdoc_options: []
|
196
69
|
require_paths:
|
197
70
|
- lib
|
@@ -206,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
79
|
- !ruby/object:Gem::Version
|
207
80
|
version: '0'
|
208
81
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
210
|
-
signing_key:
|
82
|
+
rubygems_version: 3.1.2
|
83
|
+
signing_key:
|
211
84
|
specification_version: 4
|
212
85
|
summary: Bootstrap a Maven project without the pain of archetypes.
|
213
86
|
test_files: []
|
@@ -1,39 +0,0 @@
|
|
1
|
-
Feature: Create a new Maven project
|
2
|
-
|
3
|
-
In order to rapidly run a project
|
4
|
-
As a user of Mvnizer
|
5
|
-
I want to quickly create Maven projects
|
6
|
-
|
7
|
-
Scenario: create a jar project
|
8
|
-
Given a directory named "foo"
|
9
|
-
When I run `mvnizer new com.weblogism:foonbar`
|
10
|
-
Then the output should contain "success"
|
11
|
-
And a file named "foonbar/.gitignore" should exist
|
12
|
-
And a file named "foonbar/pom.xml" should exist
|
13
|
-
And "/project/groupId" in the xml file "foonbar/pom.xml" should be "com.weblogism"
|
14
|
-
And "/project/artifactId" in the xml file "foonbar/pom.xml" should be "foonbar"
|
15
|
-
And "/project/name" in the xml file "foonbar/pom.xml" should be "foonbar"
|
16
|
-
And "/project/version" in the xml file "foonbar/pom.xml" should be "0.0.1-SNAPSHOT"
|
17
|
-
And "/project/packaging" should not be in the xml file "foonbar/pom.xml"
|
18
|
-
And a file named "foonbar/src/main/webapp/WEB-INF/web.xml" should not exist
|
19
|
-
|
20
|
-
Scenario: create a war project
|
21
|
-
Given a directory named "foo"
|
22
|
-
When I run `mvnizer new com.weblogism:foonbar:war`
|
23
|
-
Then the output should contain "success"
|
24
|
-
And a file named "foonbar/.gitignore" should exist
|
25
|
-
And a file named "foonbar/pom.xml" should exist
|
26
|
-
And "/project/groupId" in the xml file "foonbar/pom.xml" should be "com.weblogism"
|
27
|
-
And "/project/artifactId" in the xml file "foonbar/pom.xml" should be "foonbar"
|
28
|
-
And "/project/name" in the xml file "foonbar/pom.xml" should be "foonbar"
|
29
|
-
And "/project/version" in the xml file "foonbar/pom.xml" should be "0.0.1-SNAPSHOT"
|
30
|
-
And "/project/packaging" in the xml file "foonbar/pom.xml" should be "war"
|
31
|
-
And a file named "foonbar/src/main/webapp/WEB-INF/web.xml" should exist
|
32
|
-
|
33
|
-
Scenario: add the dependencies
|
34
|
-
Given a directory named "foo"
|
35
|
-
When I run `mvnizer new com.weblogism:foonbar`
|
36
|
-
Then "/project/dependencies/dependency/groupId" in the xml file "foonbar/pom.xml" should be "junit"
|
37
|
-
And "/project/dependencies/dependency/artifactId" in the xml file "foonbar/pom.xml" should be "junit"
|
38
|
-
And "/project/dependencies/dependency/version" in the xml file "foonbar/pom.xml" should be "4.12"
|
39
|
-
And "/project/dependencies/dependency/scope" in the xml file "foonbar/pom.xml" should be "test"
|
@@ -1,14 +0,0 @@
|
|
1
|
-
Feature: Search for a Maven artefact
|
2
|
-
|
3
|
-
In order to easily find dependencies
|
4
|
-
As a user of Mvnizer
|
5
|
-
I want to search the Maven central repositories through the command line
|
6
|
-
|
7
|
-
Scenario: search for log4j
|
8
|
-
When I run `mvnizer search log4j`
|
9
|
-
Then the output should contain "log4j:log4j:"
|
10
|
-
And the output should contain "org.apache.logging.log4j:log4j"
|
11
|
-
|
12
|
-
Scenario: message when no result
|
13
|
-
When I run `mvnizer search ffffl`
|
14
|
-
Then the output should contain "No result found"
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
Then /^"([^"]+)" should not be in the xml file "([^"]+)"$/ do |xpath,path|
|
4
|
-
in_current_dir do
|
5
|
-
doc = Nokogiri::XML(File.open(path))
|
6
|
-
doc.remove_namespaces!
|
7
|
-
doc.xpath(xpath).first.should be_nil
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
Then /^"([^"]+)" in the xml file "([^"]+)" should be "([^"]+)"$/ do |xpath,path,value|
|
13
|
-
in_current_dir do
|
14
|
-
doc = Nokogiri::XML(File.open(path))
|
15
|
-
doc.remove_namespaces!
|
16
|
-
doc.xpath(xpath).first.text().should == value
|
17
|
-
end
|
18
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'aruba/cucumber'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
root_dir = File.join(File.dirname(__FILE__), '..', '..')
|
5
|
-
bin_dir = File.expand_path(File.join(root_dir, 'bin'))
|
6
|
-
# FIXME: This actually doesn't work:
|
7
|
-
# aruba doesn't find the mvnizer script unless it is added to the PATH
|
8
|
-
# outside ruby.
|
9
|
-
ENV['PATH'] = "#{bin_dir}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
10
|
-
|
11
|
-
|
12
|
-
Before do
|
13
|
-
@aruba_timeout_seconds = 30
|
14
|
-
end
|
15
|
-
|
16
|
-
# Aruba.configure do |config|
|
17
|
-
# config.before_cmd do |cmd|
|
18
|
-
# puts "About to run '#{cmd}' with path = #{ENV["PATH"]}"
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
|
22
|
-
After do
|
23
|
-
FileUtils.rm_rf("#{root_dir}/tmp")
|
24
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Mvnizer
|
4
|
-
module Command
|
5
|
-
describe AddDependency do
|
6
|
-
let (:file) { double("file") }
|
7
|
-
|
8
|
-
subject { AddDependency.new }
|
9
|
-
it "checks the pom can be found in the current directory" do
|
10
|
-
lambda { subject.run({}) }.should raise_error(FileNotFoundError, "The pom.xml file cannot be found.")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "adds a dependency" do
|
14
|
-
options = { name: "test" }
|
15
|
-
|
16
|
-
File.should_receive(:exists?).and_return(true)
|
17
|
-
subject.should_receive(:add_dependency).with(["test"]).and_return("out")
|
18
|
-
File.should_receive(:open).with("pom.xml", "w").and_yield(file)
|
19
|
-
file.should_receive(:write).with("out")
|
20
|
-
|
21
|
-
subject.run(options)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
module Mvnizer
|
5
|
-
module Command
|
6
|
-
describe NewProject do
|
7
|
-
let(:coordinate_parser) { double("parser") }
|
8
|
-
let(:project) { Mvnizer::Project.new("com.example", "foobar", "1.0.0-SNAPSHOT", "war") }
|
9
|
-
subject { Mvnizer::Command::NewProject.new }
|
10
|
-
|
11
|
-
it "creates the project directory" do
|
12
|
-
subject.should_receive(:generate_file).exactly(3).times
|
13
|
-
subject.should_receive(:create_dir).with("foobar/src/main/java", "foobar/src/test/java")
|
14
|
-
|
15
|
-
subject.run(project)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "parses the extra dependencies and adds them" do
|
19
|
-
subject.should_receive(:get_dependencies).and_return(["foo:bar:1.0:jar:test"])
|
20
|
-
CoordinateParser.should_receive(:new).and_return(coordinate_parser)
|
21
|
-
coordinate_parser.should_receive(:parse_scoped_coordinates).with("foo:bar:1.0:jar:test").and_return("Blah")
|
22
|
-
subject.should_receive(:generate_file).exactly(3).times
|
23
|
-
subject.should_receive(:create_dir)
|
24
|
-
|
25
|
-
subject.run(project)
|
26
|
-
|
27
|
-
project.dependencies.first.should == "Blah"
|
28
|
-
end
|
29
|
-
|
30
|
-
it "generates the pom file" do
|
31
|
-
subject.should_receive(:generate_file).with(File.join(TaskHelper::TEMPLATE_DIR, "pom.xml.erb"), "foobar/pom.xml", project)
|
32
|
-
subject.should_receive(:generate_file).with(File.join(TaskHelper::TEMPLATE_DIR, "gitignore.erb"), "foobar/.gitignore", project)
|
33
|
-
subject.should_receive(:generate_file).with(File.join(TaskHelper::TEMPLATE_DIR, "editorconfig.erb"), "foobar/.editorconfig", project)
|
34
|
-
subject.run(project)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'mvnizer/commands/new_war_project'
|
3
|
-
|
4
|
-
module Mvnizer
|
5
|
-
module Command
|
6
|
-
describe NewWarProject do
|
7
|
-
|
8
|
-
let(:project) { Mvnizer::Project.new("test", "foobar", nil, nil) }
|
9
|
-
subject { Mvnizer::Command::NewWarProject.new }
|
10
|
-
|
11
|
-
before do
|
12
|
-
$run = false
|
13
|
-
class NewProject
|
14
|
-
alias old_run run
|
15
|
-
def run(project)
|
16
|
-
$run = true
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
subject.instance_variable_set(:@project, project)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "creates a basic project" do
|
24
|
-
subject.should_receive(:create_dir)
|
25
|
-
subject.should_receive(:generate_file).exactly(3).times
|
26
|
-
subject.run(project)
|
27
|
-
$run.should be true
|
28
|
-
end
|
29
|
-
|
30
|
-
it "creates the webapp directory" do
|
31
|
-
subject.should_receive(:create_dir).with("foobar/src/main/webapp/WEB-INF")
|
32
|
-
subject.should_receive(:generate_file).exactly(3).times
|
33
|
-
subject.run(project)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "generates all the webapp files file" do
|
37
|
-
subject.should_receive(:create_dir)
|
38
|
-
subject.should_receive(:generate_file).with(File.join(TaskHelper::TEMPLATE_DIR, "web.xml.erb"), "foobar/src/main/webapp/WEB-INF/web.xml", project)
|
39
|
-
subject.should_receive(:generate_file).with(File.join(TaskHelper::TEMPLATE_DIR, "war", "ExampleServlet.java.erb"), "foobar/src/main/java/test/foobar/ExampleServlet.java", project)
|
40
|
-
subject.should_receive(:generate_file).with(File.join(TaskHelper::TEMPLATE_DIR, "war", "index.jsp.erb"), "foobar/src/main/webapp/WEB-INF/index.jsp", project)
|
41
|
-
|
42
|
-
|
43
|
-
subject.run(project)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "adds the dependencies needed for a war file" do
|
47
|
-
deps = subject.get_dependencies
|
48
|
-
deps.include?("javax:javaee-web-api:6.0:jar:provided").should be true
|
49
|
-
end
|
50
|
-
|
51
|
-
after do
|
52
|
-
class NewProject
|
53
|
-
alias run old_run
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'mvnizer/commands/new_war_project'
|
4
|
-
|
5
|
-
module Mvnizer
|
6
|
-
module Command
|
7
|
-
describe ProjectFactory do
|
8
|
-
it "returns an instance of NewProject when passing jar" do
|
9
|
-
ProjectFactory.create("jar").should be_a(NewProject)
|
10
|
-
ProjectFactory.create("jar").should_not be_a(NewWarProject)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "returns an instance of NewWarProject when passing war" do
|
14
|
-
ProjectFactory.create("war").should be_a(NewWarProject)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "throws an error when unknown type is passed" do
|
18
|
-
lambda { ProjectFactory.create("foo") }.should raise_error(ArgumentError, "Don’t know how to create foo.")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
module Mvnizer
|
5
|
-
module Command
|
6
|
-
describe SearchArtefact do
|
7
|
-
|
8
|
-
subject { SearchArtefact.new }
|
9
|
-
before { subject.out = StringIO.new }
|
10
|
-
|
11
|
-
def httparty_response_mock(mock_response_content)
|
12
|
-
request_object = HTTParty::Request.new Net::HTTP::Get, '/'
|
13
|
-
response_object = Net::HTTPOK.new('1.1', 200, 'OK')
|
14
|
-
response_object.stub(:body => mock_response_content)
|
15
|
-
mock_response = HTTParty::Response.new(request_object, response_object, -> { mock_response_content })
|
16
|
-
end
|
17
|
-
|
18
|
-
def response_mock(klass)
|
19
|
-
response = klass.new('', '', '')
|
20
|
-
response.stub(:body)
|
21
|
-
response
|
22
|
-
end
|
23
|
-
|
24
|
-
it "performs a search in the Maven repository" do
|
25
|
-
options = { command:"search", name: "junit" }
|
26
|
-
SearchArtefact.should_receive(:get).with("http://search.maven.org/solrsearch/select?q=junit&rows=5&wt=json")
|
27
|
-
|
28
|
-
subject.run(options)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "displays the coordinates of the found artefacts" do
|
32
|
-
require 'json'
|
33
|
-
|
34
|
-
mock_response_content = JSON.parse(<<JSON)
|
35
|
-
{
|
36
|
-
"response": {
|
37
|
-
"numFound": "1",
|
38
|
-
"docs": [
|
39
|
-
{
|
40
|
-
"g": "blah",
|
41
|
-
"a": "blah",
|
42
|
-
"latestVersion": "1.0",
|
43
|
-
"p": "jar"
|
44
|
-
}
|
45
|
-
]
|
46
|
-
}
|
47
|
-
}
|
48
|
-
JSON
|
49
|
-
|
50
|
-
mock_response = httparty_response_mock(mock_response_content)
|
51
|
-
options = { command:"search", name: "junit" }
|
52
|
-
SearchArtefact.should_receive(:get).and_return(mock_response)
|
53
|
-
|
54
|
-
io = StringIO.new
|
55
|
-
subject.out = io
|
56
|
-
|
57
|
-
subject.run(options)
|
58
|
-
|
59
|
-
io.string.should =~ Regexp.new("blah:blah:1.0:jar")
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
it "displays an informative message when no result is found" do
|
64
|
-
mock_response_content = '{ "response": { "numFound": "0"} }'
|
65
|
-
mock_response = httparty_response_mock(mock_response_content)
|
66
|
-
|
67
|
-
options = { command:"search", name: "junit" }
|
68
|
-
SearchArtefact.should_receive(:get).and_return(mock_response)
|
69
|
-
|
70
|
-
io = StringIO.new
|
71
|
-
subject.out = io
|
72
|
-
|
73
|
-
subject.run(options)
|
74
|
-
|
75
|
-
io.string.should match("No result found.")
|
76
|
-
end
|
77
|
-
|
78
|
-
it "displays an error message when something went wrong" do
|
79
|
-
net_response = response_mock(Net::HTTPServerError)
|
80
|
-
SearchArtefact.should_receive(:get).and_return(net_response)
|
81
|
-
|
82
|
-
options = { command:"search", name: "junit" }
|
83
|
-
io = StringIO.new
|
84
|
-
subject.out = io
|
85
|
-
|
86
|
-
lambda { subject.run(options) }.should raise_error(SystemExit)
|
87
|
-
|
88
|
-
io.string.should match("Error during search: ")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|