Skip to main content
Code Review

Questions tagged [rspec]

RSpec is a behaviour-driven development (BDD) framework for the Ruby language.

Filter by
Sorted by
Tagged with
0 votes
2 answers
279 views

Ruby on Rails _form implicit partial test with RSpec

I am working with: ruby 3.0.0p0 and Rails 7.0.4 and rspec-rails (6.0.1) I want to test my views. I created Product model with rails scaffolding. I tested all views but I am not sure about _form.html....
1 vote
1 answer
282 views

RSpec: Compound Expectations

It's an exercise from a RSpec-course, which I'm currently doing. Task: Create a compound expectation, which asserts the string sportscar starts with the substring "sports" and ends with the ...
3 votes
1 answer
440 views

RSpec shared example for CRUD Controllers that might be nested or not

I've been trying to create a shared example to quickly and efficiently test controllers with CRUD operations that might also be nested. I came up with this ...
Manos's user avatar
  • 31
2 votes
1 answer
1k views

Rspec test for Rails method to return alphabetically sorted list of tags

I have one model class as listed here: class Post < ActiveRecord::Base has_many :comments def tags comments.map(&:tag).uniq.sort end end and ...
3 votes
0 answers
125 views

Validating Amazon CloudFormation templates using Rspec

I have created an open source project that uses Rspec to validate the formatting of AWS::CloudFormation::Init YAML blocks in CloudFormation templates.1 My project is here. Some general concerns: Is ...
1 vote
3 answers
255 views

Calculate cryptocurrency gains and losses using the Coinbase API

This class calculates the gains and losses (in USD) from the four leading cryptocurrencies using the Coinbase API. (The full repo can be found here) In addition to general feedback there are some ...
1 vote
1 answer
763 views

RSpec test for handling known IP addresses

I want to replace the array of ips with a method (like known_ips or just ips) but I don't know how. I'll use this ...
2 votes
1 answer
4k views

Rspec unit test for updating a property of a model

I know how to write simple RSpec tests and unit tests. I just want to know if this is good enough or if there are any improvements I can make. I intend to test the the ...
2 votes
0 answers
1k views

Rails CRUD feature specs (RSpec and Capybara)

The following feature spec tests CRUD operations for the users resource in a Rails 4.2.8 application. It includes tests for filtering, sorting and pagination ...
4 votes
1 answer
2k views

Rails & RSpec - Testing API with request specs and shared examples

I have written the following shared examples which are used in multiple request specs to test a namespaced RESTful JSON API. Application details: Rails 4.2, RSpec 3.5, Devise for authentication and ...
3 votes
1 answer
643 views

Controller tests (Rails 4.2 and RSpec 3.5)

The following code is a controller spec used in a Rails 4.2 application with RSpec 3.5. I would greatly appreciate your suggestions on how to improve it (e.g., efficiency, readability, maintainability,...
1 vote
2 answers
264 views

Testing a chance-based class

So, chance, huh? Randomness. I'm looking into how I can test a class whose sole responsibility is to return weighted random results, that is, where there is a set probability of returning true. The ...
3 votes
1 answer
254 views

Ruby sudoku solver using backtracking (interview)

I was required to implement the code to a spec file I was provided in Ruby. I was rejected with the message "The quality of your code isn't sufficient for this position". Can you please tell me what ...
4 votes
1 answer
542 views

Marketplace checkout system

I was given the following code challenge as part of an interview process, unfortunately I did not get through to the next stage. Any advice on how I could improve would be very much appreciated. Here ...

15 30 50 per page
1
2 3 4 5

AltStyle によって変換されたページ (->オリジナル) /