1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00
awesome_print/spec/objects_spec.rb
Mauro George 526f907629 Improves spec runner harness, switches to better env detection.
Does not run rails specs when running mongoid specs

WIP Start of remove BRE to check tests

Remove old helper of active record

Use RSpec skip to skip AR specs

Run ActionView only when needed

Run ActiveSupport only when needed

Run Mongoid only when needed

Create ExtVerifier.require_dependencies

Run MongoMapper only when needed

Always load nokogiri specs

Always load ostruct specs

Run Ripple only when needed

Remove :: when check for defined constants

Require spec_helper directly

Remove 1.8.6 old monkey patch

Add some RSpec configs
2015-01-02 13:20:18 -05:00

85 lines
1.9 KiB
Ruby

require 'spec_helper'
RSpec.describe "Objects" do
before do
stub_dotfile!
end
after do
Object.instance_eval{ remove_const :Hello } if defined?(Hello)
end
describe "Formatting an object" do
it "attributes" do
class Hello
attr_reader :abra
attr_writer :ca
attr_accessor :dabra
def initialize
@abra, @ca, @dabra = 1, 2, 3
end
end
hello = Hello.new
out = hello.ai(:plain => true, :raw => true)
str = <<-EOS.strip
#<Hello:0x01234567
attr_accessor :dabra = 3,
attr_reader :abra = 1,
attr_writer :ca = 2
>
EOS
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect)
end
it "instance variables" do
class Hello
def initialize
@abra, @ca, @dabra = 1, 2, 3
end
end
hello = Hello.new
out = hello.ai(:plain => true, :raw => true)
str = <<-EOS.strip
#<Hello:0x01234567
@abra = 1,
@ca = 2,
@dabra = 3
>
EOS
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect)
end
it "attributes and instance variables" do
class Hello
attr_reader :abra
attr_writer :ca
attr_accessor :dabra
def initialize
@abra, @ca, @dabra = 1, 2, 3
@scooby, @dooby, @doo = 3, 2, 1
end
end
hello = Hello.new
out = hello.ai(:plain => true, :raw => true)
str = <<-EOS.strip
#<Hello:0x01234567
@doo = 1,
@dooby = 2,
@scooby = 3,
attr_accessor :dabra = 3,
attr_reader :abra = 1,
attr_writer :ca = 2
>
EOS
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect)
end
end
end