rspec

ActionMailer not delivering confirmation emails in test environment - Rails 4

六月ゝ 毕业季﹏ 提交于 2019-12-24 03:27:11
问题 I'm using Rails (4.2.6), Ruby (2.2.4), Devise (4.1.1), Capybara (2.7.1), Capybara-email (2.5.0), Email_spec (2.1.0), Rspec (3.4.0), and Postgres (0.18.4) After I upgraded the application from Rails 4.1.15 to 4.2.6, several authentification & registration tests fail. Before the upgrade all tests were properly passing. The code works as expected in the development environment (for example, confirmation emails are sent & viewable in the Rails server terminal). The problem of non-delivered emails

Rspec don't delete 2 specific tables

十年热恋 提交于 2019-12-24 03:07:17
问题 I am using Rspec for testing a rails application. I have 2 tables I imported data into (both the test and development database) The entire application is dependent on the tables data, meaning the entire functionality is matching, calculating and measuring data from this table and putting it into other tables. so, when testing, there's no point in deleting these table's data but Rspec is still deleting the data from them. my question is: how can I force Rspec not to delete data from these

How can I validate exit value in rspec? [duplicate]

萝らか妹 提交于 2019-12-24 03:01:52
问题 This question already has answers here : How can I validate exits and aborts in RSpec? (7 answers) Closed 5 years ago . I have a method that will sometimes call exit(numeric_value) . Is it possible for rspec to validate that when the method is invoked, the process is exiting with the correct value? I have seen these other posts, but they do not answer this specific question. How can I validate exits and aborts in RSpec? How to spec methods that exit or abort 回答1: Given sample ruby code: def

Capturing STDOUT in RSpec

六眼飞鱼酱① 提交于 2019-12-24 02:57:28
问题 I'm new to unit testing in Ruby and I'm having some trouble creating a spec that will check for STDOUT. I know how to test STDOUT if the code I'm testing is within a Class/Method, but I want to just test a puts statement coming from a regular Ruby file that's not within a Class or Method. Here is the simple one liner from my_file.rb puts "Welcome to the Book Club!" Here's the spec my_spec.rb require_relative 'my_file.rb' describe "Something I'm Testing" do it 'should print Welcome to the Book

Capybara selecting root node rather than specified node

我怕爱的太早我们不能终老 提交于 2019-12-24 02:43:08
问题 When running locally, the code works as expected, but when running on CI server (circle CI) it behaves strangely. I call the #find method passing in a css selector, this normally returns the specific DOM node or throws an error. card = find('.card__title', text: display_name).ancestor('.card') expect(card).to have_no_selector('.read') On the CI server, it doesn't throw an error, rather the variable card has the value of: #<Capybara::Node::Element tag="html" path="/HTML"> and the expectations

Why does 'rspec spec' run faster and use less resources than 'bundle exec spec'

旧城冷巷雨未停 提交于 2019-12-24 02:13:51
问题 Below are 3 random runs using time rspec spec vs time bundle exec spec on a fairly simple rails 3 app. Not using bundler is consistently faster AND it uses a lot less resources, 6% vs 17% cpu. I'm sure it has something to do with bundler handling the dependencies but I'd like to understand this problem better. I try to practice TDD so of course I run my tests many times throughout the day. If using bundle exec is going to "cost" me in terms of speed and resources then I'm tempted to find a

Why does visiting my root path require warmup time to make my test data available?

两盒软妹~` 提交于 2019-12-24 02:06:14
问题 I am in the process of switching from capybara-webkit to poltergeist/phantomjs. I'm experiencing a timing problem and I've determined which line of code needs warmup time, but I can't determine why this is or how to solve it. I have a 225 line spec file with a couple dozen tests. On any given test run, 1 or 2 of them will consistently fail. It can be any of them, it's not consistent. This before block applies to all the tests. I've annotated the code to explain the situation. before do # -->

Rails and RSpec: Testing controllers with the same name in different namespace (module)

喜欢而已 提交于 2019-12-24 02:00:45
问题 I have rails 4.1.16 API application that is tested using RSpec 3.4.0, and I experience problems with testing classes called the same name in a different module. The structure is: app/controllers/bar/notifications_controller.rb class Bar::NotificationsController < ApiController ... end and controller with the same name in a different module: app/controllers/foo/bar/notifications_controller.rb module Foo class Bar::NotificationsController < ApiController ... end end The Foo is a new module and

Setting http status codes

佐手、 提交于 2019-12-24 01:46:18
问题 redirect_to browse_path(asset.parent_id), notice: "successfully created file!", status: 201 201 is the status you should set if you've created a resource. While the above method works for a create action, the spec for its action no longer does: subject { response } describe '.create' do context 'when orphan' do before do post :create, asset: { parent_id: nil, uploaded_file: file } end it { should have_http_status 201 } it { should redirect_to '/' } end end The status expectation passes, but

How to test ActionCable along with Devise using rspec?

北慕城南 提交于 2019-12-24 01:22:44
问题 In my Rails (5.1) application I'm using devise for authentication and ActionCable. My ActionCable connection looks like: module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect puts 'current_user:', current_user.inspect self.current_user = find_verified_user logger.add_tags 'ActionCable', current_user.id end def disconnect # ... end protected def find_verified_user verified_user = env['warden'].user return verified_user if verified_user