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

Spec fixup #222

Merged
merged 2 commits into from
Jul 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions spec/grape_extensions/grape_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@
require 'napa/grape_extensions/error_formatter'

describe Napa::GrapeHelpers do
describe 'represent' do
it 'should not rely on to_a if the data is enumerable with :map' do
class Foo
def to_a
puts "Called to_a"
end
def map
puts "Called map"
end
end
describe '#represent' do
it 'should not rely on to_a if the data is enumerable with :map' do
class Foo
end

class FooRepresenter < Napa::Representer
end
class FooRepresenter < Napa::Representer
end

class DummyClass
include Napa::GrapeHelpers
end
class DummyClass
include Napa::GrapeHelpers
end

foo = double("Foo")
expect(foo).not_to receive(:to_a)
expect(foo).to receive(:map) { ["foo", "bar"] }
foo = double("Foo")
expect(foo).not_to receive(:to_a)
expect(foo).to receive(:map) { ['foo', 'bar'] }

DummyClass.new.represent(foo, with: FooRepresenter)
end
DummyClass.new.represent(foo, with: FooRepresenter)
end
end
end
end