0
私のスペック失敗してくれ__mock_proxyに関するエラーメッセージ()与えている多くの:私はRailsの3.1.4を実行している予期しない呼び出し:__mock_proxy()mock_model含まRSpecのスペックを実行しているときに
$ rspec spec/helpers/liaisons_helper_spec.rb
WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being defered until env.rb is called.
To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile
FF
Failures:
1) LiaisonsHelper hrefs_of_email_addresses_for_liaison to enumerate email_addresses as RESTful links
Failure/Error: email_address = mock_model(EmailAddress)
Mocha::ExpectationError:
unexpected invocation: #<Mock:EmailAddress_1001>.__mock_proxy()
unsatisfied expectations:
- expected exactly once, not yet invoked: #<Mock:EmailAddress_1001>.id(any_parameters)
- expected exactly once, not yet invoked: #<Mock:EmailAddress_1001>.blank?(any_parameters)
- expected exactly once, not yet invoked: #<Mock:EmailAddress_1001>.valid?(any_parameters)
- expected exactly once, not yet invoked: #<Mock:EmailAddress_1001>.marked_for_destruction?(any_parameters)
- expected exactly once, not yet invoked: #<Mock:EmailAddress_1001>.destroyed?(any_parameters)
- expected exactly once, not yet invoked: #<Mock:EmailAddress_1001>.persisted?(any_parameters)
# ./spec/helpers/liaisons_helper_spec.rb:6:in `block (3 levels) in <top (required)>'
2) LiaisonsHelper hrefs_of_phone_numbers_for_liaison to enumerate phone_numbers as RESTful links
Failure/Error: phone_number = mock_model(PhoneNumber)
Mocha::ExpectationError:
unexpected invocation: #<Mock:PhoneNumber_1002>.__mock_proxy()
unsatisfied expectations:
- expected exactly once, not yet invoked: #<Mock:PhoneNumber_1002>.id(any_parameters)
- expected exactly once, not yet invoked: #<Mock:PhoneNumber_1002>.blank?(any_parameters)
- expected exactly once, not yet invoked: #<Mock:PhoneNumber_1002>.valid?(any_parameters)
- expected exactly once, not yet invoked: #<Mock:PhoneNumber_1002>.marked_for_destruction?(any_parameters)
- expected exactly once, not yet invoked: #<Mock:PhoneNumber_1002>.destroyed?(any_parameters)
- expected exactly once, not yet invoked: #<Mock:PhoneNumber_1002>.persisted?(any_parameters)
# ./spec/helpers/liaisons_helper_spec.rb:19:in `block (3 levels) in <top (required)>'
をし、 Rubyの1.9.2、およびこれらの宝石を使用しています:
$ bundle list | grep mocha
* mocha (0.10.5)
* rspec-rails-mocha (0.3.1)
$ bundle list | grep rspec
* rspec (2.8.0)
* rspec-apotomo (0.9.6)
* rspec-cells (0.1.2)
* rspec-core (2.8.0)
* rspec-expectations (2.8.0)
* rspec-mocks (2.8.0)
* rspec-rails (2.8.1)
* rspec-rails-mocha (0.3.1)
を私はthis one on githubを含む同じエラーを取得して人々のいくつかの報告を見つけたが、彼らはすべてのいずれかの日の外にあるように見えるか含まれていません。溶液。
編集:これらの仕様は、私の同僚のコンピュータ上で動作しますが、私のものでは動作しません。それでは、違いが何であるかは、RSpec::Rails::Mocha
とRSpec::Rails::Mocks
が含まれています - RSpec::Rails::Mocha
が最後に含まれている必要があります。 (スペックは仕事)私の同僚のコンピュータで
describe 'test' do
it 'test' do
m = self.method(:mock_model)
p m
p m.source_location
p self.class.included_modules.map(&:to_s).grep(/Moc/)
end
end
、それはこの出力生成:
#<Method: RSpec::Core::ExampleGroup::Nested_1::Nested_1(RSpec::Rails::Mocha)#mock_model>
["/Users/username/.rvm/gems/[email protected]/gems/rspec-rails-mocha-0.3.1/lib/rspec/rails/mocha.rb", 59]
["RSpec::Rails::Mocha", "RSpec::Rails::Mocks", "RSpec::Core::MockFrameworkAdapter", "Mocha::API", "Mocha::ParameterMatchers", "Mocha::ObjectMethods"]
そして、私のコンピュータ上に(
は、私は、その出力を示し、これはテスト仕様を作りましたスペックは動作しません)、それはこの出力を生成:#<Method: RSpec::Core::ExampleGroup::Nested_1::Nested_1(RSpec::Rails::Mocks)#mock_model>
["/Users/username/.rvm/gems/[email protected]/gems/rspec-rails-2.9.0/lib/rspec/rails/mocks.rb", 67]
["RSpec::Rails::Mocks", "RSpec::Rails::Mocha", "RSpec::Core::MockFrameworkAdapter", "Mocha::API", "Mocha::ParameterMatchers", "Mocha::ObjectMethods"]