I'm trying to write a simple test but my application is not detecting 'users' keyword when I'm using it in my Test functions:
post_controller_test.rb
require 'test_helper'
class PostsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
test "should fetch facebook post" do
sign_in users(:one)
get(:save_posts_from_facebook_page,{'id'=>'my_id'},{'access_token'=>Rails.application.secrets.fb_access_token})
assert_response :success
end
end
test_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
include Devise::TestHelpers
# Add more helper methods to be used by all tests here...
end
users.yml
# Read about fixtures at http://ift.tt/1BqMnxt
one:
email: hello@testing.com
encrypted_password: <%= Devise.bcrypt(User,'password') %>
links:
causes:
two:
email: MyString
password: MyString
links:
causes:
output of rake/Error:
Run options: --seed 42684
# Running:
E
Finished in 0.010275s, 97.3279 runs/s, 0.0000 assertions/s.
1) Error:
PostsControllerTest#test_should_fetch_facebook_post:
NoMethodError: undefined method `users' for #<PostsControllerTest:0x000001042152f0>
test/controllers/posts_controller_test.rb:9:in `block in <class:PostsControllerTest>'
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
Aucun commentaire:
Enregistrer un commentaire