diff --git a/Gemfile.lock b/Gemfile.lock index e7729e17..9f8961fe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ PATH specs: vraptor-scaffold (1.3.0) activesupport (= 3.0.1) - rake (= 0.9.2) + rake thor (= 0.14.6) GEM @@ -11,13 +11,28 @@ GEM specs: ZenTest (4.4.0) activesupport (3.0.1) - multi_json (1.0.3) - rake (0.9.2) - rspec (1.3.2) + coderay (1.0.6) + diff-lcs (1.1.3) + method_source (0.7.1) + multi_json (1.0.4) + pry (0.9.9.6) + coderay (~> 1.0.5) + method_source (~> 0.7.1) + slop (>= 2.4.4, < 3) + rake (0.9.2.2) + rspec (2.10.0) + rspec-core (~> 2.10.0) + rspec-expectations (~> 2.10.0) + rspec-mocks (~> 2.10.0) + rspec-core (2.10.1) + rspec-expectations (2.10.0) + diff-lcs (~> 1.1.3) + rspec-mocks (2.10.1) simplecov (0.5.4) multi_json (~> 1.0.3) simplecov-html (~> 0.5.3) simplecov-html (0.5.3) + slop (2.4.4) thor (0.14.6) PLATFORMS @@ -25,6 +40,7 @@ PLATFORMS DEPENDENCIES ZenTest (= 4.4.0) - rspec (= 1.3.2) + pry + rspec simplecov (= 0.5.4) vraptor-scaffold! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0ba82353..55b1af72 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,7 @@ require 'simplecov' +require 'pry' SimpleCov.start -require 'spec' -require 'spec/autorun' require File.dirname(__FILE__) + '/../lib/vraptor-scaffold' def build_attributes @@ -22,5 +21,5 @@ def mock_objectify_config_file def exists_and_identical?(source, created) c = File.open(created).read.gsub( /\r/m, "" ) c2 = File.open(source).read.gsub( /\r/m, "" ) - c.should be == c2 + c.should == c2 end diff --git a/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb b/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb index 8d5a6b8a..fc694ca5 100644 --- a/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb +++ b/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper") +require 'spec_helper' describe PluginGenerator do @@ -29,97 +29,82 @@ def expected_for(name) context "maven project" do before :each do - FileUtils.chdir(@maven_projet) - @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8"]) - @generator.build - back + backup @maven_projet, 'pom.xml' end - it "should inject dependency into pom.xml" do + it "should inject dependency into pom.xmlwith default" do + PluginGenerator.new("vraptor-environment", ["-v=0.0.8"]).build + back source = expected_for "default_org_pom.xml" destination = "#{@maven_projet}/pom.xml" exists_and_identical?(source, destination) end - end - context "maven project with plugin org" do - - before :each do - FileUtils.chdir(@maven_projet) - @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor.plugin"]) - @generator.build + it "injects dependency into pom.xml with provided org" do + PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor.plugin"]).build back - end - - it "should inject dependency into pom.xml" do source = expected_for "pom.xml" destination = "#{@maven_projet}/pom.xml" exists_and_identical?(source, destination) end + + after :each do + rollback @maven_projet, 'pom.xml' + end end context "ant project" do before :each do - FileUtils.chdir(@ant_projet) - @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8"]) - @generator.build - back + backup @ant_projet, 'ivy.xml' end - it "should inject dependency into ivy.xml" do + it "should inject dependency into ivy.xml with default org" do + PluginGenerator.new("vraptor-environment", ["-v=0.0.8"]).build + back source = expected_for "default_org_ivy.xml" destination = "#{@ant_projet}/ivy.xml" exists_and_identical?(source, destination) end - end - - context "ant project with plugin org" do - before :each do - FileUtils.chdir(@ant_projet) - @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor.plugin"]) - @generator.build + it "injects dependency into ivy.xml with provided org" do + PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor.plugin"]).build back - end - - it "should inject dependency into ivy.xml" do source = expected_for "ivy.xml" destination = "#{@ant_projet}/ivy.xml" exists_and_identical?(source, destination) end + + after :each do + rollback @ant_projet, 'ivy.xml' + end end context "gradle project" do before :each do - FileUtils.chdir(@gradle_projet) - @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8"]) - @generator.build - back + backup @gradle_projet, 'build.gradle' end - it "should inject dependency into build.gradle" do + it "injects dependency into build.gradle with default org" do + PluginGenerator.new("vraptor-environment", ["-v=0.0.8"]).build + back source = expected_for "default_org_build.gradle" destination = "#{@gradle_projet}/build.gradle" exists_and_identical?(source, destination) end - end - - context "gradle project with plugin org" do - - before :each do - FileUtils.chdir(@gradle_projet) - @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor.plugin"]) - @generator.build - back - end it "should inject dependency into build.gradle" do + PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor.plugin"]).build + back source = expected_for "build.gradle" destination = "#{@gradle_projet}/build.gradle" exists_and_identical?(source, destination) end + + after :each do + rollback @gradle_projet, 'build.gradle' + end end def back @@ -127,4 +112,12 @@ def back FileUtils.chdir("..") end + def backup dir_path, file_name + FileUtils.cp("#{dir_path}/#{file_name}", "#{dir_path}/#{file_name}.original") + FileUtils.chdir(dir_path) + end + + def rollback dir_path, file_name + FileUtils.cp("#{dir_path}/#{file_name}.original", "#{dir_path}/#{file_name}") + end end diff --git a/spec/vraptor-scaffold/http_request_spec.rb b/spec/vraptor-scaffold/http_request_spec.rb index 33cc521a..6b14ed56 100644 --- a/spec/vraptor-scaffold/http_request_spec.rb +++ b/spec/vraptor-scaffold/http_request_spec.rb @@ -21,7 +21,7 @@ it "should use 'http_proxy' env when it is present" do http = VraptorScaffold::HttpRequest.http - http.should be_true http.proxy_class? + http.proxy_class?.should be_true end end @@ -33,7 +33,7 @@ it "should not use proxy settings when no http_proxy env exists" do http = VraptorScaffold::HttpRequest.http - http.should be_true !http.proxy_class? + http.proxy_class?.should be_false end end diff --git a/vraptor-scaffold.gemspec b/vraptor-scaffold.gemspec index 119f9d3e..dc5a12e6 100644 --- a/vraptor-scaffold.gemspec +++ b/vraptor-scaffold.gemspec @@ -15,11 +15,12 @@ Gem::Specification.new do |s| s.add_dependency('thor', '0.14.6') s.add_dependency('activesupport', "3.0.1") - s.add_dependency('rake', '0.9.2') + s.add_dependency('rake') - s.add_development_dependency('rspec', '1.3.2') + s.add_development_dependency('rspec') s.add_development_dependency('ZenTest', '4.4.0') s.add_development_dependency('simplecov', '0.5.4') + s.add_development_dependency('pry') s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {spec}/*`.split("\n")