Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renamed commands to the ObjectAction scheme

  • Loading branch information...
commit 6fcebc79c6691a867f2447f038f3289d302a6e51 1 parent 1448563
@weppos weppos authored
Showing with 161 additions and 152 deletions.
  1. +2 −0  CHANGELOG.md
  2. +91 −90 lib/dnsimple/cli.rb
  3. +1 −1  lib/dnsimple/commands/{describe_certificate.rb → certificate_describe.rb}
  4. +1 −1  lib/dnsimple/commands/{list_certificates.rb → certificate_list.rb}
  5. +1 −1  lib/dnsimple/commands/{purchase_certificate.rb → certificate_purchase.rb}
  6. +1 −1  lib/dnsimple/commands/{submit_certificate.rb → certificate_submit.rb}
  7. +7 −5 lib/dnsimple/commands/{create_contact.rb → contact_create.rb}
  8. +1 −1  lib/dnsimple/commands/{delete_contact.rb → contact_delete.rb}
  9. +1 −1  lib/dnsimple/commands/{describe_contact.rb → contact_describe.rb}
  10. +1 −1  lib/dnsimple/commands/{list_contacts.rb → contact_list.rb}
  11. +1 −1  lib/dnsimple/commands/{update_contact.rb → contact_update.rb}
  12. +1 −1  lib/dnsimple/commands/{apply_template.rb → domain_apply_template.rb}
  13. +1 −1  lib/dnsimple/commands/{check_domain.rb → domain_check.rb}
  14. +1 −1  lib/dnsimple/commands/{clear_domain.rb → domain_clear.rb}
  15. +1 −1  lib/dnsimple/commands/{create_domain.rb → domain_create.rb}
  16. +1 −1  lib/dnsimple/commands/{delete_domain.rb → domain_delete.rb}
  17. +1 −1  lib/dnsimple/commands/{describe_domain.rb → domain_describe.rb}
  18. +1 −1  lib/dnsimple/commands/{list_domains.rb → domain_list.rb}
  19. +1 −1  lib/dnsimple/commands/{register_domain.rb → domain_register.rb}
  20. +1 −1  lib/dnsimple/commands/{transfer_domain.rb → domain_transfer.rb}
  21. +1 −1  lib/dnsimple/commands/{list_extended_attributes.rb → extended_attribute_list.rb}
  22. +1 −1  lib/dnsimple/commands/{describe_user.rb → me.rb}
  23. +1 −1  lib/dnsimple/commands/{create_record.rb → record_create.rb}
  24. +1 −1  lib/dnsimple/commands/{delete_record.rb → record_delete.rb}
  25. +1 −1  lib/dnsimple/commands/{describe_record.rb → record_describe.rb}
  26. +1 −1  lib/dnsimple/commands/{list_records.rb → record_list.rb}
  27. +1 −1  lib/dnsimple/commands/{update_record.rb → record_update.rb}
  28. +1 −1  lib/dnsimple/commands/{add_service.rb → service_add.rb}
  29. +1 −1  lib/dnsimple/commands/{describe_service.rb → service_describe.rb}
  30. +1 −1  lib/dnsimple/commands/{list_services.rb → service_list.rb}
  31. +1 −1  lib/dnsimple/commands/{list_applied_services.rb → service_list_applied.rb}
  32. +1 −1  lib/dnsimple/commands/{list_available_services.rb → service_list_available.rb}
  33. +1 −1  lib/dnsimple/commands/{remove_service.rb → service_remove.rb}
  34. +1 −1  lib/dnsimple/commands/{create_template.rb → template_create.rb}
  35. +1 −1  lib/dnsimple/commands/{delete_template.rb → template_delete.rb}
  36. +1 −1  lib/dnsimple/commands/{add_template_record.rb → template_record_create.rb}
  37. +1 −1  lib/dnsimple/commands/{delete_template_record.rb → template_record_delete.rb}
  38. +1 −1  lib/dnsimple/commands/{list_template_records.rb → template_record_list.rb}
  39. +1 −1  lib/dnsimple/commands/{list_templates.rb → templates_list.rb}
  40. +3 −4 spec/commands/{purchase_certificate_spec.rb → certificate_purchase_spec.rb}
  41. +3 −4 spec/commands/{submit_certificate_spec.rb → certificate_submit_spec.rb}
  42. +4 −4 spec/commands/{create_record_spec.rb → record_create_spec.rb}
  43. +2 −3 spec/commands/{list_records_spec.rb → records_list_spec.rb}
  44. +3 −6 spec/commands/{add_service_spec.rb → service_add_spec.rb}
  45. +10 −0 spec/spec_helper.rb
View
2  CHANGELOG.md
@@ -10,6 +10,8 @@
- CHANGED: Use Accept header to determine the request type instead of the .json suffix in the URL.
+- CHANGED: Renamed commands to the ObjectAction scheme (e.g. CreateDomain became DomainCreate).
+
- FIXED: Cucumber was trying to execute steps on dnsimple.com main website instead of given site.
- REMOVED: Removed DomainError, UserNotFound, CertificateNotFound, CertificateExists error classes.
View
181 lib/dnsimple/cli.rb
@@ -23,98 +23,99 @@ def execute(command_name, args, options={})
def commands
{
- 'info' => DNSimple::Commands::DescribeUser,
-
- 'check' => DNSimple::Commands::CheckDomain,
- 'create' => DNSimple::Commands::CreateDomain,
- 'register' => DNSimple::Commands::RegisterDomain,
- 'transfer' => DNSimple::Commands::TransferDomain,
- 'describe' => DNSimple::Commands::DescribeDomain,
- 'list' => DNSimple::Commands::ListDomains,
- 'delete' => DNSimple::Commands::DeleteDomain,
- 'clear' => DNSimple::Commands::ClearDomain,
- 'apply' => DNSimple::Commands::ApplyTemplate,
-
- 'record:describe' => DNSimple::Commands::DescribeRecord,
- 'record:create' => DNSimple::Commands::CreateRecord,
- 'record:list' => DNSimple::Commands::ListRecords,
- 'record:update' => DNSimple::Commands::UpdateRecord,
- 'record:delete' => DNSimple::Commands::DeleteRecord,
-
- 'template:create' => DNSimple::Commands::CreateTemplate,
- 'template:list' => DNSimple::Commands::ListTemplates,
- 'template:delete' => DNSimple::Commands::DeleteTemplate,
-
- 'template:list_records' => DNSimple::Commands::ListTemplateRecords,
- 'template:add_record' => DNSimple::Commands::AddTemplateRecord,
- 'template:delete_record' => DNSimple::Commands::DeleteTemplateRecord,
-
- 'contact:create' => DNSimple::Commands::CreateContact,
- 'contact:list' => DNSimple::Commands::ListContacts,
- 'contact:describe' => DNSimple::Commands::DescribeContact,
- 'contact:update' => DNSimple::Commands::UpdateContact,
- 'contact:delete' => DNSimple::Commands::DeleteContact,
-
- 'extended-attributes:list' => DNSimple::Commands::ListExtendedAttributes,
-
- 'service:list' => DNSimple::Commands::ListServices,
- 'service:describe' => DNSimple::Commands::DescribeService,
-
- 'service:applied' => DNSimple::Commands::ListAppliedServices,
- 'service:available' => DNSimple::Commands::ListAvailableServices,
- 'service:add' => DNSimple::Commands::AddService,
- 'service:remove' => DNSimple::Commands::RemoveService,
-
- 'certificate:list' => DNSimple::Commands::ListCertificates,
- 'certificate:describe' => DNSimple::Commands::DescribeCertificate,
- 'certificate:purchase' => DNSimple::Commands::PurchaseCertificate,
- 'certificate:submit' => DNSimple::Commands::SubmitCertificate
+ 'info' => DNSimple::Commands::Me,
+
+ 'list' => DNSimple::Commands::DomainList,
+ 'describe' => DNSimple::Commands::DomainDescribe,
+ 'check' => DNSimple::Commands::DomainCheck,
+ 'create' => DNSimple::Commands::DomainCreate,
+ 'register' => DNSimple::Commands::DomainRegister,
+ 'transfer' => DNSimple::Commands::DomainTransfer,
+ 'delete' => DNSimple::Commands::DomainDelete,
+ 'clear' => DNSimple::Commands::DomainClear,
+ 'apply' => DNSimple::Commands::DomainApplyTemplate,
+
+ 'record:describe' => DNSimple::Commands::RecordDescribe,
+ 'record:create' => DNSimple::Commands::RecordCreate,
+ 'record:list' => DNSimple::Commands::RecordList,
+ 'record:update' => DNSimple::Commands::RecordUpdate,
+ 'record:delete' => DNSimple::Commands::RecordDelete,
+
+ 'template:create' => DNSimple::Commands::TemplateCreate,
+ 'template:list' => DNSimple::Commands::TemplateList,
+ 'template:delete' => DNSimple::Commands::TemplateDelete,
+
+ 'template:list_records' => DNSimple::Commands::TemplateRecordList,
+ 'template:add_record' => DNSimple::Commands::TemplateRecordCreate,
+ 'template:delete_record' => DNSimple::Commands::TemplateRecordDelete,
+
+ 'contact:create' => DNSimple::Commands::ContactCreate,
+ 'contact:list' => DNSimple::Commands::ContactList,
+ 'contact:describe' => DNSimple::Commands::ContactDescribe,
+ 'contact:update' => DNSimple::Commands::ContactUpdate,
+ 'contact:delete' => DNSimple::Commands::ContactDelete,
+
+ 'extended-attributes:list' => DNSimple::Commands::ExtendedAttributeList,
+
+ 'service:list' => DNSimple::Commands::ServiceList,
+ 'service:describe' => DNSimple::Commands::ServiceDescribe,
+
+ 'service:applied' => DNSimple::Commands::ServiceListApplied,
+ 'service:available' => DNSimple::Commands::ServiceListAvailable,
+ 'service:add' => DNSimple::Commands::ServiceAdd,
+ 'service:remove' => DNSimple::Commands::ServiceRemove,
+
+ 'certificate:list' => DNSimple::Commands::CertificateList,
+ 'certificate:describe' => DNSimple::Commands::CertificateDescribe,
+ 'certificate:purchase' => DNSimple::Commands::CertificatePurchase,
+ 'certificate:submit' => DNSimple::Commands::CertificateSubmit,
}
end
end
end
-require 'dnsimple/commands/describe_user'
-require 'dnsimple/commands/check_domain'
-require 'dnsimple/commands/create_domain'
-require 'dnsimple/commands/register_domain'
-require 'dnsimple/commands/transfer_domain'
-require 'dnsimple/commands/describe_domain'
-require 'dnsimple/commands/list_domains'
-require 'dnsimple/commands/delete_domain'
-require 'dnsimple/commands/clear_domain'
-require 'dnsimple/commands/apply_template'
-
-require 'dnsimple/commands/describe_record'
-require 'dnsimple/commands/create_record'
-require 'dnsimple/commands/list_records'
-require 'dnsimple/commands/update_record'
-require 'dnsimple/commands/delete_record'
-
-require 'dnsimple/commands/create_template'
-require 'dnsimple/commands/list_templates'
-require 'dnsimple/commands/delete_template'
-require 'dnsimple/commands/list_template_records'
-require 'dnsimple/commands/add_template_record'
-require 'dnsimple/commands/delete_template_record'
-
-require 'dnsimple/commands/create_contact'
-require 'dnsimple/commands/list_contacts'
-require 'dnsimple/commands/describe_contact'
-require 'dnsimple/commands/update_contact'
-require 'dnsimple/commands/delete_contact'
-
-require 'dnsimple/commands/list_extended_attributes'
-
-require 'dnsimple/commands/list_services'
-require 'dnsimple/commands/describe_service'
-
-require 'dnsimple/commands/list_available_services'
-require 'dnsimple/commands/list_applied_services'
-require 'dnsimple/commands/add_service'
-require 'dnsimple/commands/remove_service'
-
-require 'dnsimple/commands/list_certificates'
-require 'dnsimple/commands/describe_certificate'
-require 'dnsimple/commands/purchase_certificate'
-require 'dnsimple/commands/submit_certificate'
+require 'dnsimple/commands/me'
+
+require 'dnsimple/commands/domain_list'
+require 'dnsimple/commands/domain_describe'
+require 'dnsimple/commands/domain_check'
+require 'dnsimple/commands/domain_create'
+require 'dnsimple/commands/domain_register'
+require 'dnsimple/commands/domain_transfer'
+require 'dnsimple/commands/domain_delete'
+require 'dnsimple/commands/domain_clear'
+require 'dnsimple/commands/domain_apply_template'
+
+require 'dnsimple/commands/record_list'
+require 'dnsimple/commands/record_describe'
+require 'dnsimple/commands/record_create'
+require 'dnsimple/commands/record_update'
+require 'dnsimple/commands/record_delete'
+
+require 'dnsimple/commands/template_list'
+require 'dnsimple/commands/template_create'
+require 'dnsimple/commands/template_delete'
+require 'dnsimple/commands/template_record_list'
+require 'dnsimple/commands/template_record_create'
+require 'dnsimple/commands/template_record_delete'
+
+require 'dnsimple/commands/contact_list'
+require 'dnsimple/commands/contact_describe'
+require 'dnsimple/commands/contact_create'
+require 'dnsimple/commands/contact_update'
+require 'dnsimple/commands/contact_delete'
+
+require 'dnsimple/commands/extended_attribute_list'
+
+require 'dnsimple/commands/service_list'
+require 'dnsimple/commands/service_describe'
+
+require 'dnsimple/commands/service_list_available'
+require 'dnsimple/commands/service_list_applied'
+require 'dnsimple/commands/service_add'
+require 'dnsimple/commands/service_remove'
+
+require 'dnsimple/commands/certificate_list'
+require 'dnsimple/commands/certificate_describe'
+require 'dnsimple/commands/certificate_purchase'
+require 'dnsimple/commands/certificate_submit'
View
2  ...dnsimple/commands/describe_certificate.rb → ...dnsimple/commands/certificate_describe.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DescribeCertificate
+ class CertificateDescribe
def execute(args, options = {})
domain_name = args.shift
certificate_id = args.shift
View
2  lib/dnsimple/commands/list_certificates.rb → lib/dnsimple/commands/certificate_list.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListCertificates
+ class CertificateList
def execute(args, options = {})
domain_name = args.shift
domain = DNSimple::Domain.find(domain_name)
View
2  ...dnsimple/commands/purchase_certificate.rb → ...dnsimple/commands/certificate_purchase.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class PurchaseCertificate
+ class CertificatePurchase
def execute(args, options = {})
domain_name = args.shift
name = args.shift
View
2  lib/dnsimple/commands/submit_certificate.rb → lib/dnsimple/commands/certificate_submit.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class SubmitCertificate
+ class CertificateSubmit
def execute(args, options = {})
domain_name = args.shift
certificate_id = args.shift
View
12 lib/dnsimple/commands/create_contact.rb → lib/dnsimple/commands/contact_create.rb
@@ -1,10 +1,11 @@
module DNSimple
module Commands
- class CreateContact
- # Execute the contact:create command.
- #
- # Args expected to be:
- # [name:value name:value ...]
+
+ # Command to create a contact.
+ #
+ # contact:create [ name:value name:value ... ]
+ #
+ class ContactCreate
def execute(args, options = {})
attributes = {}
attributes['state_province_choice'] = 'S'
@@ -17,5 +18,6 @@ def execute(args, options = {})
puts "Created contact #{contact.name} (id: #{contact.id})"
end
end
+
end
end
View
2  lib/dnsimple/commands/delete_contact.rb → lib/dnsimple/commands/contact_delete.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DeleteContact
+ class ContactDelete
def execute(args, options = {})
id = args.shift
View
2  lib/dnsimple/commands/describe_contact.rb → lib/dnsimple/commands/contact_describe.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DescribeContact
+ class ContactDescribe
def execute(args, options = {})
id = args.shift
contact = Contact.find(id)
View
2  lib/dnsimple/commands/list_contacts.rb → lib/dnsimple/commands/contact_list.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListContacts
+ class ContactList
def execute(args, options = {})
contacts = Contact.all
puts "Found #{contacts.length} contacts:"
View
2  lib/dnsimple/commands/update_contact.rb → lib/dnsimple/commands/contact_update.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class UpdateContact
+ class ContactUpdate
# Execute the contact:update command.
#
# Args expected:
View
2  lib/dnsimple/commands/apply_template.rb → ...nsimple/commands/domain_apply_template.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ApplyTemplate
+ class DomainApplyTemplate
def execute(args, options = {})
domain_name = args.shift
template_name = args.shift
View
2  lib/dnsimple/commands/check_domain.rb → lib/dnsimple/commands/domain_check.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class CheckDomain
+ class DomainCheck
def execute(args, options = {})
name = args.shift
response = Domain.check(name)
View
2  lib/dnsimple/commands/clear_domain.rb → lib/dnsimple/commands/domain_clear.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ClearDomain
+ class DomainClear
def execute(args, options = {})
name = args.shift
View
2  lib/dnsimple/commands/create_domain.rb → lib/dnsimple/commands/domain_create.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class CreateDomain
+ class DomainCreate
def execute(args, options = {})
name = args.shift
domain = Domain.create(name)
View
2  lib/dnsimple/commands/delete_domain.rb → lib/dnsimple/commands/domain_delete.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DeleteDomain
+ class DomainDelete
def execute(args, options = {})
name_or_id = args.shift
View
2  lib/dnsimple/commands/describe_domain.rb → lib/dnsimple/commands/domain_describe.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DescribeDomain
+ class DomainDescribe
def execute(args, options = {})
name = args.shift
domain = Domain.find(name)
View
2  lib/dnsimple/commands/list_domains.rb → lib/dnsimple/commands/domain_list.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListDomains
+ class DomainList
def execute(args, options = {})
domains = Domain.all
puts "Found #{domains.length} domains:"
View
2  lib/dnsimple/commands/register_domain.rb → lib/dnsimple/commands/domain_register.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class RegisterDomain
+ class DomainRegister
def execute(args, options = {})
name = args.shift
registrant = nil
View
2  lib/dnsimple/commands/transfer_domain.rb → lib/dnsimple/commands/domain_transfer.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class TransferDomain
+ class DomainTransfer
def execute(args, options = {})
name = args.shift
registrant = {:id => args.shift}
View
2  ...mple/commands/list_extended_attributes.rb → ...imple/commands/extended_attribute_list.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListExtendedAttributes
+ class ExtendedAttributeList
def execute(args, options = {})
tld = args.shift
extended_attributes = ExtendedAttribute.find(tld)
View
2  lib/dnsimple/commands/describe_user.rb → lib/dnsimple/commands/me.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DescribeUser
+ class Me
def execute(args, options = {})
puts "Connecting to #{Client.base_uri}"
user = User.me
View
2  lib/dnsimple/commands/create_record.rb → lib/dnsimple/commands/record_create.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class CreateRecord
+ class RecordCreate
def execute(args, options = {})
name = args.shift
record_name = args.shift
View
2  lib/dnsimple/commands/delete_record.rb → lib/dnsimple/commands/record_delete.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DeleteRecord
+ class RecordDelete
def execute(args, options = {})
domain_name = args.shift
id = args.shift
View
2  lib/dnsimple/commands/describe_record.rb → lib/dnsimple/commands/record_describe.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DescribeRecord
+ class RecordDescribe
def execute(args, options = {})
name = args.shift
id = args.shift
View
2  lib/dnsimple/commands/list_records.rb → lib/dnsimple/commands/record_list.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListRecords
+ class RecordList
def execute(args, options = {})
domain_name = args.shift
View
2  lib/dnsimple/commands/update_record.rb → lib/dnsimple/commands/record_update.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class UpdateRecord
+ class RecordUpdate
def execute(args, options = {})
attributes = {}
domain_name = args.shift
View
2  lib/dnsimple/commands/add_service.rb → lib/dnsimple/commands/service_add.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class AddService
+ class ServiceAdd
def execute(args, options = {})
domain_name = args.shift
domain = Domain.find(domain_name)
View
2  lib/dnsimple/commands/describe_service.rb → lib/dnsimple/commands/service_describe.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DescribeService
+ class ServiceDescribe
def execute(args, options = {})
short_name = args.shift
service = Service.find(short_name)
View
2  lib/dnsimple/commands/list_services.rb → lib/dnsimple/commands/service_list.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListServices
+ class ServiceList
def execute(args, options = {})
services = Service.all
puts "Found #{services.length} services:"
View
2  ...nsimple/commands/list_applied_services.rb → ...dnsimple/commands/service_list_applied.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListAppliedServices
+ class ServiceListApplied
def execute(args, options = {})
domain_name = args.shift
domain = Domain.find(domain_name)
View
2  ...imple/commands/list_available_services.rb → ...simple/commands/service_list_available.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListAvailableServices
+ class ServiceListAvailable
def execute(args, options = {})
domain_name = args.shift
domain = Domain.find(domain_name)
View
2  lib/dnsimple/commands/remove_service.rb → lib/dnsimple/commands/service_remove.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class RemoveService
+ class ServiceRemove
def execute(args, options = {})
domain_name = args.shift
domain = Domain.find(domain_name)
View
2  lib/dnsimple/commands/create_template.rb → lib/dnsimple/commands/template_create.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class CreateTemplate
+ class TemplateCreate
def execute(args, options = {})
name = args.shift
short_name = args.shift
View
2  lib/dnsimple/commands/delete_template.rb → lib/dnsimple/commands/template_delete.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DeleteTemplate
+ class TemplateDelete
def execute(args, options = {})
short_name = args.shift
template = Template.find(short_name)
View
2  lib/dnsimple/commands/add_template_record.rb → ...simple/commands/template_record_create.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class AddTemplateRecord
+ class TemplateRecordCreate
def execute(args, options = {})
short_name = args.shift
record_name = args.shift
View
2  ...simple/commands/delete_template_record.rb → ...simple/commands/template_record_delete.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class DeleteTemplateRecord
+ class TemplateRecordDelete
def execute(args, options = {})
short_name = args.shift
id = args.shift
View
2  ...nsimple/commands/list_template_records.rb → ...dnsimple/commands/template_record_list.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListTemplateRecords
+ class TemplateRecordList
def execute(args, options = {})
short_name = args.shift
template_records = TemplateRecord.all(short_name)
View
2  lib/dnsimple/commands/list_templates.rb → lib/dnsimple/commands/templates_list.rb
@@ -1,6 +1,6 @@
module DNSimple
module Commands
- class ListTemplates
+ class TemplateList
def execute(args, options = {})
templates = Template.all
puts "Found #{templates.length} templates:"
View
7 spec/commands/purchase_certificate_spec.rb → spec/commands/certificate_purchase_spec.rb
@@ -1,9 +1,8 @@
require 'spec_helper'
require 'dnsimple/certificate'
-require 'dnsimple/commands/purchase_certificate'
+require 'dnsimple/commands/certificate_purchase'
-describe DNSimple::Commands::PurchaseCertificate do
- let(:out) { StringIO.new }
+describe DNSimple::Commands::CertificatePurchase do
let(:domain_name) { 'example.com' }
let(:domain) { stub('domain') }
let(:contact) { stub('contact') }
@@ -19,7 +18,7 @@
with(domain, 'certname', contact).
returns(stub("certificate", :fqdn => domain_name))
- DNSimple::Commands::PurchaseCertificate.new(out).
+ DNSimple::Commands::CertificatePurchase.new.
execute([domain_name, 'certname', stub('contact id')])
end
end
View
7 spec/commands/submit_certificate_spec.rb → spec/commands/certificate_submit_spec.rb
@@ -1,8 +1,7 @@
require 'spec_helper'
-require 'dnsimple/commands/submit_certificate'
+require 'dnsimple/commands/certificate_submit'
-describe DNSimple::Commands::SubmitCertificate do
- let(:out) { StringIO.new }
+describe DNSimple::Commands::CertificateSubmit do
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
let(:domain_name) { 'example.com' }
let(:name) { 'www' }
@@ -14,6 +13,6 @@
DNSimple::Domain.stubs(:find).with(domain_name).returns(domain)
DNSimple::Certificate.expects(:find).with(domain, certificate_id).returns(certificate)
certificate.expects(:submit).with(approver_email)
- DNSimple::Commands::SubmitCertificate.new(out).execute([domain_name, certificate_id, approver_email])
+ DNSimple::Commands::CertificateSubmit.new.execute([domain_name, certificate_id, approver_email])
end
end
View
8 spec/commands/create_record_spec.rb → spec/commands/record_create_spec.rb
@@ -1,14 +1,14 @@
require 'spec_helper'
require 'dnsimple/domain'
require 'dnsimple/record'
-require 'dnsimple/commands/create_record'
+require 'dnsimple/commands/record_create'
-describe DNSimple::Commands::CreateRecord do
- let(:out) { StringIO.new }
+describe DNSimple::Commands::RecordCreate do
let(:domain_name) { 'example.com' }
let(:record_name) { 'www' }
let(:record_type) { 'CNAME' }
let(:ttl) { "3600" }
+
context "with one argument" do
it "purchases the certificate" do
domain_stub = stub("domain", :name => domain_name)
@@ -16,7 +16,7 @@
DNSimple::Domain.expects(:find).with(domain_name).returns(domain_stub)
DNSimple::Record.expects(:create).with(domain_stub, record_name, record_type, domain_name, :ttl => ttl, :prio => nil).returns(record_stub)
- DNSimple::Commands::CreateRecord.new(out).execute([domain_name, record_name, record_type, domain_name, ttl])
+ DNSimple::Commands::RecordCreate.new.execute([domain_name, record_name, record_type, domain_name, ttl])
end
end
end
View
5 spec/commands/list_records_spec.rb → spec/commands/records_list_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
-require 'dnsimple/commands/list_records'
+require 'dnsimple/commands/record_list'
-describe DNSimple::Commands::ListRecords do
+describe DNSimple::Commands::RecordList do
before do
DNSimple::Record.expects(:all).with(instance_of(DNSimple::Domain)).returns(records)
end
@@ -18,7 +18,6 @@
let(:args) { [ domain_name ] }
let(:domain_name) { 'example.com' }
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
- let(:out) { StringIO.new }
end
View
9 spec/commands/add_service_spec.rb → spec/commands/service_add_spec.rb
@@ -1,12 +1,9 @@
require 'spec_helper'
-require 'dnsimple/commands/add_service'
-
-describe DNSimple::Commands::AddService do
- let(:out) { StringIO.new }
+require 'dnsimple/commands/service_add'
+describe DNSimple::Commands::ServiceAdd do
let(:domain_name) { 'example.com' }
let(:short_name) { 'service-name' }
- let(:args) { [domain_name, short_name] }
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
let(:service) { stub("service", :name => "Service") }
@@ -18,6 +15,6 @@
it "adds a service to a domain" do
domain.expects(:add_service).with(short_name)
- DNSimple::Commands::AddService.new(out).execute(args)
+ DNSimple::Commands::ServiceAdd.new.execute([domain_name, short_name])
end
end
View
10 spec/spec_helper.rb
@@ -24,4 +24,14 @@
RSpec.configure do |c|
c.mock_framework = :mocha
c.extend VCR::RSpec::Macros
+
+ # Silent the puts call in the commands
+ c.before do
+ @_stdout = $stdout
+ $stdout = StringIO.new
+ end
+ c.after do
+ $stdout = @_stdout
+ end
end
+
Please sign in to comment.
Something went wrong with that request. Please try again.