On Mon, May 17, 2010 at 9:32 PM, Kwang how Tan [email protected]
wrote:
Here are the failure messages, and the backtraces.
Thx
SessionsController #create authenticate fail flash.now[:error] should
be set to failure
Failure/Error: flash.now[:error].should == “Invalid username or
password!”
expected: “Invalid username or password!”,
got: nil (using ==)
I think the problem here is that the expectation is set on flash.now,
but that’s not how flash.now works - views still just access flash
(not flash.now). Try this:
it 'flash.now[:error] should be set to failure' do
post :create
flash[:error].should == "Invalid username or password!"
end
SessionsController #create authenticate successfully should redirect
Failure/Error:
expects(:redirect_to_target_or_default).with(twikets_path)
And in this case the expects message is being sent to the example
group, not the controller. Try:
SessionsController #create authenticate fail flash.now[:error] should
be set to failure
Failure/Error: flash[:error].should == “Invalid username or
password!”
expected: “Invalid username or password!”,
got: nil (using ==)
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/expectations/fail_with.rb:23:in fail_with' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:39:infail_with_message’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:61:in __delegate_operator' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:51:ineval_match’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:29:in block in use_custom_matcher_or_delegate' # ./spec/controllers/sessions_spec.rb:33:inblock (4 levels) in
<top (required)>’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in instance_eval' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:inblock in run’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in catch' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:inrun’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:181:in block in run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:inmap’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:171:inrun’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in block in run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:ineach’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in inject' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:inrun_all’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:27:in block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:34:inblock in report’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:140:in sync_output' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:29:inreport’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:26:in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:12:inblock in autorun’
SessionsController #create authenticate successfully should redirect
Failure/Error:
controller.expects(:redirect_to_target_or_default).with(twikets_path)
undefined local variable or method `controller’ for
#Rspec::Core::ExampleGroup::Nested_1::Nested_2::Nested_2:0xc256ef4
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/method_missing.rb:6:in method_missing' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/action_dispatch/testing/assertions/routing.rb:174:inmethod_missing’
# ./spec/controllers/sessions_spec.rb:44:in block (4 levels) in <top (required)>' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:ininstance_eval’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:incatch’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:181:inblock in run_examples’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in map' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:inrun_examples’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:171:in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:inblock in run_all’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in each' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:ininject’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:27:inblock in run’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:34:in block in report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:140:insync_output’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:29:in report' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:26:inrun’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:12:in
`block in autorun’
Finished in 0.40236 seconds
14 examples, 2 failures
Here are the failure messages, and the backtraces.
Thx
SessionsController #create authenticate fail flash.now[:error] should
be set to failure
Failure/Error: flash.now[:error].should == “Invalid username or
password!”
expected: “Invalid username or password!”,
got: nil (using ==)
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/expectations/fail_with.rb:23:in fail_with' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:39:infail_with_message’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:61:in __delegate_operator' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:51:ineval_match’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-expectations-2.0.0.beta.8/lib/rspec/matchers/operator_matcher.rb:29:in block in use_custom_matcher_or_delegate' # ./spec/controllers/sessions_spec.rb:33:inblock (4 levels) in
<top (required)>’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:in instance_eval' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:41:inblock in run’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:in catch' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example.rb:39:inrun’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:181:in block in run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:inmap’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:179:in run_examples' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/example_group.rb:171:inrun’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in block in run_all' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:ineach’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:in inject' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:51:inrun_all’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:27:in block in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:34:inblock in report’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:140:in sync_output' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/formatters/base_formatter.rb:29:inreport’
#
/home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:26:in run' # /home/tkhow/.rvm/gems/ruby-1.9.1-p378/gems/rspec-core-2.0.0.beta.8/lib/rspec/core/runner.rb:12:inblock in autorun’
SessionsController #create authenticate successfully should redirect
Failure/Error:
expects(:redirect_to_target_or_default).with(twikets_path)
not all expectations were satisfied
unsatisfied expectations: