laserlemon / figaro

Simple Rails app configuration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In some tests Figaro.env works but in others it won't

THPubs opened this issue Β· comments

I have two test files. One for pages controller and the other for users controller. Here are the two files πŸ‘

pages_controller:
require 'test_helper'

    class PagesControllerTest < ActionController::TestCase
      test "should get home" do
        get :home
        assert_response :success
        assert_select "title", "#{Figaro.env.app_name}"
      end
    end

users_controller:

    require 'test_helper'

    class UsersControllerTest < ActionController::TestCase

      test "should get signup" do
        get :signup
        assert_response :success
        assert_select "title", "SignUp | #{Figaro.env.app_name}"
      end

    end

As you can see I have used the same way to get the app_name in both the files. But the problem is, the first one works and the second one does not. I get the following error when running the tests :

    1) Failure:
    UsersControllerTest#test_should_get_signup [/home/pubudu/Projects/istockseller/test/controllers/users_controller_test.rb:8]:
    <SignUp | > expected but was
    <SignUp |>..
    Expected 0 to be >= 1.

How can I fix it?

We have to include Figaro.require_keys in test helper. I used only Figaro.require.