Description
CodeBreaker breaks a line of Ruby code into its receiver classes and the methods that are called on them.
The idea behind this is to make global lines of code like the following one testable:
sum = Rational(2, 3) + 4
By breaking down this line into the receiver classes and called methods you can check e.g. whether a code snippet assigns the sum of a Rational and an Integer to a variable with the name sum.
Testing global code snippets might be important for testing the code of simple programming tasks in learning tools like Daigaku.
CodeBreaker alternatives and similar gems
Based on the "Testing" category.
Alternatively, view CodeBreaker alternatives based on common mentions on social networks and blogs.
-
vcr
Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. -
minitest
minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking. -
timecop
A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call. -
Spork
A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state. -
Konacha
Test your Rails application's JavaScript with the mocha test framework and chai assertion library -
Fabrication
DISCONTINUED. This project has moved to GitLab! Please check there for the latest updates. -
Knapsack
Knapsack splits tests evenly across parallel CI nodes to run fast CI build and save you time. -
ActiveMocker
Generate mocks from ActiveRecord models for unit tests that run fast because they don’t need to load Rails or a database. -
Wrong
Wrong provides a general assert method that takes a predicate block. Assertion failure messages are rich in detail. -
RR
RR is a test double framework that features a rich selection of double techniques and a terse syntax. ⛺ -
turbo_tests
Run RSpec tests on multiple cores. Like parallel_tests but with incremental summarized output. Originally extracted from the Discourse and Rubygems source code. -
RSpecTracer
RSpec Tracer is a specs dependency analyzer, flaky tests detector, tests accelerator, and coverage reporter tool for RSpec. It maintains a list of files for each test, enabling itself to skip tests in the subsequent runs if none of the dependent files are changed. It uses Ruby's built-in coverage library to keep track of the coverage for each test.
Scout Monitoring - Performance metrics and, now, Logs Management Monitoring with Scout Monitoring
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of CodeBreaker or a related project?
README
CodeBreaker
CodeBreaker breaks a line of Ruby code into its receiver classes and the methods that are called on them.
The idea behind this is to make global lines of code like the following one testable:
sum = Rational(2, 3) + 4
By breaking down this line into the receiver classes and called methods you can
check e.g. whether a code snippet assigns the sum of a Rational and an Integer to
a variable with the name sum
.
Testing global code snippets might be important for testing the code of simple programming tasks in learning tools like Daigaku.
Installation
Add this line to your application's Gemfile:
gem 'code_breaker'
And then execute:
$ bundle
Or install it yourself as:
$ gem install 'code_breaker'
Usage
You can break a Ruby code snippet into its receivers and called method:
require 'code_breaker'
code_snippet = 'crazy_number = Rational(3, 5) + 42 - Complex(2.3, 6.4) * 1.2'
CodeBreaker.parse(code_snippet)
# => {:lvasgn=>[:crazy_number, [Rational, :+, Integer, :-, Complex, :*, Float]]}
code_snippet = '"hello" + "World"'
CodeBreaker.parse(code_snippet)
# => [String, :+, String]
You can also use the Parser class directly:
code_snippet = '"hello" + "World"'
parser = CodeBreaker::Parser.new(code_snippet)
parser.run
# => [String, :+, String]
parser.output
# => [String, :+, String]
parser.input
# => "\"hello\"+\"world\""
Implemented syntax
For an overview of the implemented syntax and examples for certain parsed Ruby statement please see the project's Wiki.
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/daigaku-ruby/code_breaker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
*Note that all licence references and agreements mentioned in the CodeBreaker README section above
are relevant to that project's source code only.