Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minitest-given not working in controller tests #49

Open
schadenfred opened this issue Mar 22, 2015 · 2 comments
Open

minitest-given not working in controller tests #49

schadenfred opened this issue Mar 22, 2015 · 2 comments

Comments

@schadenfred
Copy link

I'm able to run model tests but not controller tests with minitest-given. Here's a controller test that I feel should be passing:

require "test_helper"

context "OrgsController" do

  Given(:org) { FactoryGirl.build(:org) }  
  Given(:user) { FactoryGirl.create(:confirmed_user) }
  Given(:user) { sign_in user }

  context "gets index" do

    When { get :index }
    Then { assert_response :success }
  end
end

Here is the terminal output:

20:39:25 - INFO - Running: test/controllers/orgs_controller_test.rb
rake aborted!
NoMethodError: undefined method `Given' for #<Class:0x007f8899292150>
/home/fred/work/projects/compliancemaster/test/controllers/orgs_controller_test.rb:5:in `block in <top (required)>'
/home/fred/work/projects/compliancemaster/test/controllers/orgs_controller_test.rb:3:in `<top (required)>'
-e:1:in `<main>'
Tasks: TOP => test:single
(See full trace by running task with --trace)

@aviflax
Copy link

aviflax commented Feb 5, 2016

I’m having this problem now… did you ever figure this out?

@aviflax
Copy link

aviflax commented Feb 5, 2016

Ah, in my case it turned out to be because I was using Given/When/Then in it blocks, I had to change them to context as per this Stack Overflow answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants