Practicing BDD with python
Which are the most advanced frameworks and tools there are available for python for practicing Behavior Driven Development? Especially finding similar tools as rspec and mocha for ruby would be great. ...
Which are the most advanced frameworks and tools there are available for python for practicing Behavior Driven Development? Especially finding similar tools as rspec and mocha for ruby would be great. ...
I am using Mocha and Factory_girl in a JRuby rails application. When I call the factory I would like to return the objects with some mocking already done. Here is a code snippet of what I am trying to do. Factory.define :tweet_feed_with_tweets, :parent => :tweet_feed do |t| t.expects(:pull_tweets).returns([Factory.build(:status),Fac...
Assume this ruby code: class User def self.failed_login!(email) user = User.find_by_email(email) if user user.failed_login_count = user.failed_login_count + 1 user.save end end end I want to write a test that tests that user.save is never called when an invalid email is given. E.g.: it "should not incremen...
I've just downloaded MochaUI, and I'm playing around trying to build an interface. I've successfully created windows, but I'm having trouble when it comes to layouts with columns. I've included all of the libraries in the same order as the demo, and this is in my init code: window.addEvent('domready', function(){ new MochaUI.Colum...
I just started using mocha and I find it annoying that when creating a new mock object, mocha expects it to be called exactly once. I have helper methods to generate my mocks and I'm doing something like this my_mock = mock(HashOfParameters) All of the parameters might not get called for each test method so it will raise an error: ...
I installed the Mocha 0.9.7 Rails plug-in using: $ script/plugin install git://github.com/floehopper/mocha.git (Just followed instruction in http://mocha.rubyforge.org/) Then, I have the following set-up defined in my functional test def setup @controller.expects(:logged_in?).returns(true) @controller.expects(:admin_user?).retur...
Hi, I just started testing a new rails project, and I want a feature to webthumb the url into image. And now I want to test this feature. I'm trying to use the ThoughtBot family - shoulda factory-girl paperclip. For mocking, mocha. How can I test this feature? ...
I already removed all environment variables and ruby/ironruby directories and reinstalled it from scratch. And then I installed mocha through igem. Here are my outputs. $ ir IronRuby 0.9.1.0 on .NET 2.0.50727.3082 Copyright (c) Microsoft Corporation. All rights reserved. >>> require 'mocha' :0:in `require': no such file to load -- moch...
The following is the app/models/websites.rb class Masterpiece < ActiveRecord::Base validates_presence_of :title, :link validates_uri_existence_of :link, :allow_redirect => false end The second validation is from the plugin Validates Existence of URI plugin The following is the features/support/mocha.rb file require 'mocha' W...
I want to stub just a specific model, but not only a specific object and not every instance E.g. Given class 'Person' with attributes 'name' (string) and 'cool' (boolean). We have two models: person_bill: name: bill cool: false person_steve: name: steve cool: false Now I want to stub just steve, which works alright: p1...
I am doing some controller testing with RSpec and Mocha. Here is an example describe MenuItemsController, "creating a new menu item" do integrate_views fixtures :menu_items it "should redirect to index with a notice on successful save" do MenuItem.any_instance.stubs(:valid?).returns(true) post 'create' assigns[:menu_i...
I am currently struggling with stubbing out a helper method of my Sinatra app from within Cucumber. I have a Sinatra app with simple session authentication (by cookies) and I want to turn of authentication by stubbing out the logged_in? helper method for my Cucumber scenarios. There seems to be a problem with Sinatra and Cucumber conce...
Im new to tdd and stubbing. When I stub a method im assumng that any code within that method does not get executed? Im trying to fake the method raising an exception but the results of my test indicate that the code in that method is being executed rather than bypassed. can anyone help explain why? My stubbing is @logged_in_user.subs...
I have the following rspec code: require 'spec_helper' require 'mocha' require 'rr' describe ProjectsController, "creating a new project" do integrate_views it "should redirect to project with a notice on successful save" do Project.any_instance.stubs(:valid?).returns(true) #mock.instance_of(Project).valid? {true} Proj...
Hi I'm using Mocha for a Rails project. I'm new to TDD so please forgive me if this is a stupid question. If I have this @client.expects(:create_config).once.returns(true) then am I right in assuming that the code in create_config() won't be run and instead true will just be returned? ...
Excuse if this is a silly question, I am new to mocking. I am able to use mocha to do things like: person.expects(:first_name).returns('David') How can I mock a nested object? Say I have a Product that belongs to a Person and I want to get the first name of that person. In my app I might do it like this: product.person.first_name ...
How can I mock an array's sort expect a lambda expression? This is a trivial example of my problem: # initializing the data l = lambda { |a,b| a <=> b } array = [ 1, 2, 3, 4, 5 ] sorted_array = [ 2, 3, 8, 9, 1] # I expect that sort will be called using the lambda as a parameter array.expects(:sort).with( l ).returns( sorted_array ) #...
So I came about the strangest rails bug. I have been starting a new rails3 app, and just installed will_paginate 3.0pre. Unfortunately the rails 3.0.0.beta2 update made some of will_paginate 3.0pre code deprecated. I did a quick fix. In gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb: ... #railtie_name :will_paginate #Old co...
Within my controller specs I am stubbing out valid? for some routing tests, (based on Ryan Bates nifty_scaffold) as follows :- it "create action should render new template when model is invalid" do Company.any_instance.stubs(:valid?).returns(false) post :create response.should render_template(:new) end This is fine when I test t...
The gist of my problem is as follows:- I'm writing a Mocha mock in Ruby for the method represented as "post_to_embassy" below. It is not really our concern, for the purpose of describing the problem, what the actual method does. But I need the mock to return a dynamic value. The proc '&prc' below is executing rightly in place of the act...