Skip to content

Instantly share code, notes, and snippets.

@thisismydesign
Last active October 30, 2017 20:08
Show Gist options
  • Save thisismydesign/87e0b42bbab175445da56b34d58ddfcf to your computer and use it in GitHub Desktop.
Save thisismydesign/87e0b42bbab175445da56b34d58ddfcf to your computer and use it in GitHub Desktop.
Using rspec-rails in non-rails projects
ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found.
-e:1:in `load'
-e:1:in `<main>'
An error occurred while loading ./spec/project/project_spec.rb.
Failure/Error: require 'rspec/rails'
NameError:
uninitialized constant ActionView::Template::Handlers::ERB::ENCODING_FLAG
Did you mean? Encoding
# ./spec/spec_helper.rb:9:in `require'
# ./spec/spec_helper.rb:9:in `<top (required)>'
# ./spec/project/project_spec.rb:1:in `require'
# ./spec/project/project_spec.rb:1:in `<top (required)>'
# -e:1:in `load'
# -e:1:in `<main>'
expect {
Job.perform_later
}.to have_fgkjbfvghfjk(Job)
# => You must pass an argument rather than a block to use the provided matcher (have fgkjbfvghfjk Job), or the matcher must implement `supports_block_expectations?`.
expect {
Job.perform_later
}.to fgkjbfvghfjk(Job)
# => NoMethodError: undefined method `fgkjbfvghfjk' for #<RSpec::ExampleGroups::Something:0x007f827dab4170>
expect(Job).to have_been_enqueued
# => expected Job to respond to `has_been_enqueued?`
expect {
Job.perform_later
}.to have_enqueued_job(Job)
# => You must pass an argument rather than a block to use the provided matcher (have enqueued job Job), or the matcher must implement `supports_block_expectations?`.
require "action_controller/railtie"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment