Skip to content

Commit

Permalink
require webmock and use it to stub out trefle data
Browse files Browse the repository at this point in the history
  • Loading branch information
one-m1nd committed Mar 4, 2024
1 parent 45186f0 commit 43b2df4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion spec/models/plant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@
end

describe '#trefle_data' do
it do
before(:each) do
stub_request(:get, "https://trefle.io/api/v1/plants/search")
.with(query: { q: Plant.first.name })
.to_return(status: 404, headers: { 'Content-Type' => 'application/json' })

end

subject { Plant.first.trefle_data }

it do
expect(subject).to be_instance_of(Hash)
end
end
end
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
require 'webmock/rspec'
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
# Prevent database truncation if the environment is production
Expand Down

0 comments on commit 43b2df4

Please sign in to comment.