2012-01-05 5 views
1

私は、簡単なテストを書いた:RSpecの:#<RSpecの::コア:: ExampleGroup :: Nested_1:0x007fcc2f626d50>のための「未定義のメソッド `ダブル次のように

require 'spec_helper.rb' 

describe Channel do 
    before(:each) do 
    @channel = Channel.new 
    end 

    it "should get the true view count" do 
    upload_view_count = double('upload view count') 
    upload_view_count.should_receive(:upload_num).and_return(16000666) 
    @channel.upload_view_counts << upload_view_count 
    @channel.save() 
    @channel.true_all_time_views.should equal(16000666) 
    end 

    it "should get the true view count with multiple upload view counts" do 
    upload_vc1 = double('uplaod view count 1') 
    upload_vc1.should_receive(:created_at).and_return(Time.now()) 
    upload_vc1.should_receive(:upload_num).and_return(17666) 
    upload_vc1.should_receive(:updated_at).and_return(Time.now()) 

    upload_vc2 = double('upload view count 2') 
    upload_vc2.should_receive(:created_at).and_return(Time.now()) 
    upload_vc2.should_receive(:upload_num).and_return(17777) 
    upload_vc2.should_receive(:updated_at).and_return(Time.now()) 

    @channel.upload_view_counts << upload_vc1 
    @channel.upload_view_counts << upload_vc2 
    @channel.save() 
    @channel.true_all_time_views.should equal(17777) 
    end 




end 

私はこのテストを実行しようとすると、次のエラーが表示されます。

Failures:

1) Channel should get the true view count Failure/Error: upload_view_count = double('upload view count') NoMethodError: undefined method double' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fcc2f66a8c0> # ./spec/models/channel_spec.rb:9:in block (2 levels) in '

2) Channel should get the true view count with multiple upload view counts Failure/Error: upload_vc1 = double('uplaod view count 1') NoMethodError: undefined method double' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fcc2f626d50> # ./spec/models/channel_spec.rb:17:in block (2 levels) in '

Finished in 37.68 seconds 5 examples, 2 failures, 3 pending

Failed examples:

rspec ./spec/models/channel_spec.rb:8 # Channel should get the true view count rspec ./spec/models/channel_spec.rb:16 # Channel should get the true view count with multiple upload view counts

double()メソッドが機能しない理由はわかりません。私はこの特定のエラーのために高値と低値を検索しました。関連するものに見た最も近いものは 'spec_helper.rb'が不足していることが必要でしたが、その行があります。任意のアイデア、誰ですか?

答えて

8

私のspec_helper.rbファイルには、config.mock_with:mochaという行が誤って含まれていたことになりました。それを取り除くことはやりました。

関連する問題