similar to: rspec problems mocking classes based on mongoid

Displaying 20 results from an estimated 2000 matches similar to: "rspec problems mocking classes based on mongoid"

2011 Jul 04
2
when use mongoid , Model.count can't work.
Hi, when i use mongoid to get the count of model named "User", I met a error : irb(main):001:0> User.count ArgumentError: wrong number of arguments (1 for 0) from /var/lib/gems/1.8/gems/mongoid-2.0.2/lib/mongoid/ cursor.rb:37:in `count'' from /var/lib/gems/1.8/gems/mongoid-2.0.2/lib/mongoid/ cursor.rb:37:in `send'' from
2013 Oct 23
2
how is mongoid syntax implemented ?
In mongoid, a ORM mapped database object is like below. The part "type: String" seems to me to not fit into any standard ruby syntax and I was curious how does mongoid implement that ? class Step include Mongoid::Document field :Label, type: String field :Descript, type: String field :ErrorText, type: String embedded_in :step_data end -- You received this message
2012 Jan 22
3
Using Mongoid with ActiveRecord
I''m trying to use mongodb and postgresql simultaneously with Rails 3.1. I believe I have everything set up correctly. What I''m interested in knowing is how to get rails to flip-flop back- and-forth between mongoid and activerecord. For example, if I want to generate an ActiveRecord model after using mongoid, rails automatically defaults to the Mongoid gem. > rails g model
2011 May 14
1
RSpec stub question
Hi I am using Mongoid. In Mongoid while saving a record we typically give like in the controller @post.safely.save For a model class Post I am writing rspecs for my controller and want to mock the model. So what I am doing is let(:post) { mock_model(Post).as_null_object } before(:each) do Post.stub(:new).and_return(post) end it "creates new post"
2014 Mar 10
0
Mongoid : bson namespace error
Hello All, I had been trying to work on Rails 4 and Mongoid gem. The following are the versions I had installed: bson-2.2.1 mongoid-3.1.6 After installing and trying to run "rails generate" command. It is failing with NameSpace error for BSON::ByteBuffer. It is trying to connect to mongodb server initially and getting successful. Post that it is failing with the following
2011 May 08
0
Mongoid rails 3
Hi, I am using mongoid, rails, mongohq. I have to tables Category and SubCategory Category references_many :subcategories SubCategory referenced_in :category Now I have a form in view. In view, when user chooses a category, an ajax request is made to get dependent subcategories. But problem is, it is returning empty array in response(this is using mongohq). It is working normally as expected
2011 May 04
5
rails mongoid
I have a strange problem. Suppose I have a user model with only name field. I can add a field with value by creating an instance in mongodb rails environment. Example: class User include Mongoid::Document field :name end Now in rails console, If you do user = User.new user[:name] = "xxxx" user[:firstname] = "yyyy" user.save The record gets created with name and
2012 Jan 15
2
DEPRECATION WARNING: Passing a template handler in the template name is deprecated. (rspec + haml)
I upgraded a small project that I had created on 3.1.3 to 3.2.0.rc2. Running rspec on it brings about a large amount of these messages: DEPRECATION WARNING: Passing a template handler in the template name is deprecated. You can simply remove the handler name or pass render :handlers => [:haml] instead. (called from block (2 levels) in <top (required)> at
2011 Aug 09
0
Devise, RSpec and Webrat
My app is builded with rails 2.3.12, rspec-rails 1.3.2, webrat 0.7.3. My spec_helper.rb ENV["RAILS_ENV"] ||= ''test'' require File.expand_path(File.join(File.dirname(__FILE__),''..'',''config'',''environment'')) require ''spec/autorun'' require ''spec/rails'' require
2011 Jul 11
2
Can't get this Rspec test to pass
Hello, I''m completely new to Rspec testing and I''m finding it very difficult to mock specific objects. In this test, I have a before block setup as such: [code] before do setup_controller_for_warden controller.session[:operation_id] = 1 @operator = Factory :operator sign_in :operator, @operator @persist_herd = Herd.new
2013 Mar 28
0
Can not determine issue in my factories with factory girl in rspec
Hi Folks, I hope you''re doing good. Sorry for a long email. I am just trying my best to learn something new and, need your help to understand/ sort a small issue which I am not able to figure out. I have create couple of factories and created some examples for rspec for one of my projects. I have got everything working on my local. Even, my specs are green on local for both ruby
2007 Feb 16
6
some fun functionality for all your specs
I''ve found these two snippets of code useful and would love some feedback. first, .should_have_valid_associations usage: context "A new Product" do specify "should have valid associations" do @product.should_have_valid_associations end end code: (thanks to Wilson/Defiler for converting to rspec) module Spec module Expectations module Should
2011 Jun 09
2
nginx + passenger + mongoid
When I set the rails_env to production in nginx.conf I get: Error message: db_name must be a string or symbol -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to
2008 Jun 24
1
Suggestions on how to use stub_model with webrat?
Hi all, I am using story runner with webrat, but I am not sure how to incorporate stub_model into my tests. The webrat steps only care about the user interface and have nothing to say about interaction with the database. Following Ben Mabey, I have a line in my story like: "When clicks the Create button" And a step like: When "clicks the $button button" do |button|
2008 May 26
7
Mocking Models in Controller Specs...
I find myself doing this kind of thing a lot in Controller Specs: @vacancy = mock_model(Vacancy) @vacancy.stub!(:reference) @vacancy.stub!(:title) @vacancy.stub!(:created_at) @vacancy.stub!(:updated_at) @vacancy.stub!(:body) @vacancy.stub!(:contract) @vacancy.stub!(:location) @vacancy.stub!(:salary) @vacancy.stub!(:benefits)
2010 Jun 20
10
RSpec 2 view example: render_template
On http://github.com/rspec/rspec-rails under "View specs" there''s an example describe "events/index.html.erb" do it "renders _event partial for each event" do assign(:events, [stub_model(Event), stub_model(Event)]) render view.should render_template(:partial => "_event", :count => 2) end end Is this indeed correct? From the
2010 Feb 25
0
Bundle install error involving hash range errors
While running "bundle install" on a new Rails3.0.0.beta app on Ubuntu 9.10 / Ruby 1.8.7 with the following line in my Gemfile: gem "mongoid", :git => "git://github.com/durran/mongoid.git", :branch => "prerelease" I got the following error: Installing mongoid (2.0.0.pre) from git://github.com/durran/mongoid.git (at prerelease)
2011 Feb 03
0
Correct way to exclude attributes from json serialization
Hi I''m using Mongoid and Rails 3, and I want to serialize one of my mongoid documents to json for publishing via a controller, e.g. class ReportController < ApplicationController respond_to :json def show report = Report.where(:report_id => params[:id]).first respond_with report end end This works ok, but pushes out every attribute on the document
2010 Feb 12
1
Why does config.gem mess up migration?
I was working this morning, trying to clean up my project and I did something that sent migrations to hell-in-a-hand-basket. I tried to run rake db:migrate --trace I got the following error msg: (in /Users/richardmartin/NetBeansProjects/ReTrace) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! Mysql::Error: Table
2012 Jun 14
1
Cucumber/RSpec ::: Capybara? Webrat What am I using??
Hey everybody I''m currently reading through the Pragmatic Programmers RSpec book, and I really enjoy it. But I’m facing some problems because of the fact that the book is already some years old, I guess. I have installed rvm and use Ruby 1.9.3, and I didn’t really get some Rails code examples to work properly, so I tried it with a 1.8.7 installation, but there I had some other problems