{"id":6461,"date":"2014-04-18T05:39:34","date_gmt":"2014-04-18T05:39:34","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/18\/ruby-on-railsrspecrspec2rspec-railsrelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-04-18T05:39:34","modified_gmt":"2014-04-18T05:39:34","slug":"ruby-on-railsrspecrspec2rspec-railsrelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/18\/ruby-on-railsrspecrspec2rspec-railsrelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"ruby-on-rails,rspec,rspec2,rspec-railsRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/18e42b0ddc143340cfb072987f45ca50?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeter Mortensen<br \/>\narchitecture ruby-on-rails node.js rewrite<br \/>\nPlease tell me if:Node.js will make our site faster! Node.js will consume fewer server resources, we can save money! Node.js will make us more productive! Node.js means we can share client and server side JavaScript code.To clarify, we&#8217;re rewriting a frontend server, which will talk to our existing Ruby on Rails application as an API. Meanwhile, we&#8217;ll refactor our Ruby on Rails application into services.More details on the existing architecture:Memcached for HTML partials caching Redis for sessi<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6022fa1cba81782d5bdb214d48a277aa?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nairlok<br \/>\nruby-on-rails ruby ubuntu rvm linkparser<br \/>\nI am using rvm, ruby 1.9.3, link-grammar (sudo apt-get install link-grammar), and pkg-config. I have the same setup on OSX, and it works great.Running &#8216;gem install linkparser&#8217; fails on this:\/usr\/local\/include\/link-grammar\/link-includes.h:16:36fatal error: link-grammar\/api-types.h: No such file or directoryI&#8217;ve tried installing link-grammer manually as well, then running:gem install linkparser &#8212; &#8211;with-link-grammar=\/usr\/local gem install linkparser &#8212; &#8211;with-link-grammar=\/usr\/share gem install l<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7dc9468b4611468761a93b49ee43be4e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njackerman09<br \/>\nruby-on-rails git heroku<br \/>\nI have been working on this rails project for weeks (it is deployed using Heroku), pushing to GitHub frequently without a problem. I am now getting this error:error: The requested URL returned error: 504 while accessing https:\/\/github.com\/my_git_name\/my_repository_name.git\/info\/refs?service=git-receive-pack fatal: HTTP request failedAny idea what might be causing this? Thanks!<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1c39f3643f2ad2ab87508a7a48060943?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbharath<br \/>\nruby-on-rails git rubygems bundler ruby-on-rails-3.2<br \/>\nI Have This in my GemFilesource &#8216;https:\/\/rubygems.org&#8217;gem &#8216;rails&#8217;, &#8216;3.2.3&#8217;# Bundle edge Rails instead: # gem &#8216;rails&#8217;, :git =&gt; &#8216;git:\/\/github.com\/rails\/rails.git&#8217;gem &#8216;sqlite3&#8217;gem &#8220;nested_form&#8221;, :git =&gt; &#8220;https:\/\/github.com\/ryanb\/nested_form.git&#8221; gem &#8216;lazy_high_charts&#8217;, :git =&gt; &#8220;https:\/\/github.com\/michelson\/lazy_high_charts.git&#8221;# Gems used only for assets and not required # in production environments by default. group :assets dogem &#8216;sass-rails&#8217;, &#8216;~&gt; 3.2.3&#8217;gem &#8216;coffee-rails&#8217;, &#8216;~&gt; 3.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fbbe2adedf4308c5978d92fa1a8dbbff?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ncjm2671<br \/>\nruby-on-rails ruby rescue<br \/>\nI&#8217;m trying to run a command that might fail sometimes. When it fails, it throws an exception.What I&#8217;d like it to do is just log the error quietly and continue executing the next line below it, rather than aborting and going into the &#8216;rescue&#8217; block. How should I approach this?My current code is as follows:rescue_from &#8216;Gibbon::MailChimpError&#8217; do |exception|logger.error(&#8220;MAILCHIMP: #{exception}&#8221;)endWhen I call the Mailchimp API, sometimes there is an error, and this disrupts the flow of my applicat<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/566e636647de5fa8ea092a23dd5c533d?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\ndachi<br \/>\nruby-on-rails git openshift<br \/>\nWhen trying to clone my Rails application via Git, I am geting:Cloning into ruby&#8230; ssh: Could not resolve hostnameruby-xxxxxxxxx.rhcloud.com: nodename nor servname provided, or notknown fatal: The remote end hung up unexpectedlyFor this, I am running the following command:$ git clone ssh:\/\/5311f57b5973ca7b7b00012b@ruby-xxxxxxxxx.rhcloud.com\/~\/git\/ruby.git\/I can access the app from the web console &amp; have installed the rhc gem &amp; the set up was successful.Anybody know what I can do to try<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bd1a5dc3e5f270014f2d1b61e9e136bf?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nstefkas<br \/>\nruby-on-rails git heroku push<br \/>\nWhen I git push on heroku, I receive this fatal: Not a git repository (or any of the parent directories): .git error many times. Everything works fine in my application and the push completes normally. I just wonder why this happens. I also see the same message 4-5 times in my logs in heroku, when a scheduler task runs. Any idea? Thanks!git push staging masterCounting objects: 41, done. Delta compression using up to 4 threads. Compressing objects: 100% (21\/21), done. Writing objects: 100% (21\/2<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dd7cc06b1b1c347e172c6ba532937173?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nZack<br \/>\nruby-on-rails ruby shell heroku<br \/>\nIm getting a fatal error in my Ruby and Rails Command Line when I try to bundle install &#8211;without productionfor Heroku.I&#8217;m following the instructions here: http:\/\/installfest.railsbridge.org\/installfest\/create_and_deploy_a_rails_appThis step is in 7.2. Everything was working fine until this. Can anyone point me in the right direction as to why this is failing?It says something along the lines of &#8216;group&#8217; no block given (yield) (LocalJumpError)ThanksEdit: Gemfilesource &#8216;https:\/\/rubygems.org&#8217;# Bun<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ca9ccb8fc9b8788e83bd57ac3ff9ded6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBram Jetten<br \/>\njavascript ruby-on-rails debian v8<br \/>\nI&#8217;m trying to deploy my Rails app to a new VPS which runs with Debian. I&#8217;m using Nginx and Phusion Passenger as my server.I&#8217;ve installed Node.js as a JavaScript runtime. Sadly I&#8217;m seeing the following error message:Fatal error in v8::V8::AddGCPrologueCallback() V8 is no longer usableEdit:It is fixed now. Apparently gr security was causing the error.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a2d818d801ce38a33807f68fdd92043a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBoltClock<br \/>\nruby-on-rails installation osx-lion<br \/>\nI&#8217;m a n00b eager to get my hands on Ruby on Rails (OSX 10.7). But first I need to install it. Now I&#8217;ve spend 9 hours trying to get it to work but it always fails when I try to create a new project:$ rails new \/Users\/tom\/Documents\/14-Utveckling\/WhichTerminal exist identical README.rdoc identical Rakefile identical config.ru identical .gitignoreconflict Gemfile Overwrite \/Users\/tom\/Documents\/14-Utveckling\/WhichTerminal\/Gemfile? (enter &#8220;h&#8221; for help) [Ynaqdh] Yforce Gemfileexist app identic<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8eaa128e738406b877ac89f6781148e2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMartin Carpenter<br \/>\nruby-on-rails rspec solaris<br \/>\nSetup:Host is laptop running windows 7, 64bitGuest is Solaris 11 running on VirtualBox 4.2 with packages:ruby(1.9.3p286) rails(3.2.8) gem(1.8.24) bundler(1.2.1) git(1.7.3.2) All seemed to run fine after a little tweeking. I am going through Ruby on Rails tutorial by Michael Hartl and I created a basic web page. I brought up rails server and could display web page. Basic git commands seemed to work fine.Went to run rspec to start the basic testing stage and got the following:\/usr\/lib\/ruby\/gems\/<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/aUpNv.jpg?s=32&amp;g=1\" \/><br \/>\nbackpackerhh<br \/>\nruby-on-rails json rspec<br \/>\nCreating a user through a json post with httparty creates the user (as seen by the server logs) but the test fails on both conditions. Either user count is not changed or the user is not found. Is this a problem with my understanding of testing, the spec or the way rspec handles creating db records?Results:1) User signup and signin with native request with valid information should save the userFailure\/Error: User.where(email: &#8220;bigbadwolf@example.com&#8221;).should existexpected #&lt;ActiveRecord::Rela<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/51ad7de6a7e94a27b6e7c0e2df390f77?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njyli7<br \/>\nruby-on-rails testing rspec cucumber<br \/>\nI&#8217;m trying to set up cucumber for rails. I included this in my Gemfile and ran bundle install. gem &#8216;cucumber-rails&#8217;gem &#8216;database_cleaner&#8217;I got this error. What should I do?ERROR: Error installing gherkin:ERROR: Failed to build gem native extension.\/Users\/[my_user_name]\/.rvm\/rubies\/ruby-1.9.2-p290\/bin\/ruby extconf.rb checking for main() in -lc&#8230; *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and\/or headers. Check the mkmf.log file f<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0606b479a1b760580f0e2309d128e545?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRajarshi Das<br \/>\nruby-on-rails ruby rspec bundler ruby-ffi<br \/>\nI have written a Ruby gem that makes use of the most recent version of FFI to access a (as well self written) shared object library. I am using ruby 2.0.0p247 in conjunction with rvm 1.21.12.My gem includes an &#8216;executable&#8217; in \/bin thats works as expected, reads in some data given by the user, and calls one function in my shared object library that in turn calls one function in an external API library. Everything works fine.If I execute the exact same code of my &#8216;executable&#8217; inside an RSpec test,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bc10c7edd7524e1a05de670a3f0399a4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nWill<br \/>\nruby-on-rails ruby rspec<br \/>\nIn Michael Hartl&#8217;s (wonderful) Rails Tutorial I&#8217;m getting an unexpected Rspec test failure of the form: &#8220;Expected response to be a redirect to&lt;http:\/\/test.host\/signin&gt; but was aredirect to&lt;http:\/\/test.host\/signin?notice=Please+sign+in+to+access+this+page.&gt;.&#8221;(Find this in Section 10.3.) So, from the very error, you can se that the server is redirecting to the appropriate page except that there is an additional notice to &#8220;Please sign in&#8221;. The code of the test looks like this:describe &#8220;GET<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e51c8fc2087c08ad566f2aac83bb76d0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1899140<br \/>\nruby rspec mocking<br \/>\nWhat would the pros and cons be of using an rspec double over a struct? For example before :each dolocation = double &#8220;locatoin&#8221;location.stub(:id =&gt; 1) endvsbefore :each dolocation = Struct.new(&#8220;locatoin&#8221;, :id)location.new.id = 1 end<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c032a0e8e40dd79b715420e4c5d03b00?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmeagar<br \/>\nruby-on-rails unit-testing rspec bdd nested-resources<br \/>\nI&#8217;ve got two models:class Solution &lt; ActiveRecord::Basebelongs_to :owner, :class_name =&gt; &#8220;User&#8221;, :foreign_key =&gt; :user_id endclass User &lt; ActiveRecord::Basehas_many :solutions endand I nest solutions within users like this:ActionController::Routing::Routes.draw do |map|map.resources :users, :has_many =&gt; :solutions endand finally here&#8217;s the action I&#8221;m trying to spec:class SolutionsController &lt; ApplicationControllerbefore_filter :load_userdef showif(@user)@solution = @user.soluti<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a0474e8305e39addf16ccf5e1f11ace6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nenricostn<br \/>\nruby-on-rails ruby testing rspec cancan<br \/>\nhere is the Controller I want to test:class UsersController &lt; ApplicationControllerload_and_authorize_resourcedef index@users = User.allrespond_to do |format|format.html # index.html.erbformat.json { render json: @users }endenddef show@user = User.find(params[:id])respond_to do |format|format.html # show.html.erbformat.json { render json: @user }endend#other actions hereendAs you can see I use CanCan method load_and_authorize_resource so I&#8217;ve written a ControllerHelper for RSpec:# spec\/suppor<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3a9ff49a9e689dcbfc8242f05180cc31?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nOrion Edwards<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5175951289cbb5d4cab7b5397634dd4a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJames Barona<br \/>\nruby-on-rails ruby rspec<br \/>\nThis simple controller exampledescribe &#8216;create&#8217; doit &#8216;creates a panel&#8217; dopanel = SimplePanel.make! TestingGroup.any_instance.should_receive(:add_panel!).with(panel, [SampleType::SERUM])post :create, {submission_id: submission.to_param,testing_group_id: testing_group.to_param,sample_type_ids: [SampleType::SERUM],panel_ids: [panel.id]}endendproduces the following resultFailure\/Error: post :create, {#&lt;TestingGroup:0x00000006685910&gt; received :add_panel! with unexpected argumentsexpected: (, [1<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2a7ee386e55303f049651d0318202f6f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDarmen<br \/>\nruby-on-rails ruby-on-rails-3 rspec rspec2 rspec-rails<br \/>\nI&#8217;m pretty new to Rspec so while I was writing some search results expectations I stumbled upon an unexpected behavior:describe &#8220;resultset&#8221; dosubject { search.products }describe &#8220;product name has a higher weight than product description&#8221; dolet(:product_first) { create(:product, name: &#8216;searched keywords&#8217;, description: &#8220;unmatching&#8221;) }let(:product_second) { create(:product, name: &#8216;unmatching&#8217;, description: &#8220;searched keywords&#8221;) } let(:product_third) { create(:product, name: &#8216;unmatching&#8217;, descri<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0140c747b563458f7baa2dfdcbb0a0e6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlulalala<br \/>\nruby-on-rails ruby rspec rspec2<br \/>\nI have a Currency class and want to update its rates. The following is the spec of an update class I plan to write:describe WebCrawlers::Currency::FeedParser dolet(:gbp){ double(&#8216;GBP&#8217;).as_null_object }let(:usd){ double(&#8216;USD&#8217;).as_null_object }describe &#8216;#perform&#8217; dobefore doCurrency.stub(:find_by_name).with(&#8216;GBP&#8217;).and_return( gbp )Currency.stub(:find_by_name).with(&#8216;USD&#8217;).and_return( usd )endit &#8216;should update GBP rate&#8217; dogbp.should_receive(:update_attributes).with(rate_to_usd:0.63114)subject.perfor<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/edf6bdf4153e3cb819ed126641249e49?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSherwin Yu<br \/>\nrspec rspec2 rspec-rails stub<br \/>\nI&#8217;m using rspec-spies and am wondering if there&#8217;s a way to inspect a spy after all the calls have been made. For example, If I do something like# setup Post.stub(:find).with(@post.id).and_return(@post)do_something_to_call_post_find()# verify find was called Post.should have_received(:find).with(@post.id)This works great, but if Post didn&#8217;t receive the expected argument, I get an unhelpful error message (basically &#8220;Post should have received find with 123&#8221;). Instead, I&#8217;d like to see what the actua<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/664efdf1bcd00b4087b638a81c502c17?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nserver info<br \/>\nruby-on-rails ruby-on-rails-3 rspec2 rspec-rails<br \/>\nI have a controller spec and I get following failed expectation:Failure\/Error: put :update, :id =&gt; login_user.id, :user =&gt; valid_attributes#&lt;User:0xbd030bc&gt; received :update_attributes with unexpected argumentsexpected: ({:name=&gt;&#8221;changed name&#8221;, :email=&gt;&#8221;changed@mail.com&#8221;, :password=&gt;&#8221;secret&#8221;, :password_confirmation=&gt;&#8221;secret&#8221;})got: ({&#8220;name&#8221;=&gt;&#8221;Test user&#8221;, &#8220;email&#8221;=&gt;&#8221;user@test.com&#8221;, &#8220;password&#8221;=&gt;&#8221;secret&#8221;, &#8220;password_confirmation&#8221;=&gt;&#8221;secret&#8221;})And for me it looks like<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e12dfefd0c6276a098857d95c024ad7f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nzkidd<br \/>\nruby-on-rails rspec2 autotest<br \/>\nI am going through Hartl&#8217;s RoR tutorial and am now in the section for integration testing. As instructed I modified .autotest with:require &#8216;autotest\/growl&#8217; require &#8216;autotest\/fsevent&#8217; require &#8220;autotest\/restart&#8221; Autotest.add_hook :initialize do |autotest|autotest.add_mapping(\/^spec\\\/requests\\\/.*_spec\\.rb$\/) doautotest.files_matching(\/^spec\\\/requests\\\/.*_spec\\.rb$\/)end endMy set-up:Z-Kidds-MacBook-Air:sample_app zkidd$ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0] Z-Ki<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/17977a15fb035d378d8a0a93b3401215?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrudolph9<br \/>\nruby-on-rails associations rspec2 rspec-rails<br \/>\nI recently upgraded a Ruby on Rails project from rspec-core \/ rspec-rails 2.10.1 to 2.14. Now (as I feared) a lot of tests are failing, but just because some methods have been changed. I have already fixed deprecations (stub! -&gt; stub, mock -&gt; double) but there are some more. One important method I use everywhere is something I picked up here: https:\/\/www.ruby-forum.com\/topic\/126993 to stub association methods:module RSpecmodule Mocksmodule Mockdef stub_association!(association_name, methods_to_b<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d56e8ad656ebfa19e9ef4c7daa9fd447?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLee<br \/>\nruby-on-rails mocking rspec2<br \/>\nSo new to testing and hope you can advise.I have a simple model:class Checkout &lt; ActiveRecord::Basevalidates&#8230;&#8230;&#8230; def number_of_days(checkout &#8211; checkin).to_iendendI would like to test that &#8216;number_of_days&#8217; method returns the correct value. I have tried mock_model and various other ways to stub the class but just cant get it working.Here is my lastest attempt which still does not work:require &#8216;spec_helper&#8217;describe Checkout doit &#8220;should calculate the number of days&#8221; docheckout = mock_model<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ba9cf679e6263efdd04fde56d4eafb72?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nawendt<br \/>\nruby rspec rspec2<br \/>\nI just spent ages trying to figure out why my specs were passing in isolation, but when running the controller and lib tests together, some specs were mysteriously failing. The culprit was this:In one spec:describe SomeThing doCONSTANT_VALUE = &#8220;a value&#8221;# &#8230; examples etc &#8230; endAnd in another:describe AnotherThing doCONSTANT_VALUE = &#8220;a different value&#8221;# &#8230; the rest is history endThe values I&#8217;d assigned to these constants was leaking between my specs and causing unexpected behaviour. Am I supp<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5bea293ccb8b5f613e57d64f69228e65?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrpearce<br \/>\nruby-on-rails ruby rspec rspec2 rspec-rails<br \/>\nI have a Rails 3.2 project I just started, and I&#8217;m trying to write some tests.When I try to utilize Ruby 1.9.3&#8217;s JSON-esque hash syntax and do this:let(:user) { User.new(first_name: &#8216;Joe&#8217;, last_name: &#8216;Blow&#8217;) }or this:let(:user) { User.new({first_name: &#8216;Joe&#8217;, last_name: &#8216;Blow&#8217;}) }I get this error:syntax error, unexpected &#8216;:&#8217;, expecting &#8216;)&#8217; (SyntaxError)let(:user) { User.new(first_name: &#8216;Joe&#8217;, last_name: &#8216;Blow&#8217;) }^When I revert to the :key =&gt; &#8216;value&#8217; syntax, rspec then looks at the user.rb file I&#8217;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e08c3b6b18e6760baaacab0dfe2ed14c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBhushan Lodha<br \/>\nruby ruby-on-rails-3 rspec rspec2 rspec-rails<br \/>\nmy model code is:class User &lt; ActiveRecord::Baseafter_create :create_node_for_userdef create_node_for_userUserGraph.create(user_id: self.id)end endand test for User model:it &#8220;create node in graph database on user creation&#8221; douserr = FactoryGirl.build(:user)UserGraph.should_receive(:create).with(user_id: userr.id)userr.save endbut my test is failing with messageFailure\/Error: userr.save&lt;UserGraph (class)&gt; received :create with unexpected argumentsexpected: ({:user_id=&gt;nil})got: ({:use<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a9e27b6a86cf2c5a869b19304f97bb73?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkyu1012<br \/>\nruby-on-rails-3 tdd rspec-rails nameerror<br \/>\nI am working through Hartl&#8217;s Ruby on Rails tutorial and am stuck on Section 3.2 where I am required to run a TDD using the command:$bundle exec rspec\/requests\/static_pages_spec.rband I get this in return:\/home\/Kelvin_Yu\/rails_projects\/sample_app\/spec\/requests\/static_pages_spec.rb:1:in `require&#8217;: \/home\/Kelvin_Yu\/rails_projects\/sample_app\/spec\/spec_helper.rb:2: syntax error, unexpected &#8216;.&#8217; (SyntaxError) \/home\/Kelvin_Yu\/rails_projects\/sample_app\/spec\/spec_helper.rb:6: syntax error, unexpected &#8216;.&#8217;fr<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2a7ee386e55303f049651d0318202f6f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDarmen<br \/>\nruby-on-rails ruby-on-rails-3 rspec rspec2 rspec-rails<br \/>\nI&#8217;m pretty new to Rspec so while I was writing some search results expectations I stumbled upon an unexpected behavior:describe &#8220;resultset&#8221; dosubject { search.products }describe &#8220;product name has a higher weight than product description&#8221; dolet(:product_first) { create(:product, name: &#8216;searched keywords&#8217;, description: &#8220;unmatching&#8221;) }let(:product_second) { create(:product, name: &#8216;unmatching&#8217;, description: &#8220;searched keywords&#8221;) } let(:product_third) { create(:product, name: &#8216;unmatching&#8217;, descri<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/edf6bdf4153e3cb819ed126641249e49?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSherwin Yu<br \/>\nrspec rspec2 rspec-rails stub<br \/>\nI&#8217;m using rspec-spies and am wondering if there&#8217;s a way to inspect a spy after all the calls have been made. For example, If I do something like# setup Post.stub(:find).with(@post.id).and_return(@post)do_something_to_call_post_find()# verify find was called Post.should have_received(:find).with(@post.id)This works great, but if Post didn&#8217;t receive the expected argument, I get an unhelpful error message (basically &#8220;Post should have received find with 123&#8221;). Instead, I&#8217;d like to see what the actua<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2553a4e57589e8d210aaf7c1e29906c9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nS\u00e9bastien Le Callonnec<br \/>\nruby-on-rails ruby-on-rails-3 rspec rspec-rails<br \/>\nMy trouble arose in Chapter 11 of the Ruby on Rails Tutorial here.I was seeing this rspec error:Failure\/Error: :user =&gt; Factory(:user, :email =&gt; Factory.next(:email)))ActiveRecord::RecordInvalid:Validation failed: Email has already been takenfirst in user_spec.rb then in micropost_spec.rb. It was pretty puzzling. I thought the factory statements were generating a user in a fresh testing db each time autotest ran rspec. I checked out source files from the master branch with git and tried<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/087fa8881a23bc50ff7a7f2bb8e8f05e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLille<br \/>\nruby-on-rails ruby-on-rails-3.1 mongoid rspec-rails<br \/>\nI&#8217;m using rspec-rails (2.8.1) to functional test a rails 3.1 app using mongoid (3.4.7) for persistence. I&#8217;m trying test rescue_from for Mongoid::Errors::DocumentNotFound errors in my ApplicationController in the same way that the rspec-rails documentation for anonymous controllers suggests it could be done. But when I run the following test&#8230;require &#8220;spec_helper&#8221;class ApplicationController &lt; ActionController::Baserescue_from Mongoid::Errors::DocumentNotFound, :with =&gt; :access_deniedprivat<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/664efdf1bcd00b4087b638a81c502c17?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nserver info<br \/>\nruby-on-rails ruby-on-rails-3 rspec2 rspec-rails<br \/>\nI have a controller spec and I get following failed expectation:Failure\/Error: put :update, :id =&gt; login_user.id, :user =&gt; valid_attributes#&lt;User:0xbd030bc&gt; received :update_attributes with unexpected argumentsexpected: ({:name=&gt;&#8221;changed name&#8221;, :email=&gt;&#8221;changed@mail.com&#8221;, :password=&gt;&#8221;secret&#8221;, :password_confirmation=&gt;&#8221;secret&#8221;})got: ({&#8220;name&#8221;=&gt;&#8221;Test user&#8221;, &#8220;email&#8221;=&gt;&#8221;user@test.com&#8221;, &#8220;password&#8221;=&gt;&#8221;secret&#8221;, &#8220;password_confirmation&#8221;=&gt;&#8221;secret&#8221;})And for me it looks like<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/17977a15fb035d378d8a0a93b3401215?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrudolph9<br \/>\nruby-on-rails associations rspec2 rspec-rails<br \/>\nI recently upgraded a Ruby on Rails project from rspec-core \/ rspec-rails 2.10.1 to 2.14. Now (as I feared) a lot of tests are failing, but just because some methods have been changed. I have already fixed deprecations (stub! -&gt; stub, mock -&gt; double) but there are some more. One important method I use everywhere is something I picked up here: https:\/\/www.ruby-forum.com\/topic\/126993 to stub association methods:module RSpecmodule Mocksmodule Mockdef stub_association!(association_name, methods_to_b<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/abda861707b1e78e0fce47ced55f84ee?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPaul Fioravanti<br \/>\nruby-on-rails-3 rspec-rails railstutorial.org<br \/>\nI am in section 5.3 in Michael Hartl&#8217;s RoR tutorial, where I am adding a Contact Page. I ran $ bundle exec rspec spec\/requests\/static_pages_spec.rb. I cannot figure out the error. I made changes in spec\/requests\/static_pages_spec.rb, as well as added the appropriate route, action for the contact page and edited the view for the contact page. This is the output:Failures:1) Static Pages Contact page should have the h1 &#8216;Contact&#8217;Failure\/Error: visit &#8216;\/static_pages\/contact&#8217;ActionView::Template::E<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5bea293ccb8b5f613e57d64f69228e65?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrpearce<br \/>\nruby-on-rails ruby rspec rspec2 rspec-rails<br \/>\nI have a Rails 3.2 project I just started, and I&#8217;m trying to write some tests.When I try to utilize Ruby 1.9.3&#8217;s JSON-esque hash syntax and do this:let(:user) { User.new(first_name: &#8216;Joe&#8217;, last_name: &#8216;Blow&#8217;) }or this:let(:user) { User.new({first_name: &#8216;Joe&#8217;, last_name: &#8216;Blow&#8217;}) }I get this error:syntax error, unexpected &#8216;:&#8217;, expecting &#8216;)&#8217; (SyntaxError)let(:user) { User.new(first_name: &#8216;Joe&#8217;, last_name: &#8216;Blow&#8217;) }^When I revert to the :key =&gt; &#8216;value&#8217; syntax, rspec then looks at the user.rb file I&#8217;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e08c3b6b18e6760baaacab0dfe2ed14c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBhushan Lodha<br \/>\nruby ruby-on-rails-3 rspec rspec2 rspec-rails<br \/>\nmy model code is:class User &lt; ActiveRecord::Baseafter_create :create_node_for_userdef create_node_for_userUserGraph.create(user_id: self.id)end endand test for User model:it &#8220;create node in graph database on user creation&#8221; douserr = FactoryGirl.build(:user)UserGraph.should_receive(:create).with(user_id: userr.id)userr.save endbut my test is failing with messageFailure\/Error: userr.save&lt;UserGraph (class)&gt; received :create with unexpected argumentsexpected: ({:user_id=&gt;nil})got: ({:use<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Peter Mortensen architecture ruby-on-rails node.js rewrite Please tell me if:Node.js will make our site faster! Node.js will consume fewer server resources, we can save money! Node.js will make us more productive! Node.js means we can share client and server side JavaScript code.To clarify, we&#8217;re rewriting a frontend server, which will talk to our existing Ruby [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6461","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6461"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6461\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}