0.0
The project is in a healthy, maintained state
Test resolved Breadkit circuit connections and switch states with RSpec expectations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

Breadkit logo

breadkit-rspec

Test Breadkit circuit connections and switch states with RSpec.

RubyGems version CI status Ruby 3.3 or newer MIT license

Assert that pins, board holes, and named nets share a connection in a resolved Breadkit circuit. Check connections in named switch states with the same matcher.

Quick start

Install in an RSpec project with Ruby 3.3 or newer. breadkit-rspec depends on Breadkit 0.2.x:

gem install breadkit-rspec

With Bundler, add gem "breadkit-rspec", "~> 0.1" to your Gemfile instead.

Load the matcher in spec/spec_helper.rb:

require "breadkit/rspec"

With Breadkit's LED and button example saved as circuits/led.bk.rb, add a spec:

RSpec.describe "LED circuit" do
  let(:circuit) { Breadkit.load("circuits/led.bk.rb") }

  it "connects the LED through the resistor" do
    expect(circuit).to connect("R1.2", "D1.anode")
    expect(circuit).not_to connect("D1.cathode", :VCC)
  end

  it "connects the input when the button is pressed" do
    expect(circuit).to connect("R1.1", :VCC).in_state("SW1")
  end
end

connect accepts pin aliases, hole IDs, and named nets. An unknown reference raises ArgumentError; a failed connection expectation reports the resolved nets.

Switch states

Use .in_state("SW1") to close one switch or .in_state("SW1,SW2") to close several. Other switches stay open, so you do not need to enumerate every switch combination. Unknown or repeated switch names raise ArgumentError.

Development

Clone Breadkit and this gem as sibling directories, then run:

git clone https://github.com/breadkit/breadkit.git
git clone https://github.com/breadkit/breadkit-rspec.git
cd breadkit-rspec
bundle install
bundle exec rake

License

MIT.