RSpec is a behaviour-driven development (BDD) framework for the Ruby language.
1
vote
0answers
19 views
Creating a list of things by looking up multiple sources
I am trying to write a rspec webmock test for a rails PORO model. What this model does is, query bugzilla with a set of filters for a list of bugs and iterate over it such that:
The bug ids are used ...
4
votes
1answer
72 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 ...
0
votes
3answers
30 views
3
votes
1answer
94 views
Ruby FizzBuzz solution with Rspec test
My code makes the four tests pass, but I'm worried I'm missing something. Is the code too simple and not encompassing enough? I'm just beginning to learn so any feedback is welcome!
Here's the Rspec ...
2
votes
2answers
57 views
A sequence of mistakes
This question is part of a series solving the Rosalind challenges. For the previous question in this series, see The Genetic Code. The repository with all my up-to-date solutions so far can be found ...
0
votes
0answers
37 views
Testing the integration of a recurring billing system
I'm trying to write tests for a recurring billing system. I want these tests to show that the functionality of the system works when put together - I have lots of unit tests, but I wanna make sure ...
4
votes
1answer
79 views
Simple Ruby program to model a prepaid transit card system
I have written a simple Ruby program to model a transit card system which aims to address the following user stories. I wanted to see whether I could get any feedback on it. My main interest is ...
1
vote
1answer
163 views
Creating a dictionary
I have a Ruby programming task. My code passes all the rspec requirements, but I am not sure if I've done it in the right way. And I'm not quite sure why I need ...
2
votes
1answer
84 views
Rspec controller tests
I wanted to keep my controller tests DRY, readable, and make writing new tests very simple so that it encourages good practices like one assertion per test (if you have to redo a lot of work over and ...
1
vote
0answers
41 views
Geocoding users' IPs
My Rails app geocodes users' IP when they are created and also when they update their data only if they change their city. The geocoding is slowing down my tests ridiculously.
This seems to me to be ...
1
vote
3answers
628 views
Checking whether two strings are isomorphic
I was trying to solve a problem to determine if 2 strings are isomorphic. They are isomorphic when each character in string one can be replaced with another character in string 2. Two different ...
4
votes
1answer
223 views
Rspec - testing basic functionality - redundant testing?
Being pretty new to testing, I was wondering how many of these tests make sense.
restaurants_controller_spec.rb
...
3
votes
2answers
384 views
Building a chain of responsibility in Ruby to apply transformators on an object
I try to make a middleware stack system in the rack way (but not for HTTP request).
Here is the main class:
...
2
votes
3answers
135 views
Controller actions permisson specs
I'm just starting with rails and testing, and not sure what's good way to dry code like this.
...
2
votes
0answers
135 views
5
votes
1answer
1k views
RSpec test for pagination
This is a Rspec test for pagination in Rails project. I'm not sure if I should write the test in spec/requests or ...
2
votes
1answer
132 views
DRY-ing up some rspec
I have an rspec spec test that has two sets of the same tests (from 24 Pull Requests). I thought I'd refactor the spec whilst I fixed something else.
Normally I just do a basic ...
0
votes
2answers
166 views
Factory Girl in Rails
I have a FactoryGirl page that generates same data but in two different languages. The variable names are the same. How do I write it in the smartest way possible without having to write a huge bunch ...
2
votes
3answers
515 views
RSpec/Capybara tests
There are three scenarios only for when the sign up validations fail, so is there a better way of representing them rather than having 4 scenarios? I don't want to create a model folder so please don'...
7
votes
2answers
2k views
Using I18n in capybara feature specs
Here I am trying to avoid hardcoding in flash messages by using I18n. Also, I have tried to use a CSS selector for submitting the form to make the tests less brittle (I don't really care that much ...
3
votes
1answer
112 views
Mixing Watir::Browser into RSpec
In my previous Watir question I was making a module with session_FF accepting a block.
Now I want to make the same but via RSpec. Here is my try:
...
1
vote
2answers
142 views
Removing duplication in RSpec
I’m still relatively new to the TDD scene. I’m writing a Rails app, and some duplication immediately sticks out at me in my first model spec. How else can I approach this?
...
2
votes
1answer
61 views
Unit-testing account transaction code
I'm playing with unit-testing in Ruby. There is a situation that I don't know if is good enough or if I am doing the wrong abstraction.
I have two classes: ...
1
vote
2answers
684 views
Various RSpec tests
I've just written my first full batch of RSpec tests and wondered if anyone can comment at a glance on how they might be written easier, more readable, faster etc. There are some pending specs so ...
7
votes
1answer
577 views
Binary converter and sufficient tests
I just finished writing a basic binary conversion class in Ruby. I'm curious to see if anyone has suggestions for improvements. In particular, I'm looking for the cleanest, shortest, most succinct ...
7
votes
1answer
8k views
My first controller rspec test
I'm just started learning TDD with Rails and RSpec. This is my first test for controller. Just plain RESTful UserController that responds with JSON, so it has no new and edit methods. Please review it
...
5
votes
1answer
373 views
BinarySearch Kata in Ruby
I've just completed this binary search kata - which has some weird requirements - and I spent a little while "cleaning" up my code and making it more compact. I would appreciate some feedback on the ...
4
votes
2answers
588 views
10
votes
2answers
520 views
Cash Register Kata
The Setup
This kata is a spin on the old backpack problem. Please give feedback on both the kata itself as well as my solution. I'm not sure if the kata needs to lead the student more or if this is a ...
3
votes
1answer
110 views
3
votes
1answer
763 views
2
votes
3answers
733 views
Pig Latin Code Kata
I've just complete a Pig Latin translator as a code kata and I was hoping someone would review it for me.
Here is the kata:
...
2
votes
1answer
446 views
How can this rails controller test be cleaner refactored?
I tend to write quite explicit tests for my rails controllers exposing APIs with two seperate concerns:
meeting the defined API-Response with headers headers and the response itself
ensuring the ...
1
vote
1answer
197 views
Ruby Kata Gem: WordWrap
I've just completed the WordWrap Kata in the Ruby Kata gem and I'd love some feedback. Thanks!
Here's the Kata:
...
2
votes
1answer
309 views
Advanced Calculator Kata
This is the CalculatorAdvanced Kata from the Kata gem. I've just finished it and would love some feedback on my solution.
...
4
votes
1answer
148 views
Weekly flex calculator
This is one of the first RSpec tests I've written, and I'm not really sure what the best practices are etc.
My question basically is: what would you do differently? What is good? What is bad?
The ...
2
votes
1answer
132 views
Using RSpec subject to setup a test
I find myself using subject blocks in my tests to setup example because it is succinct. However is this considered bad form and can it have undesired consequences?
...
2
votes
1answer
77 views
2
votes
1answer
177 views
Test for a Rails app
Here's a test from a Rails app I'm working on. I want to know if I'm using describe, let, ...
3
votes
1answer
2k views
Testing a Content model
I'm new to RSpec and testing in general. I've come up with a spec for testing my Content model and I need some feedback because I think there are many improvements ...
3
votes
2answers
545 views
Ruby implementation of Conway's Game of Life
I'm just starting with Ruby and decided to do two different implementations of Conway's Game of Life. In this first one I'm not using cells as a separate class and ...
1
vote
1answer
71 views
3
votes
2answers
8k views
RSpec integration tests for a simple Rails API
The Model is simple: a Player class with three attributes: first_name, last_name, and ...
3
votes
1answer
158 views
5
votes
2answers
778 views
Spoj's 1st problem in tdd using Ruby
I am pretty new to TDD and is following problems on spoj.pl for practice. I need help with following code; it was my first attempt.
Problem: Your program is to use the brute-force approach in order ...
2
votes
1answer
2k views
1
vote
1answer
527 views
4
votes
3answers
212 views
First BDD/RSpec tests, would like some review regarding idioms, conventions and style
This is my first attempt at BDD and RSpec. I'm more of a C# xUnit kind of guy.
I wrote this class while developing a 2D random tile map generator (just for fun). The project is still ongoing.
I ...
0
votes
1answer
143 views
Rspec Request break when teammate pushes some changes
This is my rspec integration test for user, it always breaks when my teammate change something, how do i improve this?
...
2
votes
1answer
2k views
Tidying scaffolded Rails controller spec with subject/let
I was just looking at a standard scaffolded Rails controller spec, and tried to get it to use subject or let blocks, and failed miserably ... can subject or let tidy controller specs the same as it ...