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

Allow Class Resources, call #to_s for defined resource_name #238

Merged
merged 1 commit into from
Dec 23, 2015
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions lib/rspec_api_documentation/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ module DSL
# +block+:: Block to pass into describe
#
def resource(*args, &block)
options = if args.last.is_a?(Hash) then args.pop else {} end
options = args.last.is_a?(Hash) ? args.pop : {}
options[:api_doc_dsl] = :resource
options[:resource_name] = args.first
options[:resource_name] = args.first.to_s
options[:document] ||= :all
args.push(options)
describe(*args, &block)
Expand Down
7 changes: 7 additions & 0 deletions spec/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,10 @@
expect(example.metadata[:document]).to eq(:not_all)
end
end

class Order; end
resource Order do
it 'should have a string resource_name' do |example|
expect(example.metadata[:resource_name]).to eq(Order.to_s)
end
end