| 48 | | it "should install a local gem (mocked)" #do |
|---|
| 49 | | # pending "Can't get the mocks to do what I want" |
|---|
| 50 | | # @mgr.gem_name = "merb-fake-plugin" |
|---|
| 51 | | # @mgr.plugin_installed?.should_not be_true |
|---|
| 52 | | # |
|---|
| 53 | | # version = mock("version") |
|---|
| 54 | | # version.should_receive(:version).and_return("1.2.3") |
|---|
| 55 | | # gemspec = mock("Gem::Specification") |
|---|
| 56 | | # gemspec.should_receive(:version).and_return(version) |
|---|
| 57 | | # gemspec.should_receive(:loaded_from). |
|---|
| 58 | | # and_return("/usr/local/lib/ruby/gems/1.8/specifications/merb-fake-plugin-1.2.3.gemspec") |
|---|
| 59 | | # |
|---|
| 60 | | # require 'rubygems/installer' |
|---|
| 61 | | # installer = mock("Gem::Installer") |
|---|
| 62 | | # installer.should_receive(:install).with(anything, anything).and_return(gemspec) |
|---|
| 63 | | # Gem::Installer.stub!(:new).and_return(installer) |
|---|
| 64 | | # |
|---|
| 65 | | # installed_gems = mock("SourceIndex") |
|---|
| 66 | | # installed_gems.should_receive(:search).twice.with("merb-fake-plugin").and_return([], [gemspec]) |
|---|
| 67 | | # Gem::SourceIndex.stub!(:from_installed_gems).and_return(installed_gems) |
|---|
| 68 | | # |
|---|
| 69 | | # @mgr.action("install", "merb-fake-plugin") |
|---|
| 70 | | # p @mgr.output.string |
|---|
| 71 | | # @mgr.output.string.should match(/Can't find gem...installing./) |
|---|
| 72 | | # @mgr.output.string.should match(/Attempting local install.../) |
|---|
| 73 | | # @mgr.output.string.should match(/No install script for merb-fake-plugin/) |
|---|
| 74 | | # @mgr.output.string.should match(/No Rakefile to copy for merb-fake-plugin/) |
|---|
| 75 | | # |
|---|
| 76 | | # @mgr.plugin_installed?.should be_true |
|---|
| 77 | | # File.read(PLUGIN_MANIFEST_FILE).should match(/merb-fake-plugin/) |
|---|
| 78 | | # end |
|---|
| | 48 | it "should install a local gem (mocked)" do |
|---|
| | 49 | pending "Can't get the mocks to do what I want" |
|---|
| | 50 | @mgr.gem_name = "merb-fake-plugin" |
|---|
| | 51 | @mgr.plugin_installed?.should_not be_true |
|---|
| | 52 | |
|---|
| | 53 | version = mock("version") |
|---|
| | 54 | version.should_receive(:version).and_return("1.2.3") |
|---|
| | 55 | gemspec = mock("Gem::Specification") |
|---|
| | 56 | gemspec.should_receive(:version).and_return(version) |
|---|
| | 57 | gemspec.should_receive(:loaded_from). |
|---|
| | 58 | and_return("/usr/local/lib/ruby/gems/1.8/specifications/merb-fake-plugin-1.2.3.gemspec") |
|---|
| | 59 | |
|---|
| | 60 | require 'rubygems/installer' |
|---|
| | 61 | installer = mock("Gem::Installer") |
|---|
| | 62 | installer.should_receive(:install).with(anything, anything).and_return(gemspec) |
|---|
| | 63 | Gem::Installer.stub!(:new).and_return(installer) |
|---|
| | 64 | |
|---|
| | 65 | installed_gems = mock("SourceIndex") |
|---|
| | 66 | installed_gems.should_receive(:search).twice.with("merb-fake-plugin").and_return([], [gemspec]) |
|---|
| | 67 | Gem::SourceIndex.stub!(:from_installed_gems).and_return(installed_gems) |
|---|
| | 68 | |
|---|
| | 69 | @mgr.action("install", "merb-fake-plugin") |
|---|
| | 70 | p @mgr.output.string |
|---|
| | 71 | @mgr.output.string.should match(/Can't find gem...installing./) |
|---|
| | 72 | @mgr.output.string.should match(/Attempting local install.../) |
|---|
| | 73 | @mgr.output.string.should match(/No install script for merb-fake-plugin/) |
|---|
| | 74 | @mgr.output.string.should match(/No Rakefile to copy for merb-fake-plugin/) |
|---|
| | 75 | |
|---|
| | 76 | @mgr.plugin_installed?.should be_true |
|---|
| | 77 | File.read(PLUGIN_MANIFEST_FILE).should match(/merb-fake-plugin/) |
|---|
| | 78 | end |
|---|