spec/spec_helper.rb in gemline-0.1.2 vs spec/spec_helper.rb in gemline-0.1.3
- old
+ new
@@ -9,5 +9,25 @@
RSpec.configure do |c|
end
+
+
+def stub_rubygems_json_output
+ Dir.glob(File.join(File.dirname(__FILE__),'samples', '*.json')).each do |f|
+ gem_name = $1 if f =~ /\/([\w\-]+).json$/
+ Gemline.stub!(:get_rubygem_json).with(gem_name).and_return(IO.read(f))
+ end
+end
+
+def grab_io
+ @stdout = StringIO.new; $stdout = @stdout;
+ @stderr = StringIO.new; $stderr = @stderr;
+
+ yield
+
+ @stdout.rewind; @stderr.rewind;
+
+ $stdout = STDOUT
+ $stderr = STDERR
+end