rspec2 Questions
3
Solved
How do I reset a singleton object in Ruby? I know that one'd never want to do this in real code but what about unit tests?
Here's what I am trying to do in an RSpec test -
describe MySingleton, "...
3
Solved
I have a few slower specs that I would like to optimise.
The example of such spec looks like:
require 'rspec'
class HeavyComputation
def compute_result
sleep 1 # something compute heavy here
...
Hi asked 3/9, 2014 at 1:6
4
Solved
I am new to Cucumber testing and I am trying to understand when to use Cucumber and when to use RSpec. For my models, I know I should be testing them with RSpec, and I know that I don't need to wri...
Basham asked 3/4, 2011 at 21:31
4
Solved
This is a pure syntactical question. I'm very new to RSpec.
I basically want to write something on the lines of this erroring line :
controller.stub!(:current_user(:update_attributes => false)...
Snorter asked 9/9, 2010 at 23:31
3
Solved
Looking to get some opinions here.
What is the best way to check boolean values with RSPEC I have seen it done a few different ways:
myvar.should == true
myvar.should be true
myvar.should be
A...
Crest asked 16/8, 2011 at 18:53
4
Solved
Consider the following RSpec snippet:
it "should match" do
{:a => 1, :b => 2}.should =~ {"a" => 1, "b" => 2}
end
This test fails because one hash uses symbols for keys and the other...
Spiv asked 6/8, 2012 at 17:17
4
Solved
Given the following RSpec configuration (v2.12.0):
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_w...
3
Solved
Here is my test:
require "rspec"
describe HomeController do
render_views
it "should renders the home" do
get :home
response.should render_template("home")
response.should include_text("Simu...
Gelid asked 25/1, 2013 at 6:28
1
Solved
I have a RSpec test like this:
context 'test #EnvironmentFile= method' do
it 'compares the command generated with the expected command' do
knife = EnvironmentFromFile.new(@knife_cfg_file)
k...
2
In my Rails 3.2 app, I'm trying to use config.exceptions_app to route exceptions through the routing table to render error-specific pages (especially one for 401 Forbidden). Here's what I've got so...
Marcasite asked 27/8, 2013 at 4:48
1
Solved
So I have an rspec test that I am trying to get my program to validate against:
code snippet from rspec test:
context '#validate(test_tool)' do
it { expect(test_tool.validate).to raise_error Sta...
2
Solved
I'm trying to create a double but I keep getting this error:
undefined method `double' for #<Class:0x007fa48c234320> (NoMethodError)
I suspect the problem has got to do with my spec helpe...
5
Solved
I wrote a simple class method Buy.get_days(string), and is trying to test it with different text string inputs. However I feel it is very verbose.
Is there any more concise way to test the follow...
4
Solved
Environment is REE(2011.12) on rvm, rspec 2.8.0, rails 3.0.6, and pg 0.13.2. Using PostgreSQL 8.3.17 on CentOS 5.6. The db:migrate have work correctly. But rspec have got following error.
1) ApiC...
Parka asked 5/3, 2012 at 5:47
2
I have a function, which accepts a block, opens a file, yields and returns:
def start &block
.....do some stuff
File.open("filename", "w") do |f|
f.write("something")
....do some more stuf...
1
Solved
I am creating
bundler gem --test=rspec MyGem.
in which I'm getting the repository structure.
When I try to run the rspec code I get the following error:
`require': cannot load such file -- s...
Burschenschaft asked 27/1, 2015 at 4:56
2
I have tagged my specs that require selenium with :js => true in my spec files. What I want to achieve is that guard will always run the non :js specs first and only when these specs all pass ru...
Subphylum asked 12/1, 2014 at 11:8
1
Solved
I have gem 'rspec-rails', '~> 2.14.2' in my Gemfile.
After upgrading from Rails 4.1 to Rails 4.2 I've got the following error while running rspec:
Failure/Error: get 'api/...'
URI::InvalidURIEr...
Brainbrainard asked 29/11, 2014 at 10:38
5
Solved
Transactional fixtures in rspec prevent after_commit from being called, but even when I disable them with
RSpec.configure do |config|
config.use_transactional_fixtures = false
end
The after_com...
Cabbageworm asked 18/5, 2012 at 17:12
2
Solved
Im using Rspec for Testing, but CAN'T find how to change the grey color in to Red and Green.
Im testing so much that -especially when an error occurs- im having a hard time reading the passed and f...
3
I have the following in Rspec
response.should redirect_to %r{\A/my_settings/mysub_path/}
I get the following error
NoMethodError: undefined method `model_name' for Regexp:Class
I just need t...
Antenna asked 19/12, 2013 at 11:35
4
Solved
It is pretty easy with the added generator of rspec-rails to set up RSpec for testing a Rails application. But how about adding RSpec for testing a gem in development?
I am not using jeweler or suc...
3
Solved
I'm always writing render_views in all my controller specs:
require 'spec_helper'
describe AwesomeController do
render_views
end
Is there any way to always render views on all controller specs...
Dearth asked 9/12, 2010 at 18:4
1
Solved
I have an RSpec integration test that needs to execute some JavaScript. I've included Poltergeist and installed PhantomJS, but whenever I run the example, I get this error:
Failure/Error: page.exe...
Herbarium asked 25/6, 2014 at 18:19
2
Solved
When developing gems in Ruby, I almost always need a file in which I can configure RSpec to my needs and maybe before doing that, require some helper modules which should be available in all my spe...
© 2022 - 2024 — McMap. All rights reserved.