Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #inspect method to views #896

Merged
merged 1 commit into from Jul 3, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+134 −3
Diff settings

Always

Just for now

@@ -77,5 +77,9 @@ def raw_path(snapshot: :last)
def binary?
@item_rep.binary?
end

def inspect
"<#{self.class} item.identifier=#{item.identifier} name=#{name}>"
end
end
end
@@ -76,5 +76,9 @@ def reference
def raw_content
unwrap.content.string
end

def inspect
"<#{self.class} identifier=#{unwrap.identifier}>"
end
end
end
Copy path View file
@@ -23,5 +23,9 @@ def unwrap
def frozen?
unwrap.frozen?
end

def inspect
"<#{self.class}>"
end
end
end
@@ -88,4 +88,9 @@
expect(res).to eql([[:amount, 9000], [:animal, 'donkey']])
end
end

describe '#inspect' do
subject { view.inspect }
it { is_expected.to eql('<Nanoc::ConfigView>') }
end
end
@@ -1,4 +1,19 @@
# FIXME: fix name
describe Nanoc::ItemCollectionWithRepsView do
let(:view_class) { Nanoc::ItemWithRepsView }
it_behaves_like 'an identifiable collection'

describe '#inspect' do
let(:wrapped) do
Nanoc::Int::IdentifiableCollection.new(config)
end

let(:view) { described_class.new(wrapped, view_context) }
let(:view_context) { double(:view_context) }
let(:config) { { string_pattern_type: 'glob' } }

subject { view.inspect }

it { is_expected.to eql('<Nanoc::ItemCollectionWithRepsView>') }
end
end
@@ -129,4 +129,10 @@
end
end
end

describe '#inspect' do
subject { view.inspect }

it { is_expected.to eql('<Nanoc::ItemRepCollectionView>') }
end
end
@@ -212,4 +212,14 @@
expect(subject._context).to equal(view_context)
end
end

describe '#inspect' do
let(:item_rep) { Nanoc::Int::ItemRep.new(item, :jacques) }
let(:item) { Nanoc::Int::Item.new('asdf', {}, '/foo/') }
let(:view) { described_class.new(item_rep, view_context) }

subject { view.inspect }

it { is_expected.to eql('<Nanoc::ItemRepView item.identifier=/foo/ name=jacques>') }
end
end
@@ -331,4 +331,13 @@
describe '#raw_filename' do
# TODO: implement
end

describe '#inspect' do
let(:item) { Nanoc::Int::Item.new('content', {}, '/asdf/') }
let(:view) { described_class.new(item, nil) }

subject { view.inspect }

it { is_expected.to eql('<Nanoc::ItemWithRepsView identifier=/asdf/>') }
end
end
@@ -1,4 +1,18 @@
describe Nanoc::LayoutCollectionView do
let(:view_class) { Nanoc::LayoutView }
it_behaves_like 'an identifiable collection'

describe '#inspect' do
let(:wrapped) do
Nanoc::Int::IdentifiableCollection.new(config)
end

let(:view) { described_class.new(wrapped, view_context) }
let(:view_context) { double(:view_context) }
let(:config) { { string_pattern_type: 'glob' } }

subject { view.inspect }

it { is_expected.to eql('<Nanoc::LayoutCollectionView>') }
end
end
@@ -2,4 +2,13 @@
let(:entity_class) { Nanoc::Int::Layout }
let(:other_view_class) { Nanoc::ItemWithRepsView }
it_behaves_like 'a document view'

describe '#inspect' do
let(:item) { Nanoc::Int::Layout.new('content', {}, '/asdf/') }
let(:view) { described_class.new(item, nil) }

subject { view.inspect }

it { is_expected.to eql('<Nanoc::LayoutView identifier=/asdf/>') }
end
end
@@ -1,11 +1,16 @@
describe Nanoc::MutableConfigView do
describe '#[]=' do
let(:config) { {} }
let(:view) { described_class.new(config, nil) }
let(:config) { {} }
let(:view) { described_class.new(config, nil) }

describe '#[]=' do
it 'sets attributes' do
view[:awesomeness] = 'rather high'
expect(config[:awesomeness]).to eq('rather high')
end
end

describe '#inspect' do
subject { view.inspect }
it { is_expected.to eql('<Nanoc::MutableConfigView>') }
end
end
@@ -32,4 +32,18 @@
expect(ret).to equal(view)
end
end

describe '#inspect' do
let(:wrapped) do
Nanoc::Int::IdentifiableCollection.new(config)
end

let(:view) { described_class.new(wrapped, view_context) }
let(:view_context) { double(:view_context) }
let(:config) { { string_pattern_type: 'glob' } }

subject { view.inspect }

it { is_expected.to eql('<Nanoc::MutableItemCollectionView>') }
end
end
@@ -10,4 +10,13 @@
expect(view).not_to respond_to(:path)
expect(view).not_to respond_to(:reps)
end

describe '#inspect' do
let(:item) { Nanoc::Int::Item.new('content', {}, '/asdf/') }
let(:view) { described_class.new(item, nil) }

subject { view.inspect }

it { is_expected.to eql('<Nanoc::MutableItemView identifier=/asdf/>') }
end
end
@@ -32,4 +32,18 @@
expect(ret).to equal(view)
end
end

describe '#inspect' do
let(:wrapped) do
Nanoc::Int::IdentifiableCollection.new(config)
end

let(:view) { described_class.new(wrapped, view_context) }
let(:view_context) { double(:view_context) }
let(:config) { { string_pattern_type: 'glob' } }

subject { view.inspect }

it { is_expected.to eql('<Nanoc::MutableLayoutCollectionView>') }
end
end
@@ -1,4 +1,13 @@
describe Nanoc::MutableLayoutView do
let(:entity_class) { Nanoc::Int::Layout }
it_behaves_like 'a mutable document view'

describe '#inspect' do
let(:item) { Nanoc::Int::Item.new('content', {}, '/asdf/') }
let(:view) { described_class.new(item, nil) }

subject { view.inspect }

it { is_expected.to eql('<Nanoc::MutableLayoutView identifier=/asdf/>') }
end
end
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.