Skip to content

Commit

Permalink
Updating test suite to latest dependencies
Browse files Browse the repository at this point in the history
multi_json and active* are not updated in this commit
  • Loading branch information
ryansch committed Feb 14, 2013
1 parent 2bb4610 commit bf462ab
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 47 deletions.
35 changes: 18 additions & 17 deletions Gemfile.lock
Expand Up @@ -19,8 +19,8 @@ GEM
builder (3.0.4)
coderay (1.0.8)
diff-lcs (1.1.3)
factory_girl (2.1.2)
activesupport
factory_girl (4.2.0)
activesupport (>= 3.0.0)
faker (1.1.2)
i18n (~> 0.5)
fakeweb (1.3.0)
Expand All @@ -31,8 +31,9 @@ GEM
pry (>= 0.9.10)
terminal-table (>= 1.4.3)
thor (>= 0.14.6)
guard-rspec (0.5.11)
guard (>= 0.8.4)
guard-rspec (2.4.0)
guard (>= 1.1)
rspec (~> 2.11)
i18n (0.6.1)
listen (0.7.2)
lumberjack (1.0.2)
Expand All @@ -42,16 +43,16 @@ GEM
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rake (0.9.6)
rake (10.0.3)
rb-fsevent (0.9.3)
rspec (2.7.0)
rspec-core (~> 2.7.0)
rspec-expectations (~> 2.7.0)
rspec-mocks (~> 2.7.0)
rspec-core (2.7.1)
rspec-expectations (2.7.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.7.0)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.2)
slop (3.4.3)
terminal-table (1.4.5)
thor (0.17.0)
Expand All @@ -61,11 +62,11 @@ PLATFORMS

DEPENDENCIES
chargify_api_ares!
factory_girl (~> 2.1.0)
factory_girl (~> 4.2.0)
faker (~> 1.1.2)
fakeweb (~> 1.3.0)
growl (~> 1.0.3)
guard-rspec (~> 0.5.0)
rake (~> 0.9.2)
guard-rspec (~> 2.4.0)
rake (~> 10.0.3)
rb-fsevent (~> 0.9.2)
rspec (~> 2.7.0)
rspec (~> 2.12.0)
8 changes: 4 additions & 4 deletions chargify_api_ares.gemspec
Expand Up @@ -20,12 +20,12 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('activeresource', '>= 2.3.5')

# Development Dependencies
s.add_development_dependency('rake', '~> 0.9.2')
s.add_development_dependency('rspec', '~> 2.7.0')
s.add_development_dependency('factory_girl', '~> 2.1.0')
s.add_development_dependency('rake', '~> 10.0.3')
s.add_development_dependency('rspec', '~> 2.12.0')
s.add_development_dependency('factory_girl', '~> 4.2.0')
s.add_development_dependency('fakeweb', '~> 1.3.0')
s.add_development_dependency('faker', '~> 1.1.2')
s.add_development_dependency('guard-rspec', '~> 0.5.0')
s.add_development_dependency('guard-rspec', '~> 2.4.0')
s.add_development_dependency('growl', '~> 1.0.3')
s.add_development_dependency('rb-fsevent', '~> 0.9.2')
end
4 changes: 2 additions & 2 deletions spec/factories.rb
Expand Up @@ -22,14 +22,14 @@
factory :customer, :class => Chargify::Customer do |f|
f.first_name { Faker::Name.first_name }
f.last_name { Faker::Name.last_name }
f.email { FactoryGirl.generate(:email) }
f.email { generate(:email) }
f.organization { Faker::Company.name }
f.created_at { 2.days.ago }
f.updated_at { 1.hour.ago }
end

factory :product, :class => Chargify::Product do |f|
f.name { FactoryGirl.generate(:product_name) }
f.name { generate(:product_name) }
end

factory :product_family, :class => Chargify::ProductFamily do |f|
Expand Down
8 changes: 4 additions & 4 deletions spec/resources/coupon_spec.rb
Expand Up @@ -2,7 +2,7 @@

describe Chargify::Coupon do
context '.find_by_product_family_id_and_code' do
let(:existing_coupon) { Factory.build(:coupon, :code => '20OFF') }
let(:existing_coupon) { build(:coupon, :code => '20OFF') }

before(:each) do
FakeWeb.register_uri(:get, "#{test_domain}/coupons/lookup.xml?code=#{existing_coupon.code}&product_family_id=10", :body => existing_coupon.attributes.to_xml)
Expand All @@ -24,8 +24,8 @@
end

context '.find_all_by_product_family_id' do
let(:coupon_1) { Factory.build(:coupon, :product_family_id => 5) }
let(:coupon_2) { Factory.build(:coupon, :product_family_id => 5) }
let(:coupon_1) { build(:coupon, :product_family_id => 5) }
let(:coupon_2) { build(:coupon, :product_family_id => 5) }

before do
FakeWeb.register_uri(:get, "#{test_domain}/coupons.xml?product_family_id=5", :body => [coupon_1.attributes, coupon_2.attributes].to_xml)
Expand All @@ -39,7 +39,7 @@
end

context '.validate' do
let(:coupon_1) { Factory.build(:coupon, :product_family_id => 6) }
let(:coupon_1) { build(:coupon, :product_family_id => 6) }

before do
FakeWeb.register_uri(:get, "#{test_domain}/coupons/validate.xml?product_family_id=6&coupon_code=foobar123", :body => coupon_1.attributes.to_xml)
Expand Down
18 changes: 9 additions & 9 deletions spec/resources/subscription_spec.rb
Expand Up @@ -4,7 +4,7 @@

context 'strips nested association attributes before saving' do
before do
@subscription = FactoryGirl.build(:subscription_with_extra_attrs)
@subscription = build(:subscription_with_extra_attrs)
end

it 'strips customer' do
Expand All @@ -26,15 +26,15 @@
end

it "doesn't strip other attrs" do
subscription = FactoryGirl.build(:subscription)
subscription = build(:subscription)

lambda { subscription.save! }.should_not change(subscription, :attributes)
end
end

it 'creates a one-time charge' do
id = FactoryGirl.generate(:subscription_id)
subscription = Factory(:subscription, :id => id)
id = generate(:subscription_id)
subscription = build(:subscription, :id => id)
subscription.stub!(:persisted?).and_return(true)
expected_response = {:charge => {:amount_in_cents => 1000, :memo => "one-time charge", :success => true}}.to_xml
FakeWeb.register_uri(:post, "#{test_domain}/subscriptions/#{id}/charges.xml", :status => 201, :body => expected_response)
Expand All @@ -46,8 +46,8 @@
end

it 'finds by customer reference' do
customer = Factory(:customer, :reference => 'roger', :id => 10)
subscription = Factory(:subscription, :id => 11, :customer_id => customer.id, :product => Factory(:product))
customer = build(:customer, :reference => 'roger', :id => 10)
subscription = build(:subscription, :id => 11, :customer_id => customer.id, :product => build(:product))

expected_response = [subscription.attributes].to_xml(:root => 'subscriptions')
FakeWeb.register_uri(:get, "#{test_domain}/subscriptions.xml?customer_id=#{customer.id}", :status => 200, :body => expected_response)
Expand All @@ -57,7 +57,7 @@
end

it 'cancels the subscription' do
@subscription = Factory(:subscription, :id => 1)
@subscription = build(:subscription, :id => 1)
find_subscription = lambda { Chargify::Subscription.find(1) }

FakeWeb.register_uri(:get, "#{test_domain}/subscriptions/1.xml", :body => @subscription.attributes.to_xml)
Expand All @@ -68,8 +68,8 @@
end

it 'migrates the subscription' do
id = FactoryGirl.generate(:subscription_id)
subscription = Factory(:subscription, :id => id)
id = generate(:subscription_id)
subscription = build(:subscription, :id => id)
subscription.stub!(:persisted?).and_return(true)
expected_response = [subscription.attributes].to_xml(:root => 'subscription')
FakeWeb.register_uri(:post, "#{test_domain}/subscriptions/#{id}/migrations.xml?migration%5Bproduct_handle%5D=upgraded-plan", :status => 201, :body => expected_response)
Expand Down
8 changes: 4 additions & 4 deletions spec/resources/usage_spec.rb
Expand Up @@ -3,8 +3,8 @@
describe Chargify::Usage do
context "create" do
before do
@subscription = Factory(:subscription)
@component = Factory(:component)
@subscription = build(:subscription)
@component = build(:component)
@now = DateTime.now.to_s
end

Expand All @@ -24,8 +24,8 @@

context "find" do
before do
@subscription = Factory(:subscription)
@component = Factory(:component)
@subscription = build(:subscription)
@component = build(:component)
@now = DateTime.now.to_s
end

Expand Down
14 changes: 7 additions & 7 deletions spec/spec_helper.rb
@@ -1,13 +1,11 @@
$:.unshift File.expand_path('../lib', File.dirname(__FILE__))

require 'chargify_api_ares'
require 'rspec'
require 'fakeweb'
require 'bundler'
Bundler.require(:default, :development)

require 'support/fake_resource'
require 'factory_girl'
require 'faker'
require 'factories'

FactoryGirl.find_definitions
ActiveResource::Base.send :include, ActiveResource::FakeResource
FakeWeb.allow_net_connect = false

Expand All @@ -21,7 +19,9 @@
config.run_all_when_everything_filtered = true
config.alias_example_to :fit, :focused => true
config.color_enabled = true


config.include FactoryGirl::Syntax::Methods

config.after(:each) do
ActiveResource::FakeResource.clean
end
Expand Down

0 comments on commit bf462ab

Please sign in to comment.