How would you stub Devise in Rails 3 with rSpec. I have a UsersController and a User model. Both of which are associated with Devise at the moment, I'm writing controller specs and I really am having a hard time with my expectations as the Devise sign_in is really jamming up the works.
Any thing will help.
...
Hello,
I'm starting a new rails 3 application, and I want it to be tested the better I can.
This application is eavily based on plugins (wich will become gems later).
One of this gem will be a proxy which talk with an API and outputs formatted data.
Few plugins will process data sent by this proxy
My questions :
Should I use cucum...
I've followed all of the steps that I've been able to find online for configuring Rails 3 with Rspec 2 and Mocha. In my Gemfile:
group :development do
gem 'rails3-generators'
gem "rspec", '>= 2.0.0.beta.19'
gem "rspec-rails", '>= 2.0.0.beta.19'
end
group :test do
gem "faker"
gem "rspec", '>= 2.0.0.beta.19'
gem "rspec-rails"...
I am using delayed_job for background tasks such as system e-mails and different timed events. I use Delayed::Worker.new.work_off to work off the events in my RSpec tests, but then the test out put gets littered with sh*t like:
[Worker(host:ch.local pid:24307)] RPM Monitoring DJ worker host:ch.local pid:24307
[Worker(host:ch.local pid...
I can run a single rspec example with
spec -e 'should be awesome' spec/models/stuff_spec.rb
but how do I run an entire group ?
describe 'GoodStuff' do
it 'should be awesome' do
true.should be_true
end
it 'want to run this too' do
true.should be_true
end
end
I've heard there's a spec -g option, but a) its not docume...
I installed RSpec 2 along RSpec 1.3 and since then I think the spec command runs without executing the test file.
I removed RSpec 2 and am using RSpec 1.3 again.
I type for example "spec spec/views/messages/show.html.erb_spec.rb" on the commandline and the command returns after a few seconds without output. I added errors to the spec fi...
n the .net world, my specs would follow the Arrange, Act, Assert pattern. I'm having trouble replicating that in rspec, because there doesn't appear to be an ability to selectively verify your mocks after the SUT has taken it's action. That, coupled with the fact that EVERY expectation is evaluated at the end of each 'It' block, is cau...
I'm trying to follow this tutorial here: http://railstutorial.org/chapters/static-pages#top
When I run:
$ rails generate rspec:install
I get:
Could not find generator rspec:install.
What could be the problem? Provided that I'm using Rails 3.0.0.rc
Thanks.
...
Hi there,
I'm having a problem testing the following model:
class Bill < ActiveRecord::Base
belongs_to :consignee
before_save :calc_rate
def calc_rate
self.chargeableweight = self.consignee.destination.rate * self.weight
end
end
The consignee model:
class Consignee < ActiveRecord::Base
belongs_to :destination
has_ma...
I've tried to use the recommended way (from the Rails Guides) to test routes generated in plugins, but the test keeps failing.
What's odd is that if I reload the routes AFTER creating the route (or so I think), the test fails, but if I let the test go through once (e.g. using autotest), then the route gets recognized on subsequent attem...
Is there an API documentation for Rspec like the one for Rails?
...
If a spec file contains this before the it() example groups, what does it mean?
context "when almost full (with one element less than capacity)" do
before(:each) do
@stack = Stack.new
(1..9).each { |n| @stack.push n }
end
end
context "when full" do
before(:each) do
@stack = Stack.new
(1..10).each { |n| @stack.push...
From what I have understood, the equal method checks if the object is the same.
person = Person.create!(:name => "David")
Person.find_by_name("David").should equal(person)
This should be true.
But aren't there two different objects here?
How could two objects be the same? I don't understand that.
...
I'm using Rails 2.3.5, paperclip 2.3.3 with rspec and factory_girl.
Can't figure out why the attr_accessors are undefined when I try to test upload or simply calling. e.g.
account.profile_photo.file?
undefined method `profile_photo_file_name' for #Account:0x105970af8
Where I have it running properly in Development.
account.rb
h...
Hello everyone,
I am currently running ruby-1.9.1 installed via RVM. I have been looking at using Merb, but when I try and run it I get this error:
sam@shiny-dev:~/Projects/mojo$ rake db:migrate
(in /home/sam/Projects/mojo)
Merb root at: /home/sam/Projects/mojo
/home/sam/.rvm/gems/ruby-1.9.1-p378@merb/gems/dm-validations-...
I have a series of rspec tests which I use to make sure some web scraping services I wrote are still valid. I have all of these inside a GEM which my rails app requires and I'm not quite sure how to embed a rake task of spec for an external gem?
I'm not sure that is at all clear, I have a gem w/rspecs:
Gem w/rspecs
MyApp
I would lik...
I have this spec:
it 'can parse armies with only section headers' do
list = <<-LIST
:Core
:Special
:Omgg
:Moarheaders
LIST
expected_output = "## Core\n## Special\n## Omgg\n## Moarheaders\n"
parsed = @parser.parse(list)
parsed.should_not be_nil
parsed.transform.should be expected_output
end
Which produces this outpu...
To be specific, I'm trying to get ActionController::Routing::Routes.recognize_path to recognize a route that is not in routes.rb, for testing purposes.
Is it possible to somehow mock or dynamically add a route? I'm using Rspec with Mocha.
...
Hi,
I am new to ROR. I am working on Rspec..
I have been provided with a full package of an application.
I kept it in my rails dir.
The dir itself contains spec folder with some controllers/models and fixtures but without spec_helper file.
So when i run $spec spec/ i got an error
/usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/sp...
I am a complete Ruby newby and am playing around with rspec
I am testing a class (Account) that has this line:
attr_reader :balance
When I try to test it with this method:
it "should deposit twice" do
@acc.deposit(75)
expect {
@acc.deposit(50)
}.to change(Account.balance).to(125)
end
I get this error:
NoMethodError in...