I have problems to get rspec running properly to test validates_inclusion_of my migration looks like this:
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.string :name
t.integer :parent_id
t.timestamps
end
end
def self.down
drop_table :categories
end
e...
Hi All,
I have sinatra appliction using session, how do I test a page that uses session?
I using Rspec + sinatra
Tks
...
Hi,
I have put some tasks in my rails app over to a Workling worker - my question is, what is best practice to test the Workling class with rspec?
I have set up rspec to be able to call the Workling class, (I use Sterling too), but since it is asyncron I dont know how to test for the result of the work done by workling.
Thanks
...
Say I have a Metal class named Preview. How do I test it with RSpec?
When I try:
require 'spec_helper'
describe Preview do
it "should return the posted content" do
post "/preview", :content => "*title*"
response.body.should == "*title*"
end
end
I get:
undefined method `post' for #<ActiveSupport::TestCase::Subclass_1:0...
I have two factories (post_factory.rb, comment_factory.rb) in separate files. I'd like to create a bit complex factory, which will create a post with associated comments for me. I created a third file, called complex_factory.rb, and wrote the following code:
Factory.define :post_with_comments, :parent => :post do |post|
post.after_cre...
Hi,
I'm trying to stub a third party service that my metal talks to. It seems rspec mocks/stubs don't extend all the way to the Metal.
When I call stubbed methods on objects, it calls the original one and not the stubbed one.
Any idea of how I can have rSpec doubles extend all the way to the metal?
Thanks.
-Nash
...
I'm having a lot of trouble trying to define a mock for a rails models on cucumber. It seems like the method is creating a bunch of message expectations and i keep getting errors like these:
Given I have only a product named "Sushi de Pato" # features/step_definitions/product_
steps.rb:19
unexpected invocation: #<Mock:ProductCate...
Hey,
I'm writing my func spec, and I was wondering if there are any good samples of a complete and well-written func spec? Like "This is a standard You're supposed to aspire to" type of spec. I know that Joel has a skeleteon of a func spec on his website, but I am looking for something more complete because I'm not of the appropriate am...
At the beginning this worked fine: $ rake cucumber:all
But then $ script/plugin install git://github.com/bmabey/email-spec.git
remote: Counting objects: 162, done.
remote: Compressing objects: 100% (130/130), done.
remote: Total 162 (delta 18), reused 79 (delta 13)
Receiving objects: 100% (162/162), 127.65 KiB | 15 KiB/s, done.
Resolvi...
screen:
E:\ir\InstantRails\rails_apps>gem install rspec
Attempting local installation of 'rspec'
Local gem file not found: rspec*.gem
Attempting remote installation of 'rspec'
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find rspec (> 0) in the repository
my env: InstantRails 1.3a on windows
thanks for he...
context "answer is correct" do
before(:each) do
@answer = stub_model(Answer, :correct => true).as_new_record
assigns[:answer] = @answer
render "answers/summarize"
end
it "should display flashcard context properly" do
response.should contain("Quiz")
end
it "should summarize results" do
response.should contain("is correct")
e...
I would like to create a set of remote specs "specs/remote" that run with the RAILS_ENV = 'remote'. These specs need to use a different database than the model specs. I would make them integration specs if that was easiest.
Ultimately, what is the easiest way change the RAILS_ENV from test and run a group of specs?
...
Hello,
I am trying to generate a controller with all the RESTful actions stubbed. I had read at link text that all I needed to do was to use call the generator with just a controller name I would get just that. So, I ran "script/generate rspec_controller Properties" and I got an empty controller.
Any other suggestions would be great...
I have a Rails model named Xpmodule with a corresponding controller XpmoduleController.
class XpmoduleController < ApplicationController
def index
@xpmodule = Xpmodule.find(params[:module_id])
end
def subscribe
flash[:notice] = "You are now subscribed to #{params[:subscription][:title]}"
redirect_to :action => :index...
I've been searching around for ways to create a gem with RSpec, but haven't found descriptive tutorials.
I started out with Ryan Bates' Making a gem, but I'm looking for a tutorial that discusses creating an acts_as style gem with RSpec.
By acts_as, I mean to say that the gem adds certain methods to an existing class in Rails. Why is t...
I have two models:
class Solution < ActiveRecord::Base
belongs_to :owner, :class_name => "User", :foreign_key => :user_id
end
class User < ActiveRecord::Base
has_many :solutions
end
with the following routing:
map.resources :users, :has_many => :solutions
and here is the SolutionsController:
class SolutionsC...
Hello there.
I'm trying to make this test fail :)
it "should display the question" do
@ui.should_receive(:puts).with("What's your name?").once
@ui.ask_question("What's your name?")
end
At the moment it passes even if I don't call puts in my function.
...
Is there a way to test the declarative_authorization permissions with respect?
In the documentation it has some instructions to use test unit, but I can't seem to find a way to use rspec.
...
I've been trying to solve a problem for a few weeks now. I am running rspec tests for my Rails app, and they are working fine except for one error that I can't seem get my head around.
I am using MySQL with the InnoDB engine.
I have set config.use_transactional_fixtures = true in spec_helper.rb
I load my test fixtures manually with th...
I'm not new to Rails or Rspec, but I'm new to making gems. When I test my controllers, the REST methods "get", "post", "put", "delete" give me an undefined method error.
Below you'll find code, but if you prefer to see it in a pastie, click here.
Thanks!
Here's my spec_helper:
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.un...