I am attempting to set up rspec to run only failures with rspec --only-failures. When I do this I get this error
block in fully_formatted_failed_examples': undefined method 'fully_formatted'
for #
<RSpec::Core::Notifications::ExampleNotification:0x00007fce3766b108> (NoMethodError)
When I run be rspec --only-failures I get this error:
bundler: failed to load command: rspec (/Users/mikeheft/.rbenv/versions/2.5.0/bin/rspec)
I have config.example_status_persistence_file_path = './spec/examples.txt' set up in spec_helper.rb
When I check out the source code on GitHub, I can see the line it's erroring out on, but I don't see a way on my end to fix this as it's in the gem it looks like. I have also opened an issue on Github.
Related
I've recently been trying to run RSpec in a Rails application and I can't seem to get it to work. I've followed all the instructions and I still can't even get a simple test to run.
RSpec is in my Gemfile, and I've run rails generate rspec:install.
I have the spec folder set up with a simple model test. However, every time I try to run RSpec, I get the following error:
An error occurred while loading ./spec/models/user_spec.rb. - Did you mean?
rspec ./spec/spec_helper.rb
Failure/Error: require File.expand_path('../config/environment', __dir__)
LoadError:
cannot load such file -- rexml/document
My user_spec.rb looks like this:
require 'rails_helper'
RSpec.describe User, type: :model do
it "tests my rspec installation"
end
I'm new to Rails so I would really appreciate any help!
Just add gem 'rexml' to your Gemfile and run bundle in terminal.
I get an issue when launching rspec
Failure/Error:
expect {
post :create, params: {tag: attributes_for(:tag)}
}.to change(Tag, :count).by(1)
NameError:
undefined local variable or method `matcher_name' for #<RSpec::Matchers::BuiltIn::Change:0x000000094f7348>
Did you mean? match_unless_raises
Edit :
it only occurs when I do
rspec
instead of
bundle exec rspec
Always use bundle exec with your project-related binaries. Without it, a wrong version is likely picked up. Check it.
rspec --version
bundle exec rspec --version
The console error log says probably you are supplying wrong method name, That's clear. Can you try changing the name of the method or variable which you are using?
You can also refer this for getting the difference between those two commands
bundle exec rspec VS rspec spec
I use both rake spec and rspec spec/ trying to run my rspec tests, but I get the following error:
/home/XXX/.rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/application/configuration.rb:49:in `initialize': uninitialized constant ActiveSupport::Logger::SimpleFormatter (NameError)
from /home/XXX/.rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/application.rb:364:in `new'
from /home/XXX/.rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/application.rb:364:in `config'
from /home/XXX/.rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/railtie.rb:123:in `config'
from /home/XXX/proj/candiru/config/application.rb:26:in `<class:Application>'
from /home/XXX/proj/candiru/config/application.rb:11:in `<module:Candiru>'
It's weird because this file (config/application.rb) is loaded when I start the rails server and rails console, without any problems.
The "suspicious" line is: config.assets.paths << Rails.root.join("vendor","assets","bower_components"), and if I comment it out, the next similar configuration line will marked as the error line.
Do you have any guess why this error is thrown?
I've just installed the 'sidekiq' gem and trying to run the following from the Terminal:
bundle exec sidekiq
When I run this though, I get the following error. This error does not occur when running the Rails server or loading the environment in the console.
undefined method `skip_authorization_check' for SessionsController:Class
It makes me think that the sidekiq script is trying to do something and it can't see that method. But I've not been able to make much progress with this.
Any clues?
I've inherited a Rails application that has no migrations and no schema. The Rails application was created off of multiple databases created years ago and all the Rails app does is it uses ActiveRecord to fetch data from the database.
I know in order to prepare a database for testing migrations have to be in place for Rails to set up the necessary testing environment. I'm trying to use a test suite that has rspec, capybara, selenium-webdriver and factory-girl but I can't get the configuration working properly
If anyone could give me any suggestions or advice on how I would go about doing this, that'd be great!
Thanks
UPDATE:
When I run bundle exec rspec spec I get an error related to selenium-webdriver saying this:
warning: already initialized constant Zip::VERSION
/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
When I run bundle exec rspec spec without the selenium-webdriver gem I get the same error as above:
/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
And if I just run rake I get this error:
Errors running test:units! #<NoMethodError: undefined method `[]' for nil:NilClass>