rspec

How to debug ruby tests in Eclipse/Aptana Studio?

笑着哭i 提交于 2021-02-07 08:52:23
问题 is there a way to debug all/single tests in Aptana Studio / Eclipse? ruby-debug19 & ruby-debug-ide are installed and I'm able to set breakpoints and debug my development environment, e.g. in a controller's index method. If I go to http://localhost:3000/controler_name eclipse opens debugging perspective and halts. But how to do that with tests / rspec tests? Thanks in advance. 回答1: For a normal ruby file, right click on it and select Debug As > Ruby application . If your test is a rails one

Using mocha for controller in functional test with RSPEC

[亡魂溺海] 提交于 2021-01-29 17:55:15
问题 I'm doing some tests here using Rspec and I would like to assure that the controller is calling the log method in some actions. I'm also using mocha. I would like something like this: it "update action should redirect when model is valid" do Tag.any_instance.stubs(:valid?).returns(true) put :update, :id => Tag.first controller.expects(:add_team_log).at_least_once response.should redirect_to(edit_admin_tag_url(assigns[:tag])) end is there something to use as the 'controller' variable? I tried

Rails - Singleton class troubles with rspec feature

跟風遠走 提交于 2021-01-29 10:32:36
问题 I have a problem testing a functionality that depends of a Singleton class. That class (ERPDao) is a suite with diferent methods that helps application to connect with external ERP vía REST services using Faraday gem. URLMaker is a helper class for build requests strings. When i try to run a feature spec that depends of one of this methods i have the following message in rspec: Failure/Error: result = ERPDao.instance.get_credit_info(erp_id) NoMethodError: undefined method `instance' for

RSpec double/mock print method from call

谁说我不能喝 提交于 2021-01-29 06:43:38
问题 My method prints in the console a list of viewed TV Shows. I want to test call method which trigger private print_result method: def initialize(parser) @parser = parser @views_hash = parser.page_views end def call puts "\n" puts 'LIST OF MOST POPULAR TV SHOWS' print_results(sort_all) puts "\n\n" end private def print_results(sorted_hash) puts "\n" puts "#{'TV Show'.center(20)} | VIEWS" puts '---------------------+----------' sorted_hash.each do |page, views_no| puts "#{page.ljust(20)} | #

How to prevent RSpec from abbreviating match_array output?

微笑、不失礼 提交于 2021-01-29 04:38:50
问题 I have just noticed that RSpec's match_array is abbreviating the error response. e.g., expected collection contained: [beginning, of, the, array....end, of, the, array] This did not use to be the case. Previously the output displayed the entire array contents, making it easier to identify what is causing the problem. It has been some time since I've had a failing match_array in these tests, so I'm not sure what has changed. Is there a setting to provide a more verbose match_array message? 回答1

How to prevent RSpec from abbreviating match_array output?

时间秒杀一切 提交于 2021-01-29 04:38:35
问题 I have just noticed that RSpec's match_array is abbreviating the error response. e.g., expected collection contained: [beginning, of, the, array....end, of, the, array] This did not use to be the case. Previously the output displayed the entire array contents, making it easier to identify what is causing the problem. It has been some time since I've had a failing match_array in these tests, so I'm not sure what has changed. Is there a setting to provide a more verbose match_array message? 回答1

Sending an email with Sidekiq RSpec Test failed because Array is empty and could not change from 0 to 1

*爱你&永不变心* 提交于 2021-01-29 02:58:57
问题 I am trying to test sending an email with Sidekiq and I am having an error which means it doesn't enqueue since my test shows it didn't change from 0 to 1 in size. Could it be I am missing something out or how can I fix this? Error expected `Array#size` to have changed by 1, but was changed by 0 0) Sending Mail sends email to sidekiq Failure/Error: expect do OrderPointsMailer.paid_order_email(customer_detail.id).deliver_later end.to change(Sidekiq::Worker.jobs, :size).by(1) expected `Array

How to properly mock itnernal services in RSpec?

混江龙づ霸主 提交于 2021-01-28 14:41:36
问题 I would like to learn how to properly mock object calls inside other classes, foor example I have this controller action: def show service = Action::PartsShow.new(show_params, current_user) service.call render json: service.part, root: :part, serializer: PartSerializer, include: '**', scope: {current_user: current_user} end The service class looks like this. module Action class PartsShow < PartsShowBase def find_part ... end end end module Action class PartsShowBase attr_reader :part def

How to properly mock itnernal services in RSpec?

我是研究僧i 提交于 2021-01-28 14:35:27
问题 I would like to learn how to properly mock object calls inside other classes, foor example I have this controller action: def show service = Action::PartsShow.new(show_params, current_user) service.call render json: service.part, root: :part, serializer: PartSerializer, include: '**', scope: {current_user: current_user} end The service class looks like this. module Action class PartsShow < PartsShowBase def find_part ... end end end module Action class PartsShowBase attr_reader :part def

RSpec + headless Chrome for front-end integration test

末鹿安然 提交于 2021-01-28 11:10:11
问题 I'm trying to test a part of my Rails 5.1 app that makes use of Vue.js. The issue I'm encountering is that, for example when generating a list, the Vue code looks like: <div v-for="(amenity, idx) in amenities"> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" v-bind:id="amenity.text" v-model="checkedAmenities[idx]" :value="amenity.id"> <label class="custom-control-label" v-bind="{ 'for': amenity.text }" >{{ amenity.text }}</label> </div> </div>