Skip to main content

Setup in RSpec

  • As always, add a new entry to your Gemfile as the first step.

    gem "convenient_service", "~> 0.19.1"
  • Then run bundle to install the gem.

    bundle install
  • Add the following line to your spec_helper.rb or rails_helper.rb.

    ConvenientService::Dependencies.require_rspec_extentions
  • To ensure Convenient Service RSpec extentions are properly loaded, define a quick service, for example:

    class Service
    include ConvenientService::Standard::Config

    def result
    success
    end
    end
  • Create the specs for it.

    RSpec.describe Service do
    include ConvenientService::RSpec::Matchers::Results

    example_group "class methods" do
    describe ".result" do
    let(:result) { described_class.result }

    context "when `Service` is successful" do
    it "returns `success`" do
    expect(result).to be_success.of_service(described_class).with_data.without_step
    end
    end
    end
    end
    end
  • Finally, run them.

    bundle exec rspec spec/service_spec.rb
  • That's it. Happy testing!