Created
September 6, 2015 23:37
-
-
Save yulgit1/5f72f160183cdda2337f to your computer and use it in GitHub Desktop.
application_controller_spec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ermadmix@libdev controllers]$ more application_controller_spec.rb | |
require 'spec_helper' | |
describe ApplicationController do | |
describe "accessing ip_whitelist.yml" do | |
it "should have a number of ip addresses" do | |
ip_whitelist = YAML.load_file(Rails.root.join('spec','templates','ip_whitelist.yml')) | |
ips = ip_whitelist.fetch("whitelist") | |
expect(ips.size).to equal(3) | |
end | |
end | |
describe "#ip_whitelist" do | |
before (:all) do | |
@ymlfile = Rails.root.join('spec','templates','ip_whitelist.yml') | |
end | |
it "should return clean if ip in list" do | |
#request.remote_ip = "172.28.80.30" | |
#ActionDispatch::Request.any_instance.stub(:remote_ip).and_return("172.28.80.30") | |
allow_any_instance_of(ActionDispatch::Request).to receive(:remote_ip).and_return("172.28.80.30") | |
#allow_any_instance_of(ActionDispatch::Session).to receive(:ip_check).and_return(nil) | |
request.session[:ip_check] = nil | |
#get 'index' | |
#response.status.should be (200) | |
ac = ApplicationController.new | |
#ac.instance_variable_set(@_request, ActionDispatch::Request.new) | |
#ac._request = ActionDispatch::Request.new | |
#ac._request.session[:ip_check] = nil | |
#ac._request.session[:ip_check] = nil | |
expect{ac.undefmethod}.to raise_error(NoMethodError) | |
expect(ac.ip_white_list(@ymlfile)).to be_nil | |
end | |
it "should return clean if session ip_check exists" do | |
end | |
it "should redirect if ip not in list" do | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment