Skip to content

Commit

Permalink
Make tests work with rspec 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
johnf committed Oct 10, 2011
1 parent ea95ec5 commit 411fbce
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 25 deletions.
15 changes: 2 additions & 13 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,12 @@ Rake::GemPackageTask.new(gemspec) do |pkg|
end

begin
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
spec.spec_files = ['spec/**/*_spec.rb']
end

Spec::Rake::SpecTask.new(:rcov) do |spec|
spec.libs << 'lib' << 'spec'
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError
task :spec do
puts 'ERROR! RSpec not found, install it by running: sudo gem install rspec'
end

task :rcov => :spec
end

task :default => :spec
Expand Down
8 changes: 6 additions & 2 deletions lib/puppet/module/tool/applications/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def initialize(full_name, options)
def skeleton
@skeleton ||= Skeleton.new
end


def get_binding
binding
end

def run
if destination.directory?
abort "#{destination} already exists."
Expand Down Expand Up @@ -95,7 +99,7 @@ def target
end
def contents
template = ERB.new(read)
template.result(@generator.send(:binding))
template.result(@generator.send(:get_binding))
end
def install!
target.open('w') { |f| f.write contents }
Expand Down
14 changes: 7 additions & 7 deletions spec/integration/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ def app

app.install("#{@release_name}.tar.gz")

File.directory?(@full_name).should == true
File.file?(File.join(@full_name, 'metadata.json')).should == true
end.should =~ /Installed "myuser-mymodule-0.0.1" into directory: myuser-mymodule/
File.directory?(@module_name).should == true
File.file?(File.join(@module_name, 'metadata.json')).should == true
end.should =~ /Installed "myuser-mymodule-0.0.1" into directory: mymodule/
end

it "should install a module from a webserver URL" do
Expand All @@ -289,9 +289,9 @@ def app

app.install(@full_name)

File.directory?(@full_name).should == true
File.file?(File.join(@full_name, 'metadata.json')).should == true
end.should =~ /Installed #{@release_name.inspect} into directory: #{@full_name}/
File.directory?(@module_name).should == true
File.file?(File.join(@module_name, 'metadata.json')).should == true
end.should =~ /Installed #{@release_name.inspect} into directory: #{@module_name}/
end

it "should install a module from a webserver URL using a version requirement" # TODO
Expand Down Expand Up @@ -357,7 +357,7 @@ def app
end
puts "CHANGES:"
app.changes(".")
end.should =~ /CHANGES:.+Modulefile\s*\z/m
end.should match /CHANGES:.+Modulefile\s*metadata.json\s*\z/m
end
end

Expand Down
5 changes: 2 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'spec'
require 'spec/autorun'
require 'rspec'

require 'puppet/module/tool'

Dir[File.join(File.dirname(__FILE__), 'support', '*.rb')].each do |support_file|
require support_file
end

Spec::Runner.configure do |config|
RSpec.configure do |config|
config.mock_with :mocha
end

0 comments on commit 411fbce

Please sign in to comment.