spec/integration/smoke_test.rb in hashrocket-mousetrap-0.1.1 vs spec/integration/smoke_test.rb in hashrocket-mousetrap-0.2.0
- old
+ new
@@ -1,36 +1,77 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-require 'pp'
+require File.dirname(__FILE__) + '/../../lib/mousetrap'
+require 'yaml'
+require 'activesupport'
-describe "The System" do
- before do
- settings = YAML.load_file(File.dirname(__FILE__) + '/settings.yml')
- Mousetrap.authenticate(settings['user'], settings['password'])
- Mousetrap.product_code = settings['product_code']
- end
+# Requires supporting files with custom matchers and macros, etc,
+# in ./support/ and its subdirectories.
+Dir["#{File.dirname(__FILE__)}/../support/**/*.rb"].each {|f| require f}
- it 'Customer.all' do
- puts Mousetrap::Customer.all.to_yaml
- end
+settings = YAML.load_file(File.dirname(__FILE__) + '/settings.yml')
+Mousetrap.authenticate(settings['user'], settings['password'])
+Mousetrap.product_code = settings['product_code']
- it "Customer.create" do
- email = random_email_address
-
- attributes = {
- 'code' => email,
- 'firstName' => 'Example',
- 'lastName' => 'Customer',
- 'email' => email,
- 'subscription' => {
- 'planCode' => 'TEST',
- 'ccFirstName' => 'Jon',
- 'ccLastName' => 'Larkowski',
- 'ccNumber' => '4111111111111111',
- 'ccExpiration' => '12-2012',
- 'ccZip' => '90210'
- }
- }
- customer = Mousetrap::Customer.create attributes
- puts customer
- end
-end
+
+all_customers = Mousetrap::Customer.all
+puts all_customers.inspect
+puts all_customers.to_yaml
+
+all_customers.each { |c| c.destroy }
+
+all_customers = Mousetrap::Customer.all
+puts all_customers.inspect
+puts all_customers.to_yaml
+
+__END__
+
+code = 'maasdxgliu@example.com'
+c = Mousetrap::Customer[code]
+puts c.to_yaml
+c.destroy
+
+puts '-' * 80
+c = Mousetrap::Customer[code]
+puts c.to_yaml
+
+
+
+
+
+email = random_email_address
+attributes = {
+ 'code' => email,
+ 'firstName' => 'Example',
+ 'lastName' => 'Customer',
+ 'email' => email,
+ 'subscription' => {
+ 'planCode' => 'TEST',
+ 'ccFirstName' => 'Jon',
+ 'ccLastName' => 'Larkowski',
+ 'ccNumber' => '4111111111111111',
+ 'ccExpiration' => '12-2012',
+ 'ccZip' => '90210'
+ }
+}
+
+customer = Mousetrap::Customer.create attributes
+puts customer
+
+
+
+
+puts Mousetrap::Plan.all.to_yaml
+puts Mousetrap::Customer['maasdxgliu@example.com'].to_yaml
+puts Mousetrap::Plan['TEST'].to_yaml
+puts Mousetrap::Customer.all.to_yaml
+
+
+customers_hash = Mousetrap::Customer['maasdxgliu@example.com']
+customer_hash = customers_hash['customers']['customer'].slice 'firstName', 'lastName', 'email', 'code'
+customer = Mousetrap::Customer.new customer_hash
+
+customer.first_name = random_string
+puts customer.save!
+
+customer_hash = Mousetrap::Customer['maasdxgliu@example.com']
+puts customer_hash.to_yaml
+