rspec3 Questions

2

Solved

I'm stuck on a test scenario. I have a controller method: def update @object = Object.find params[:id] # some other stuff @object.save rescue ActiveRecord::StaleObjectError # woo other stuff...
Lian asked 2/9, 2015 at 13:20

1

Environment Ruby 2.2.1, Rails 4.2.0, rspec-core 3.2.2, rspec-expectations 3.2.0, rspec-mocks 3.2.1, rspec-rails 3.2.1, rspec-support 3.2.2 I have the following method def send_event_alert_email(...
Bibbye asked 1/5, 2015 at 11:42

1

The Advanced Tips section of the Serverspec site shows an example of testing multiple hosts with the same test set. I've built an example of my own (https://gist.github.com/neilhwatson/81249ad39380...
Recension asked 21/5, 2015 at 12:50

2

Solved

I would like to test whether a particular method does NOT raise an error of class AError. It can raise BError, ArgumentError, almost any other kind of error, or no error, just not AError. Is there ...
Bakemeier asked 29/4, 2015 at 19:10

2

I have the following model that I want to test with RSpec: class Language < ActiveRecord::Base has_and_belongs_to_many :dvds validates :title, presence: true, uniqueness: { case_sensitive: fa...
Friedrich asked 16/6, 2014 at 12:38

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

1

Solved

In RSpec, specifically version >= 3, is there any difference between: Using allow to set up message expectations with parameters that return test doubles, and then using expect to make an asser...
Catholic asked 18/1, 2015 at 3:41

2

Solved

I upgraded my rspec-rails to 3.0.1 and now I'm seeing this error on all of my tests Failure/Error: Sidekiq::Status::complete?(json.jid).should be_true expected true to respond to `true?` I can...
Purgation asked 6/6, 2014 at 12:27

1

Solved

I have an organization object that has attributes name, doing_business_as. I need to validate that the name is not the same as doing_business_as. # app/models/organization.rb class Organization &l...
Spent asked 1/12, 2014 at 16:6

1

Solved

Can any one please explain me about the difference between be_true and be true in Ruby with simple example. I have also seen be_true and be_false are changed to be_truthy and be_falsey I have an e...
Historic asked 6/11, 2014 at 12:51

1

Solved

Learning how to Rspec 3. I have a question on the matchers. The tutorial i am following is based on Rspec 2. describe Team do it "has a name" do #Team.new("Random name").should respond_to :name...
Portiaportico asked 30/9, 2014 at 10:3

1

Solved

In Rails 4 feature spec, using RSpec 3 and Capybara, how do I assert if a certain number of specific tags are present in a page? I tried: expect(find('section.documents .document').count).to eq(2...
Recept asked 27/8, 2014 at 13:0

2

Solved

I upgraded rspec from version 2 to 3. After that I faced that problem: Failures: 1) AlbumsController GET #edit Failure/Error: sign_in_and_switch_schema @user NoMethodError: undefined method ...
Allina asked 12/8, 2014 at 17:10

1

Solved

I upgraded rspec version from 2 to 3. This is one of the issues I faced: Failures: 1) Slide after .destroy(force: false) visible if .with_deleted Failure/Error: expect{@slide.destroy(force: fal...
Mercurochrome asked 12/8, 2014 at 15:8

1

Solved

I am trying to stub out the method that makes an external request for some JSON using RSpec 3. I had it working before by placing this into the spec_helper.rb file, but now that I refactored and mo...
Griseldagriseldis asked 10/8, 2014 at 3:26

1

Solved

I am upgrading from rspec 2.99 to rspec 3.0.3 and have converted instance methods to use allow_any_instance_of, but haven't figured out how to stub a class method. I have code like this: module My...
Draggle asked 31/7, 2014 at 18:48

2

Solved

it 'should be an array and not be empty' do pending expect(a.class).to be(Array) expect(a.empty?).to be(false) expect(a.first.class).to be(ExampleClass) end When I run rspec: Failures: 1) ...
Septimal asked 30/7, 2014 at 16:21

3

Solved

Here is my code: #app/models/user.rb class User < ActiveRecord::Base def display_name name.split(' ').try(:first) end end #spec/models/user_spec.rb require 'rails_helper' RSpec.describe U...
Hanuman asked 28/7, 2014 at 1:0

1

Solved

I am upgrading from rspec 2 to rspec 3 and would like to use the new syntax and not enable the old syntax. But I have a few stubs that I set up in my top-level before(:each) block that I selectivel...
Michaelmas asked 23/6, 2014 at 18:31

0

I am expecting a pry session to be opened in my console during execution of rspec. Am I doing something incorrect? Or expecting the wrong behavior? Gemfile: group :development, :test do gem 'rsp...
Fanya asked 19/6, 2014 at 16:38

1

Solved

I'm trying to follow a guide on code.tuts and I keep getting an error. Here is my Library spec: require 'spec_helper' describe Library do before :all do lib_arr = [ Book.new("JavaScript: The ...
Tawnatawney asked 8/6, 2014 at 21:49

1

Solved

I'm trying to run the $ rspec command but all my controller tests are failing unless I explictly add :type => :controller to each of the specs. Here's the error I'm getting: 1) AccountsControl...

1

Solved

I am running this portion of a test: describe Dictionary do before do @d = Dictionary.new end it 'can check whether a given keyword exists' do @d.include?('fish').should be_false end Wit...
Merbromin asked 29/5, 2014 at 16:5

3

Solved

I have the following code inside most of my tests: describe 'index' let(:company) { FactoryGirl.create(:company) } let(:user) { FactoryGirl.create(:user, company: company) } before do sign_in...
Stoat asked 29/10, 2013 at 22:28

1

Solved

If I have a spec that needs to be run with different values to have it drive a real implementation and not a naive one. An example: it "should return 'fizz' for multiples of three" do @...
Bord asked 23/1, 2011 at 18:53

© 2022 - 2024 — McMap. All rights reserved.