I have a question with RSpec testing. I am using FactoryGirl, Capybara 2.* and trying to testing my website behavior.
Scenario of testing: User clicking on sign_in button (devise controller), he is redirected to root_path (managed by MyController). After his redirection before_filter :setup_params should assign to @app variable (in action :find_apps in MyController) some values. I would like to ensure that @app is not nil and that values were assigned.
here is my sign_in_spec.rb
require "spec_helper.rb"
require "mymodel.rb"
describe MyContoller, :type => :feature do
before do
visit '/users/sign_in'
end
it "Shall redirect to user and ensure that @app is not nil" do
user = FactoryGirl.build(:user_monit)
fill_in "user[email]", with: user.email
fill_in "user[password]", with: user.password
#expect {click_button "Sign in"}.to change {@myapp}.from(nil)
click_button "Sign in"
get :find_apps
assigns(:myapp).should_not be_nil
end
end
require section in my spec_helper.rb
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'
require 'mocha/setup'
require 'factory_girl'
....
config.include RSpec::Rails::RequestExampleGroup, type: :feature
I have got several mistakes:
1) result should have changed, but is still nil
2) bad argument error for get :find_apps (ArgumentError: bad argument (expected URI object or URI string))
What am I doing wrong?
Thanks in advance!