test/test_jim_installer.rb in jim-0.2.3 vs test/test_jim_installer.rb in jim-0.3.0.pre

- old
+ new

@@ -78,11 +78,11 @@ installer = Jim::Installer.new(fixture_path('jquery-1.4.1.js'), tmp_path, :name => 'myproject', :version => '1.1.1') assert installer.fetch assert installer.determine_name_and_version assert_equal 'myproject', installer.name assert_equal '1.1.1', installer.version - end + end should "have default version if version can not be determined" do installer = Jim::Installer.new(fixture_path('noversion.js'), tmp_path) assert installer.fetch assert installer.determine_name_and_version @@ -93,28 +93,28 @@ end context "install" do context "with a single file" do - setup do + setup do @installer = Jim::Installer.new(fixture_path('jquery-1.4.1.js'), tmp_path) assert @installer.install @install_path = File.join(tmp_path, 'lib', 'jquery-1.4.1') end - + should "install a package.json" do assert_readable @install_path, 'package.json' assert_file_contents(/\"name\"\:\s*\"jquery\"/, @install_path, 'package.json') end - + should "move file into install path at name/version" do assert_dir @install_path assert_readable @install_path, 'jquery.js' assert_equal fixture('jquery-1.4.1.js'), File.read(File.join(@install_path, 'jquery.js')) end end - + context "with a file that seems to be installed already" do should "raise error" do @installer = Jim::Installer.new(fixture_path('jquery-1.4.1.js'), tmp_path) assert @installer.install @install_path = File.join(tmp_path, 'lib', 'jquery-1.4.1') @@ -123,11 +123,11 @@ assert_raise(Jim::FileExists) { @installer.install } end end - + context "with a duplicate file" do should "skip install but not raise error" do @installer = Jim::Installer.new(fixture_path('jquery-1.4.1.js'), tmp_path) assert @installer.install @install_path = File.join(tmp_path, 'lib', 'jquery-1.4.1') @@ -161,11 +161,11 @@ should "not install files found in ignored directories" do assert_not_readable tmp_path, 'lib', 'test-2.0', 'test.js' assert_not_readable tmp_path, 'lib', 'test-0', 'test.js' end - + should "install a package.json" do json_path = @install_path + 'jquery.metadata-2.0' + 'package.json' assert_readable json_path assert_file_contents(/\"name\"\:\s*\"jquery\.metadata\"/, json_path) end @@ -195,42 +195,42 @@ assert_not_readable tmp_path, 'lib', 'qunit-spec-0.5.0', 'qunit-spec.js' assert_not_readable tmp_path, 'lib', 'qunit-spec-0', 'qunit-spec.js' assert_not_readable tmp_path, 'lib', 'test_sammy_application-0.5.0', 'test_sammy_application.js' assert_not_readable tmp_path, 'lib', 'test_sammy_application-0', 'test_sammy_application.js' end - + should "install a package.json" do json_path = @install_path + 'sammy-0.5.0' + 'package.json' assert_readable json_path assert_file_contents(/\"name\"\:\s*\"sammy\"/, json_path) - end + end end - + context "with an existing package.json" do setup do @installer = Jim::Installer.new(fixture_path('mustache.js'), tmp_path) @paths = @installer.install @install_path = tmp_path + 'lib' end - + should "return an array of paths" do assert @paths.is_a?(Array) assert @paths.all? {|p| p.is_a?(Pathname) } end should "install each js file found separately" do assert_dir tmp_path, 'lib', 'mustache-0.2.2' assert_readable tmp_path, 'lib', 'mustache-0.2.2', 'mustache.js' end - + should "merge initial package.json values" do json_path = @install_path + 'mustache-0.2.2' + 'package.json' assert_readable json_path assert_file_contents(/\"name\"\:\s*\"mustache\"/, json_path) assert_file_contents(/\"author\"\:\s*\"Jan Lehnardt\"/, json_path) end end - + end end end