Skip to content

Instantly share code, notes, and snippets.

@tjtuom
Created November 15, 2010 05:45
Show Gist options
  • Save tjtuom/026a6c696e2199a46455 to your computer and use it in GitHub Desktop.
Save tjtuom/026a6c696e2199a46455 to your computer and use it in GitHub Desktop.
def create
p "in create"
@course = Course.find(params[:course_id])
@signup = @course.signups.build(params[:signup])
if @signup.save
session[:signup_id] = @signup.id
redirect_to new_payment_path
else
render :new
end
end
describe "POST create" do
let(:course) { Factory(:course) }
let(:signup) { mock_model(Signup) }
before do
Course.should_receive(:find).with(course.id).any_number_of_times.and_return { puts caller.join("\n"); course }
course.stub_chain(:signups, :build).and_return { signup }
end
context "with valid attributes" do
before do
signup.should_receive(:save).and_return(true)
post :create, :course_id => course.id, :signup => { :foo => 'bar' }
end
it "redirects to new payment path", :focus => true do
response.should redirect_to(new_payment_path)
end
it "sets the signup id in session" do
controller.session[:signup_id].should == signup.id
end
end
context "with invalid attributes" do
before do
signup.should_receive(:save).and_return(false)
end
it "renders new template" do
post :create, :course_id => course.id, :signup => { :foo => 'bar' }
response.should render_template(:new)
end
end
end
[edit_texts][~/Code/piranha-digital/paasykoevalmennus] rake
(in /Users/toni/Code/piranha-digital/paasykoevalmennus)
NOTICE: CREATE TABLE will create implicit sequence "courses_id_seq" for serial column "courses.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "courses_pkey" for table "courses"
NOTICE: CREATE TABLE will create implicit sequence "signups_id_seq" for serial column "signups.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "signups_pkey" for table "signups"
NOTICE: CREATE TABLE will create implicit sequence "texts_id_seq" for serial column "texts.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "texts_pkey" for table "texts"
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S bundle exec rspec "./spec/acceptance/admin/creates_new_course_spec.rb" "./spec/acceptance/admin/destroys_course_spec.rb" "./spec/acceptance/admin/edits_course_information_spec.rb" "./spec/acceptance/admin/edits_texts_spec.rb" "./spec/acceptance/user_signs_up_for_course_spec.rb" "./spec/controllers/courses_controller_spec.rb" "./spec/controllers/invoices_controller_spec.rb" "./spec/controllers/payments_controller_spec.rb" "./spec/controllers/signups_controller_spec.rb" "./spec/mailers/signup_mailer_spec.rb" "./spec/models/course_spec.rb" "./spec/models/signup_spec.rb" "./spec/models/text_spec.rb"
Run filtered using {:focus=>true}
"in create"
/Library/Ruby/Gems/1.8/gems/rspec-mocks-2.0.0/lib/rspec/mocks/message_expectation.rb:185:in `call'
/Library/Ruby/Gems/1.8/gems/rspec-mocks-2.0.0/lib/rspec/mocks/message_expectation.rb:185:in `invoke_return_block'
/Library/Ruby/Gems/1.8/gems/rspec-mocks-2.0.0/lib/rspec/mocks/message_expectation.rb:128:in `invoke'
/Library/Ruby/Gems/1.8/gems/rspec-mocks-2.0.0/lib/rspec/mocks/proxy.rb:104:in `message_received'
/Library/Ruby/Gems/1.8/gems/rspec-mocks-2.0.0/lib/rspec/mocks/method_double.rb:79:in `find'
/Users/toni/Code/piranha-digital/paasykoevalmennus/app/controllers/signups_controller.rb:23:in `create'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/abstract_controller/base.rb:150:in `process_action'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/action_controller/metal/rendering.rb:11:in `process_action'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/abstract_controller/callbacks.rb:18:in `process_action'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.1/lib/active_support/callbacks.rb:435:in `_run__6547157__process_action__1623385099__callbacks'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.1/lib/active_support/callbacks.rb:409:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.1/lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.1/lib/active_support/callbacks.rb:93:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.1/lib/active_support/callbacks.rb:93:in `run_callbacks'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/abstract_controller/callbacks.rb:17:in `process_action'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `instrument'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `instrument'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/action_controller/metal/rescue.rb:17:in `process_action'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/abstract_controller/base.rb:119:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:40:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/action_controller/test_case.rb:405:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.1/lib/action_controller/test_case.rb:348:in `post'
/Users/toni/Code/piranha-digital/paasykoevalmennus/spec/controllers/signups_controller_spec.rb:30
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/hooks.rb:29:in `instance_eval'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/hooks.rb:29:in `run_in'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/hooks.rb:60:in `run_all'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/hooks.rb:60:in `each'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/hooks.rb:60:in `run_all'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/hooks.rb:106:in `run_hook'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:190:in `eval_before_eachs'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:190:in `each'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:190:in `eval_before_eachs'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:121:in `run_before_each'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:46:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:86:in `call'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:86:in `with_around_hooks'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:44:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:80:in `call'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:80:in `with_pending_capture'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:79:in `catch'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:79:in `with_pending_capture'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example.rb:43:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:262:in `run_examples'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:258:in `map'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:258:in `run_examples'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:232:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:233:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:233:in `map'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:233:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:233:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:233:in `map'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:233:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in `map'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/reporter.rb:11:in `report'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:23:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:55:in `run_in_process'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:46:in `run'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:10:in `autorun'
/Library/Ruby/Gems/1.8/bin/rspec:19
.
Finished in 0.19317 seconds
1 example, 0 failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment