I created a controller that can read api data at a special url.
def category @data = get_api_data(param1) end def get_api_data(param1) "http://my_api_url/param1=#{param1}" end
After creating the view, I see the result from the browser.
If I use rspec + capybara to run a function test
visit category_path('param1')
Then I want to confirm that the api data will be shown in the field of view
expect(page).to have_field('name', with: 'aaa')
But the @data value @data always null. What for? Do i need to make api url access message from test code? If necessary, how to do it? The visit method cannot accept other parameters.
source share