mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Stub ~/.aprc in specs to make sure custom defaults do not affect them
This commit is contained in:
parent
e2dc41c4eb
commit
bf3c9915b6
3 changed files with 32 additions and 20 deletions
|
@ -1,6 +1,9 @@
|
|||
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
||||
|
||||
describe "AwesomePrint" do
|
||||
before(:each) do
|
||||
stub_dotfile!
|
||||
end
|
||||
|
||||
describe "Array" do
|
||||
before(:each) do
|
||||
|
|
|
@ -20,17 +20,22 @@ if defined?(::Rails)
|
|||
column :created_at, :datetime
|
||||
end
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
describe "ActiveRecord instance" do
|
||||
describe "AwesomePrint/Rails" do
|
||||
before(:each) do
|
||||
@diana = User.new(:name => "Diana", :rank => 1, :admin => false, :created_at => "1992-10-10 12:30:00")
|
||||
@laura = User.new(:name => "Laura", :rank => 2, :admin => true, :created_at => "2003-05-26 14:15:00")
|
||||
@ap = AwesomePrint.new(:plain => true)
|
||||
stub_dotfile!
|
||||
end
|
||||
|
||||
it "display single record" do
|
||||
out = @ap.send(:awesome, @diana)
|
||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == <<-EOS.strip
|
||||
#------------------------------------------------------------------------------
|
||||
describe "ActiveRecord instance" do
|
||||
before(:each) do
|
||||
@diana = User.new(:name => "Diana", :rank => 1, :admin => false, :created_at => "1992-10-10 12:30:00")
|
||||
@laura = User.new(:name => "Laura", :rank => 2, :admin => true, :created_at => "2003-05-26 14:15:00")
|
||||
@ap = AwesomePrint.new(:plain => true)
|
||||
end
|
||||
|
||||
it "display single record" do
|
||||
out = @ap.send(:awesome, @diana)
|
||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == <<-EOS.strip
|
||||
#<User:0x01234567> {
|
||||
:id => nil,
|
||||
:name => "Diana",
|
||||
|
@ -39,11 +44,11 @@ if defined?(::Rails)
|
|||
:created_at => Sat, 10 Oct 1992 12:30:00 UTC +00:00
|
||||
}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
it "display multiple records" do
|
||||
out = @ap.send(:awesome, [ @diana, @laura ])
|
||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == <<-EOS.strip
|
||||
it "display multiple records" do
|
||||
out = @ap.send(:awesome, [ @diana, @laura ])
|
||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == <<-EOS.strip
|
||||
[
|
||||
[0] #<User:0x01234567> {
|
||||
:id => nil,
|
||||
|
@ -61,14 +66,14 @@ EOS
|
|||
}
|
||||
]
|
||||
EOS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
describe "ActiveRecord class" do
|
||||
it "should" do
|
||||
@ap = AwesomePrint.new(:plain => true)
|
||||
@ap.send(:awesome, User).should == <<-EOS.strip
|
||||
#------------------------------------------------------------------------------
|
||||
describe "ActiveRecord class" do
|
||||
it "should" do
|
||||
@ap = AwesomePrint.new(:plain => true)
|
||||
@ap.send(:awesome, User).should == <<-EOS.strip
|
||||
class User < ActiveRecord::Base {
|
||||
:id => :integer,
|
||||
:name => :string,
|
||||
|
@ -77,7 +82,7 @@ class User < ActiveRecord::Base {
|
|||
:created_at => :datetime
|
||||
}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,5 +5,9 @@ require 'spec'
|
|||
require 'spec/autorun'
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
|
||||
end
|
||||
|
||||
def stub_dotfile!
|
||||
dotfile = File.join(ENV["HOME"], ".aprc")
|
||||
File.should_receive(:readable?).at_least(:once).with(dotfile).and_return(false)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue