Troble running controller spec

View: New views
15 Messages — Rating Filter:   Alert me  

Troble running controller spec

by Amit Kulkarni-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

    I am trying to execute controller spec by referring to RSpec book
but it is diving me error.

Following are the details:
Ruby version : 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
rspec - 1.2.4
rails - 2.1.2
OS - Vista Home

My channels_controller_spec.rb(which is under
rootproject/spec/controller directory) file contains:

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ChannelsController do
  describe "Channel Creation" do
   before(:each) do
    @channel = mock_model(Channel, :save => nil)
    Channel.stub!(:new).and_return(@channel)
   end

   it "should create channel" do
    Channel.should_receive(:new).with(:brand_name => "test"
).and_return(@channel)
    post :create, :channel => { :brand_name => "test" }
  end

  it "should save channel" do
    @channel.should_receive(:save)
    post :create
  end
 end
end

Similarly my channels_controller.rb contains

def create
 @channel= Channel.new params[:channel]
 @channel.save
end

Now when i try to execute the spec it shows me error which i have
mentiond below along with its backtrace

FF.

1)
Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion
should cre
te chnnel'
<Chnnel(id: integer, brnd_nme: string, logo_file_nme: string,
logo_file_size: st
ring, logo_content_type: string, points: integer, rnk: integer,
overruled_rnk: b
oolen, title: string, description: text, tgs: string, url: string,
kit_file_nme:
 string, kit_file_size: string, kit_content_type: string, ctive: boolen,
bg_colo
r: string, font_color: string, title_color: string, title_style: string,
emotion
l_file_nme: string, emotionl_file_size: string, emotionl_content_type:
string, n
cestor_id: integer, chnnel_ctegory_id: integer, creted_t: dtetime,
updted_t: dte
time) (clss)> expected :new with ({:brnd_nme=>"mnger"}) once, but
received it 0
times
./spec/controllers/chnnels_controller_spec.rb:11:
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen
ertor.rb:53:in `__rise'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen
ertor.rb:26:in `rise_expecttion_error'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex
pecttion.rb:229:in `generte_error'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex
pecttion.rb:192:in `verify_messges_received'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
190:in `verify_expecttions'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
189:in `ech'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
189:in `verify_expecttions'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
66:in `verify'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/methods.r
b:34:in `rspec_verify'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:1
0:in `verify_ll'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9
:in `ech'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9
:in `verify_ll'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/dpters/mock_frm
eworks/rspec.rb:13:in `verify_mocks_for_rspec'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
ethods.rb:129:in `fter_ech_exmple'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
ethods.rb:45:in `execute'
C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
ethods.rb:37:in `execute'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
roup_methods.rb:207:in `run_exmples'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
roup_methods.rb:205:in `ech'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
roup_methods.rb:205:in `run_exmples'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
roup_methods.rb:103:in `run'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
roup_runner.rb:23:in `run'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
roup_runner.rb:22:in `ech'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
roup_runner.rb:22:in `run'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options.
rb:119:in `run_exmples'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/commnd_l
ine.rb:9:in `run'
script/spec:4:

2)
Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion
should sve
 chnnel'
Mock 'Chnnel_1002' expected :sve with (ny rgs) once, but received it 0
times
./spec/controllers/chnnels_controller_spec.rb:16:
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen
ertor.rb:53:in `__rise'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen
ertor.rb:26:in `rise_expecttion_error'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex
pecttion.rb:229:in `generte_error'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex
pecttion.rb:192:in `verify_messges_received'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
190:in `verify_expecttions'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
189:in `ech'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
189:in `verify_expecttions'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
66:in `verify'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/methods.r
b:34:in `rspec_verify'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:1
0:in `verify_ll'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9
:in `ech'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9
:in `verify_ll'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/dpters/mock_frm
eworks/rspec.rb:13:in `verify_mocks_for_rspec'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
ethods.rb:129:in `fter_ech_exmple'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
ethods.rb:45:in `execute'
C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
ethods.rb:37:in `execute'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
roup_methods.rb:207:in `run_exmples'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
roup_methods.rb:205:in `ech'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
roup_methods.rb:205:in `run_exmples'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
roup_methods.rb:103:in `run'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
roup_runner.rb:23:in `run'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
roup_runner.rb:22:in `ech'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
roup_runner.rb:22:in `run'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options.
rb:119:in `run_exmples'
C:/Progrm
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/commnd_l
ine.rb:9:in `run'

I had done same which is mentioned in the book still i dont know why i
am getting this error.
Please suggest :-)
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, May 22, 2009 at 1:41 AM, Amit Kulkarni <lists@...> wrote:

> Hi,
>
>    I am trying to execute controller spec by referring to RSpec book
> but it is diving me error.
>
> Following are the details:
> Ruby version : 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
> rspec - 1.2.4
> rails - 2.1.2
> OS - Vista Home
>
> My channels_controller_spec.rb(which is under
> rootproject/spec/controller directory) file contains:
>
> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
>
> describe ChannelsController do
>  describe "Channel Creation" do
>   before(:each) do
>    @channel = mock_model(Channel, :save => nil)
>    Channel.stub!(:new).and_return(@channel)
>   end
>
>   it "should create channel" do
>    Channel.should_receive(:new).with(:brand_name => "test"
> ).and_return(@channel)

I *think* Rails converts the keys in this hash to strings. Try:

Channel.should_receive(:new).with('brand_name' => 'test').
  and_return(@channel)

HTH,
David

>    post :create, :channel => { :brand_name => "test" }
>  end
>
>  it "should save channel" do
>    @channel.should_receive(:save)
>    post :create
>  end
>  end
> end
>
> Similarly my channels_controller.rb contains
>
> def create
>  @channel= Channel.new params[:channel]
>  @channel.save
> end
>
> Now when i try to execute the spec it shows me error which i have
> mentiond below along with its backtrace
>
> FF.
>
> 1)
> Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion
> should cre
> te chnnel'
> <Chnnel(id: integer, brnd_nme: string, logo_file_nme: string,
> logo_file_size: st
> ring, logo_content_type: string, points: integer, rnk: integer,
> overruled_rnk: b
> oolen, title: string, description: text, tgs: string, url: string,
> kit_file_nme:
>  string, kit_file_size: string, kit_content_type: string, ctive: boolen,
> bg_colo
> r: string, font_color: string, title_color: string, title_style: string,
> emotion
> l_file_nme: string, emotionl_file_size: string, emotionl_content_type:
> string, n
> cestor_id: integer, chnnel_ctegory_id: integer, creted_t: dtetime,
> updted_t: dte
> time) (clss)> expected :new with ({:brnd_nme=>"mnger"}) once, but
> received it 0
> times
> ./spec/controllers/chnnels_controller_spec.rb:11:
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen
> ertor.rb:53:in `__rise'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen
> ertor.rb:26:in `rise_expecttion_error'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex
> pecttion.rb:229:in `generte_error'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex
> pecttion.rb:192:in `verify_messges_received'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
> 190:in `verify_expecttions'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
> 189:in `ech'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
> 189:in `verify_expecttions'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
> 66:in `verify'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/methods.r
> b:34:in `rspec_verify'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:1
> 0:in `verify_ll'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9
> :in `ech'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9
> :in `verify_ll'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/dpters/mock_frm
> eworks/rspec.rb:13:in `verify_mocks_for_rspec'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
> ethods.rb:129:in `fter_ech_exmple'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
> ethods.rb:45:in `execute'
> C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
> ethods.rb:37:in `execute'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
> roup_methods.rb:207:in `run_exmples'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
> roup_methods.rb:205:in `ech'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
> roup_methods.rb:205:in `run_exmples'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
> roup_methods.rb:103:in `run'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
> roup_runner.rb:23:in `run'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
> roup_runner.rb:22:in `ech'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
> roup_runner.rb:22:in `run'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options.
> rb:119:in `run_exmples'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/commnd_l
> ine.rb:9:in `run'
> script/spec:4:
>
> 2)
> Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion
> should sve
>  chnnel'
> Mock 'Chnnel_1002' expected :sve with (ny rgs) once, but received it 0
> times
> ./spec/controllers/chnnels_controller_spec.rb:16:
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen
> ertor.rb:53:in `__rise'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/error_gen
> ertor.rb:26:in `rise_expecttion_error'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex
> pecttion.rb:229:in `generte_error'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/messge_ex
> pecttion.rb:192:in `verify_messges_received'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
> 190:in `verify_expecttions'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
> 189:in `ech'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
> 189:in `verify_expecttions'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/proxy.rb:
> 66:in `verify'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/methods.r
> b:34:in `rspec_verify'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:1
> 0:in `verify_ll'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9
> :in `ech'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/mocks/spce.rb:9
> :in `verify_ll'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/dpters/mock_frm
> eworks/rspec.rb:13:in `verify_mocks_for_rspec'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
> ethods.rb:129:in `fter_ech_exmple'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
> ethods.rb:45:in `execute'
> C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_m
> ethods.rb:37:in `execute'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
> roup_methods.rb:207:in `run_exmples'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
> roup_methods.rb:205:in `ech'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
> roup_methods.rb:205:in `run_exmples'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/exmple/exmple_g
> roup_methods.rb:103:in `run'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
> roup_runner.rb:23:in `run'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
> roup_runner.rb:22:in `ech'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/exmple_g
> roup_runner.rb:22:in `run'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/options.
> rb:119:in `run_exmples'
> C:/Progrm
> Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.6/lib/spec/runner/commnd_l
> ine.rb:9:in `run'
>
> I had done same which is mentioned in the book still i dont know why i
> am getting this error.
> Please suggest :-)
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users@...
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by Amit Kulkarni-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Chelimsky wrote:

> On Fri, May 22, 2009 at 1:41 AM, Amit Kulkarni <lists@...>
> wrote:
>>
>> � end
>>
>> � it "should create channel" do
>> � �Channel.should_receive(:new).with(:brand_name => "test"
>> ).and_return(@channel)
>
> I *think* Rails converts the keys in this hash to strings. Try:
>
> Channel.should_receive(:new).with('brand_name' => 'test').
>   and_return(@channel)
>

Hi,

I tried with the above command but it still gives the same error.Dont
know what is wrong.I am following the same which is given in the book
Details are as follows

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ChannelsController do
  describe "Channel Creation" do
    before(:each) do
      @channel = mock_model(Channel, :save => nil)
      Channel.stub!(:new).and_return(@channel)
    end

    it "should create channel" do
      Channel.should_receive(:new).with('brand_name' => 'manager'
).and_return(@channel)
      post :create, :channel => {'brand_name' => 'manager' }
    end

    it "should save channel" do
      @channel.should_receive(:save)
      post :create
    end
  end


Following are the errors
{Please ignore the missing a's :-)}

ChnnelsController
  Chnnel Cretion
    should crete chnnel (FILED - 1)
    should sve chnnel (FILED - 2)

1)
Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion
should cre
te chnnel'
<Chnnel(id: integer, brnd_nme: string, logo_file_nme: string,
logo_file_size: st
ring, logo_content_type: string, points: integer, rnk: integer,
overruled_rnk: b
oolen, title: string, description: text, tgs: string, url: string,
kit_file_nme:
 string, kit_file_size: string, kit_content_type: string, ctive: boolen,
bg_colo
r: string, font_color: string, title_color: string, title_style: string,
emotion
l_file_nme: string, emotionl_file_size: string, emotionl_content_type:
string, n
cestor_id: integer, chnnel_ctegory_id: integer, creted_t: dtetime,
updted_t: dte
time) (clss)> expected :new with ({"brnd_nme"=>"mnger"}) once, but
received it 0
 times
./spec/controllers/chnnels_controller_spec.rb:183:
script/spec:4:

2)
Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion
should sve
 chnnel'
Mock 'Chnnel_1002' expected :sve with (ny rgs) once, but received it 0
times
./spec/controllers/chnnels_controller_spec.rb:188:
script/spec:4:

Finished in 0.305 seconds

2 exmples, 2 filures


--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jun 8, 2009 at 8:31 AM, Amit Kulkarni<lists@...> wrote:

> David Chelimsky wrote:
>> On Fri, May 22, 2009 at 1:41 AM, Amit Kulkarni <lists@...>
>> wrote:
>>>
>>> � end
>>>
>>> � it "should create channel" do
>>> � �Channel.should_receive(:new).with(:brand_name => "test"
>>> ).and_return(@channel)
>>
>> I *think* Rails converts the keys in this hash to strings. Try:
>>
>> Channel.should_receive(:new).with('brand_name' => 'test').
>>   and_return(@channel)
>>
>
> Hi,
>
> I tried with the above command but it still gives the same error.Dont
> know what is wrong.I am following the same which is given in the book
> Details are as follows
>
> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
>
> describe ChannelsController do
>  describe "Channel Creation" do
>    before(:each) do
>      @channel = mock_model(Channel, :save => nil)
>      Channel.stub!(:new).and_return(@channel)
>    end
>
>    it "should create channel" do
>      Channel.should_receive(:new).with('brand_name' => 'manager'
> ).and_return(@channel)
>      post :create, :channel => {'brand_name' => 'manager' }
>    end
>
>    it "should save channel" do
>      @channel.should_receive(:save)
>      post :create
>    end
>  end

I went as far as to create a rails 2.1.2 project with rspec and
rspec-rails 1.2.4, copy your code into it and ran the specs. They both
pass. I don't have a Vista environment in which to test this, so
that's all I can do to help at the moment.

Anybody else running into similar problems on Vista?

>
>
> Following are the errors
> {Please ignore the missing a's :-)}
>
> ChnnelsController
>  Chnnel Cretion
>    should crete chnnel (FILED - 1)
>    should sve chnnel (FILED - 2)
>
> 1)
> Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion
> should cre
> te chnnel'
> <Chnnel(id: integer, brnd_nme: string, logo_file_nme: string,
> logo_file_size: st
> ring, logo_content_type: string, points: integer, rnk: integer,
> overruled_rnk: b
> oolen, title: string, description: text, tgs: string, url: string,
> kit_file_nme:
>  string, kit_file_size: string, kit_content_type: string, ctive: boolen,
> bg_colo
> r: string, font_color: string, title_color: string, title_style: string,
> emotion
> l_file_nme: string, emotionl_file_size: string, emotionl_content_type:
> string, n
> cestor_id: integer, chnnel_ctegory_id: integer, creted_t: dtetime,
> updted_t: dte
> time) (clss)> expected :new with ({"brnd_nme"=>"mnger"}) once, but
> received it 0
>  times
> ./spec/controllers/chnnels_controller_spec.rb:183:
> script/spec:4:
>
> 2)
> Spec::Mocks::MockExpecttionError in 'ChnnelsController Chnnel Cretion
> should sve
>  chnnel'
> Mock 'Chnnel_1002' expected :sve with (ny rgs) once, but received it 0
> times
> ./spec/controllers/chnnels_controller_spec.rb:188:
> script/spec:4:
>
> Finished in 0.305 seconds
>
> 2 exmples, 2 filures



>
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users@...
> http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by Amit Kulkarni-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Chelimsky wrote:

> On Mon, Jun 8, 2009 at 8:31 AM, Amit Kulkarni<lists@...>
> wrote:
>>> I *think* Rails converts the keys in this hash to strings. Try:
>>
>>      Channel.should_receive(:new).with('brand_name' => 'manager'
>> ).and_return(@channel)
>>      post :create, :channel => {'brand_name' => 'manager' }
>>    end
>>
>>    it "should save channel" do
>>      @channel.should_receive(:save)
>>      post :create
>>    end
>>  end
>
> I went as far as to create a rails 2.1.2 project with rspec and
> rspec-rails 1.2.4, copy your code into it and ran the specs. They both
> pass. I don't have a Vista environment in which to test this, so
> that's all I can do to help at the moment.
>
> Anybody else running into similar problems on Vista?
>

Thanks a lot for looking into the matter.I am not sure if i am getting
this problem due to vista environment.If it is then i dont know what to
do :-(

Also i didnt understand b the statement
"create a rails 2.1.2 project with rspec and rspec-rails 1.2.4, copy
your code into it and ran the specs."

Also i checked my spec version it is 1.2.6,so does this causing the
problem.
This version got updated from 1.2.4.
Please suggest.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jun 8, 2009 at 9:48 AM, Amit Kulkarni<lists@...> wrote:

> David Chelimsky wrote:
>> On Mon, Jun 8, 2009 at 8:31 AM, Amit Kulkarni<lists@...>
>> wrote:
>>>> I *think* Rails converts the keys in this hash to strings. Try:
>>>
>>>      Channel.should_receive(:new).with('brand_name' => 'manager'
>>> ).and_return(@channel)
>>>      post :create, :channel => {'brand_name' => 'manager' }
>>>    end
>>>
>>>    it "should save channel" do
>>>      @channel.should_receive(:save)
>>>      post :create
>>>    end
>>>  end
>>
>> I went as far as to create a rails 2.1.2 project with rspec and
>> rspec-rails 1.2.4, copy your code into it and ran the specs. They both
>> pass. I don't have a Vista environment in which to test this, so
>> that's all I can do to help at the moment.
>>
>> Anybody else running into similar problems on Vista?
>>
>
> Thanks a lot for looking into the matter.I am not sure if i am getting
> this problem due to vista environment.If it is then i dont know what to
> do :-(
>
> Also i didnt understand b the statement
> "create a rails 2.1.2 project with rspec and rspec-rails 1.2.4, copy
> your code into it and ran the specs."

The versions  you cited earlier were rails 2.1.2 and rspec 1.2.4, so I
did the following:

* created a rails 2.1.2 project
* configured it to use rspec 1.2.4
* created a ChannelsController and a spec for it
* created a Channel model with a migration and ran the migration
* copied the code you posted in this thread to
app/controllers/channels_controller.rb and
spec/controllers/channels_controller_spec.rb
* ran the specs
* watched them pass

>
> Also i checked my spec version it is 1.2.6,so does this causing the
> problem.
> This version got updated from 1.2.4.
> Please suggest.

You stated above that you were using 1.2.4, but now you are saying you
are using 1.2.6. Please be sure to provide accurate information.

Do you have both rspec and rspec-rails? And are they both 1.2.6 now?

FYI - I get the same result from 1.2.6. All specs pass.



> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users@...
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by Amit Kulkarni-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> You stated above that you were using 1.2.4, but now you are saying you
> are using 1.2.6. Please be sure to provide accurate information.

I am sorry for the above information.Yes earlier the version was 1.2.4
but i installed rspec again and it installed the latest version i.e
1.2.6

> Do you have both rspec and rspec-rails? And are they both 1.2.6 now?
> Yes i have both rspec and rspec-rails as 1.2.6 and 1.2.4 installed.

> FYI - I get the same result from 1.2.6. All specs pass.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by Amit Kulkarni-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Amit Kulkarni wrote:

>> You stated above that you were using 1.2.4, but now you are saying you
>> are using 1.2.6. Please be sure to provide accurate information.
>
> I am sorry for the above information.Yes earlier the version was 1.2.4
> but i installed rspec again and it installed the latest version i.e
> 1.2.6
>
>> Do you have both rspec and rspec-rails? And are they both 1.2.6 now?
>> Yes i have both rspec and rspec-rails as 1.2.6 and 1.2.4 installed.
>
>> FYI - I get the same result from 1.2.6. All specs pass.

Any Updates....
:-)
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jun 9, 2009 at 1:19 AM, Amit Kulkarni<lists@...> wrote:

> Amit Kulkarni wrote:
>>> You stated above that you were using 1.2.4, but now you are saying you
>>> are using 1.2.6. Please be sure to provide accurate information.
>>
>> I am sorry for the above information.Yes earlier the version was 1.2.4
>> but i installed rspec again and it installed the latest version i.e
>> 1.2.6
>>
>>> Do you have both rspec and rspec-rails? And are they both 1.2.6 now?
>>> Yes i have both rspec and rspec-rails as 1.2.6 and 1.2.4 installed.
>>
>>> FYI - I get the same result from 1.2.6. All specs pass.
>
> Any Updates....
> :-)

Any Vista users in earshot? I've done all I can do on this.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by Amit Kulkarni-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Chelimsky wrote:
> On Tue, Jun 9, 2009 at 1:19 AM, Amit Kulkarni<lists@...>
> wrote:
>>>
>>>> FYI - I get the same result from 1.2.6. All specs pass.
>>
>> Any Updates....
>> :-)
>
> Any Vista users in earshot? I've done all I can do on this.

Oh ok.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by Mohit Sindhwani-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Chelimsky wrote:

> On Tue, Jun 9, 2009 at 1:19 AM, Amit Kulkarni<lists@...> wrote:
>  
>> Amit Kulkarni wrote:
>>    
>>>> You stated above that you were using 1.2.4, but now you are saying you
>>>> are using 1.2.6. Please be sure to provide accurate information.
>>>>        
>>> I am sorry for the above information.Yes earlier the version was 1.2.4
>>> but i installed rspec again and it installed the latest version i.e
>>> 1.2.6
>>>
>>>      
>>>> Do you have both rspec and rspec-rails? And are they both 1.2.6 now?
>>>> Yes i have both rspec and rspec-rails as 1.2.6 and 1.2.4 installed.
>>>>        
>>>> FYI - I get the same result from 1.2.6. All specs pass.
>>>>        
>> Any Updates....
>> :-)
>>    
>
> Any Vista users in earshot? I've done all I can do on this.

Hi David

I'm on Vista, but I just joined the mailing list - could I have a bit of
a background to what we're trying to do?  I'll try to see what I can do.

Cheers,
Mohit.
6/9/2009 | 11:30 PM.

_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jun 9, 2009 at 10:30 AM, Mohit Sindhwani<tech@...> wrote:

> David Chelimsky wrote:
>>
>> On Tue, Jun 9, 2009 at 1:19 AM, Amit Kulkarni<lists@...> wrote:
>>
>>>
>>> Amit Kulkarni wrote:
>>>
>>>>>
>>>>> You stated above that you were using 1.2.4, but now you are saying you
>>>>> are using 1.2.6. Please be sure to provide accurate information.
>>>>>
>>>>
>>>> I am sorry for the above information.Yes earlier the version was 1.2.4
>>>> but i installed rspec again and it installed the latest version i.e
>>>> 1.2.6
>>>>
>>>>
>>>>>
>>>>> Do you have both rspec and rspec-rails? And are they both 1.2.6 now?
>>>>> Yes i have both rspec and rspec-rails as 1.2.6 and 1.2.4 installed.
>>>>>        FYI - I get the same result from 1.2.6. All specs pass.
>>>>>
>>>
>>> Any Updates....
>>> :-)
>>>
>>
>> Any Vista users in earshot? I've done all I can do on this.
>
> Hi David
>
> I'm on Vista, but I just joined the mailing list - could I have a bit of a
> background to what we're trying to do?  I'll try to see what I can do.

Thanks for volunteering to help Amit. You can see the full thread at
http://groups.google.com/group/rspec/browse_thread/thread/dc0f97750a92f7bd.

Cheers,
David

>
> Cheers,
> Mohit.
> 6/9/2009 | 11:30 PM.
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@...
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by Amit Kulkarni-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mohit Sindhwani wrote:

> David Chelimsky wrote:
>>>>
>> Any Vista users in earshot? I've done all I can do on this.
> Hi David
>
> I'm on Vista, but I just joined the mailing list - could I have a bit of
> a background to what we're trying to do?  I'll try to see what I can do.
>
> Cheers,
> Mohit.
> 6/9/2009 | 11:30 PM.

Thanks Mohit.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by Amit Kulkarni-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
Any updates on the above topic....

--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: Troble running controller spec

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 28, 2009 at 8:40 AM, Amit Kulkarni <lists@...> wrote:
Hello,
Any updates on the above topic....

Please be sure to quote enough of the previous topic so those of us reading on phones can respond to you.

There is a thread about this on the Cucumber list - please see if this information helps you:

http://wiki.github.com/aslakhellesoy/cucumber/troubleshooting (Console output isn’t right on Windows)

_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users