Permalink
Browse files

Merge branch 'develop' of github.com:HAW-AI/Zaphod into develop

  • Loading branch information...
2 parents bd0105d + 0388f4a commit 58782b72d8f4e2cc96e46a76fa43db327efb85fc @patrickdet patrickdet committed Apr 24, 2012
Showing with 19 additions and 25 deletions.
  1. +8 −24 spec/controllers/cards_controller_spec.rb
  2. +2 −1 spec/spec_helper.rb
  3. +9 −0 spec/support/helpers/request_helpers.rb
@@ -2,23 +2,18 @@
describe CardsController do
let(:deck) { FactoryGirl.create(:deck) }
+ let(:params) do
+ {
+ card: card.attributes.slice(Card.accessible_attributes),
+ auth_token: card.user.authentication_token
+ }
+ end
describe :create do
let(:card) { FactoryGirl.build(:card, deck: deck) }
- def do_create(data = {})
- post :create, data.merge(format: :json, deck_id: deck.id)
- end
-
context "with valid data" do
- let(:params) do
- {
- card: card.attributes.slice(Card.accessible_attributes),
- auth_token: card.user.authentication_token
- }
- end
-
- before { do_create params }
+ before { do_create params.merge(format: :json, deck_id: deck.id) }
specify { response.should be_success }
it { expect { do_create params }.to change(Card, :count).by(1) }
@@ -28,18 +23,7 @@ def do_create(data = {})
describe :update do
let(:card) { FactoryGirl.create(:card, deck: deck) }
- def do_update(data={})
- post :update, data.merge(format: :json, id: card.id, deck_id: card.deck.id)
- end
-
- let(:params) do
- {
- card: card.attributes.slice(Card.accessible_attributes),
- auth_token: card.user.authentication_token
- }
- end
-
- before { do_update params }
+ before { do_update params.merge(format: :json, id: card.id, deck_id: card.deck.id) }
specify { response.should be_success }
end
View
@@ -29,7 +29,8 @@
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
-
+
config.include Devise::TestHelpers, :type => :controller
+ config.include RequestHelpers, :type => :controller
config.extend LoginMacros, :type => :controller
end
@@ -0,0 +1,9 @@
+module RequestHelpers
+ def do_create(data = {})
+ post :create, data
+ end
+
+ def do_update(data={})
+ post :update, data
+ end
+end

0 comments on commit 58782b7

Please sign in to comment.