Skip to content

Repository files navigation

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.

About

RSpec matchers for Breadkit circuit connections and switch states.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages