def check_url(url)
return true if /^(?:(?:https\:\/\/))|(?:(?:http\:\/\/))/.match(url)
return false
end
describe "check_url" do
include ActionView::Helpers
it "should return false if url does not have http or https" do
@user = FactoryGirl.create(:user)
@user.website = "test-test.test.test"
expect(check_url(@user.website)).to eql(false)
end
it "should return true if url does have http" do
@user = FactoryGirl.create(:user)
@user.website = "http://test-test.test.test"
expect(check_url(@user.website)).to eql(true)
end
it "should return true if url does have https" do
@user = FactoryGirl.create(:user)
@user.website = "https://test-test.test.test"
expect(check_url(@user.website)).to eql(true)
end
end
-
User check_url should return false if url does not have http or https Failure/Error: expect(check_url(@user.website)).to eql(false)
NoMethodError: undefined method `check_url' for #<RSpec::ExampleGroups::User::CheckUrl:0x000027ddbee628> Did you mean? check_box # ./spec/models/user_spec.rb:56:in `block (3 levels) in <top (required)>'
-
User check_url should return true if url does have http Failure/Error: expect(check_url(@user.website)).to eql(true)
NoMethodError: undefined method `check_url' for #<RSpec::ExampleGroups::User::CheckUrl:0x000027dec9fbe8> Did you mean? check_box # ./spec/models/user_spec.rb:61:in `block (3 levels) in <top (required)>'
-
User check_url should return true if url does have https Failure/Error: expect(check_url(@user.website)).to eql(true)
NoMethodError: undefined method `check_url' for #<RSpec::ExampleGroups::User::CheckUrl:0x000027ded48608> Did you mean? check_box # ./spec/models/user_spec.rb:66:in `block (3 levels) in <top (required)>'