Commit c65cbdd7 authored by PiTrem's avatar PiTrem
Browse files

spec maint

parent 1429ca77
......@@ -14,6 +14,7 @@
.ruby-gemset
.ruby-version
.coveralls.yml
.nvmrc
.env
/config/database.yml
......
......@@ -8,3 +8,7 @@ addons:
postgresql: "9.3"
services:
- postgresql
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- bundle exec rake
......@@ -54,7 +54,7 @@ gem 'roo', ">2.3.0"
gem 'httparty'
# Ketcher editor
gem 'ketcherails', '0.1.3', github: 'ComPlat/ketcher-rails'
gem 'ketcherails', github: 'ComPlat/ketcher-rails', branch: 'extrema_search_safe'#'0.1.3', github: 'ComPlat/ketcher-rails'
# Free font icons
gem "font-awesome-rails"
......@@ -131,10 +131,10 @@ group :test do
gem 'factory_girl_rails'
gem 'database_cleaner'
gem "faker", "~> 1.4"
gem "capybara", "~> 2.4"
gem "launchy", "~> 2.4"
gem "selenium-webdriver", "~> 2.43"
gem "faker", "~> 1.6.6"
gem "capybara", "~> 2.7.1"
gem "launchy", "~> 2.4.3"
gem "selenium-webdriver", "~> 2.53.4"
end
# Chemotion plugins: lsit your chemotion specific plugin gems here
......
GIT
remote: git://github.com/ComPlat/ketcher-rails.git
revision: 10772e248579cf96b4d2dd6dd66181b07d832a65
revision: 5b4a1cc0252cda98733771a96a7c3cce54494550
branch: extrema_search_safe
specs:
ketcherails (0.1.3)
bootstrap-kaminari-views
......@@ -196,7 +197,7 @@ GEM
factory_girl_rails (4.7.0)
factory_girl (~> 4.7.0)
railties (>= 3.0.0)
faker (1.6.3)
faker (1.6.6)
i18n (~> 0.5)
ffi (1.9.10)
font-awesome-rails (4.6.2.0)
......@@ -387,7 +388,7 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
selenium-webdriver (2.53.0)
selenium-webdriver (2.53.4)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
......@@ -472,7 +473,7 @@ DEPENDENCIES
capistrano-rails
capistrano-rvm
capistrano3-delayed-job
capybara (~> 2.4)
capybara (~> 2.7.1)
coveralls
daemons
database_cleaner
......@@ -480,7 +481,7 @@ DEPENDENCIES
devise
dotenv-rails
factory_girl_rails
faker (~> 1.4)
faker (~> 1.6.6)
font-awesome-rails
fontcustom
grape
......@@ -492,8 +493,8 @@ DEPENDENCIES
jbuilder (~> 2.0)
jquery-rails
kaminari
ketcherails (= 0.1.3)!
launchy (~> 2.4)
ketcherails!
launchy (~> 2.4.3)
mailcatcher
nokogiri
openbabel (= 2.3.2.1)!
......@@ -509,7 +510,7 @@ DEPENDENCIES
sablon!
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
selenium-webdriver (~> 2.43)
selenium-webdriver (~> 2.53.4)
spring
svg2pdf!
thin
......
......@@ -235,7 +235,7 @@ class Sample < ActiveRecord::Base
def init_elemental_compositions
residue = self.residues[0]
return unless m_formula = self.molecule.sum_formular
return unless m_formula = (self.molecule && self.molecule.sum_formular)
if residue.present? && self.molfile.include?(' R# ')# case when residue will be deleted
p_formula = residue.custom_info['formula']
......
......@@ -3,4 +3,5 @@ test:
encoding: unicode
database: travis_ci_test
username: postgres
pool: 5
host: localhost
......@@ -6,9 +6,9 @@ module SVG
def initialize(materials_svg_paths, options = {})
@svg_path = File.join(File.dirname(__FILE__), '..', '..', 'public', 'images', 'molecules')
@starting_materials = materials_svg_paths[:starting_materials]
@reactants = materials_svg_paths[:reactants]
@products = materials_svg_paths[:products]
@starting_materials = materials_svg_paths[:starting_materials] || []
@reactants = materials_svg_paths[:reactants] || []
@products = materials_svg_paths[:products] || []
number_of_reactants = (@reactants.size == 0 && @starting_materials.size != 0) ? 1 : @reactants.size
number_of_starting_materials = @starting_materials.size
number_of_products = @products.size
......@@ -16,7 +16,7 @@ module SVG
@word_size = is_report ? 4 + (number_of_reactants + number_of_starting_materials + number_of_products) : 8
@arrow_width = number_of_reactants * 50 + 60
width = (@starting_materials.size + @products.size) * 100 + @arrow_width
@solvents = options[:solvents]
@solvents = options[:solvents] || []
@temperature = options[:temperature]
@arrow_y_shift = @solvents.count > 3 ? (@solvents.count - 3) * 12 : 0
......
......@@ -44,7 +44,7 @@ M END"
let!(:params) {
{
inchistring: "InChI=1S/C8H8/c1-2-5-3(1)7-4(1)6(2)8(5)7/h1-8H",
molecule_svg_file: "TXWRERCHRDBNLG-UHFFFAOYSA-N.svg",
#molecule_svg_file: "TXWRERCHRDBNLG-UHFFFAOYSA-N.svg",
inchikey: "TXWRERCHRDBNLG-UHFFFAOYSA-N",
molecular_weight: 104.14912,
sum_formular: "C8H8",
......@@ -62,7 +62,7 @@ M END"
params.each do |k, v|
expect(m.attributes.symbolize_keys[k]).to eq(v)
end
expect(m.molecule_svg_file).to match(/\w{128}\.svg/)
end
end
......
......@@ -221,7 +221,7 @@ describe Chemotion::SampleAPI do
solvent: '',
impurities: '',
location: '',
molecule: FactoryGirl.create(:molecule),
# molecule: FactoryGirl.create(:molecule),
molfile: '',
is_top_secret: false
}
......
......@@ -3,7 +3,7 @@ require 'rails_helper'
describe Chemotion::UserAPI do
let(:json_options) {
{
only: [:id,:is_templates_moderator],
only: [:id,:is_templates_moderator,:type],
methods: [:name, :initials]
}
}
......
require 'rails_helper'
RSpec.describe PagesController do
#login_user
let(:user) { create(:person) }
let (:group) {create(:group,users: [user])}
let (:g1) {create(:group)}
let (:g2) {create(:group)}
let(:json_options) {
{
only: [:id],
methods: [:name, :initials]
}
}
before do
#allow_any_instance_of(WardenAuthentication).to receive(:current_user).and_return(user)
allow(request.env['warden']).to receive(:authenticate!).and_return(user)
allow(controller).to receive(:current_user).and_return(user)
sign__in(user)
end
describe "GET groups" do
it "assigns @groups" do
g1.users << user
g1.save
g2.admins << user
g2.save
get :groups
expect(assigns(:groups)).to match_array([group])
groups=assigns(:groups).map{|g| g.select{|k| k.match(/id|name|initials/)}}
expect(groups).to match_array([g1.as_json(json_options),g2.as_json(json_options)])
end
it "renders the groups template" do
......
require 'rails_helper'
feature 'Pages' do
let(:john) { create(:user) }
let(:john) { create(:person) }
background do
sign_in(john)
......
......@@ -88,10 +88,27 @@ M END
MOLFILE
}
let(:sample) { build(:sample, molfile: molfile) }
let(:mol_attributes){
{
"boiling_point" => nil,
"density" => nil,
"inchikey" => "XLYOFNOQVPJJNP-UHFFFAOYSA-N",
"inchistring" => "InChI=1S/H2O/h1H2",
"iupac_name" => "oxidane",
"melting_point" => nil,
"molecular_weight" => 18.01528,
# "molecule_svg_file" => "XLYOFNOQVPJJNP-UHFFFAOYSA-N.svg", #todo
"molfile" => molfile.rstrip,
"names" => ["water", "oxidane"],
"sum_formular" => "H2O"
}
}
before do
sample.collections << FactoryGirl.build(:collection)
sample.creator = FactoryGirl.build(:person)
end
it 'should create a molecule' do
sample.save!
molecule = sample.molecule
......@@ -101,20 +118,11 @@ MOLFILE
it 'should retrieve molecule information' do
sample.save
molecule = sample.molecule
mol_attributes.each do |k, v|
expect(molecule.attributes[k]).to eq(v)
end
expect(molecule.attributes).to include(
"boiling_point" => nil,
"density" => nil,
"inchikey" => "XLYOFNOQVPJJNP-UHFFFAOYSA-N",
"inchistring" => "InChI=1S/H2O/h1H2",
"iupac_name" => "oxidane",
"melting_point" => nil,
"molecular_weight" => 18.01528,
# "molecule_svg_file" => "XLYOFNOQVPJJNP-UHFFFAOYSA-N.svg", #todo
"molfile" => molfile,
"names" => ["water", "oxidane"],
"sum_formular" => "H2O",
)
end
##Fixme : now file are anonymised
......
......@@ -2,20 +2,35 @@ require 'rails_helper'
RSpec.describe SVG::ReactionComposer do
# let(:composer) {
# SVG::ReactionComposer.new({
# starting_materials: ["AFABGHUZZDYHJO-UHFFFAOYSA-N", "KIWAUQFHKHLABA-AATRIKPKSA-N", "XLYOFNOQVPJJNP-UHFFFAOYSA-N"],
# reactants: ["AFABGHUZZDYHJO-UHFFFAOYSA-N", "KIWAUQFHKHLABA-AATRIKPKSA-N", "XLYOFNOQVPJJNP-UHFFFAOYSA-N"],
# products: ["AFABGHUZZDYHJO-UHFFFAOYSA-N", "KIWAUQFHKHLABA-AATRIKPKSA-N", "XLYOFNOQVPJJNP-UHFFFAOYSA-N"]
# })
# }
let(:composer) {
SVG::ReactionComposer.new({
starting_materials: ["AFABGHUZZDYHJO-UHFFFAOYSA-N", "KIWAUQFHKHLABA-AATRIKPKSA-N", "XLYOFNOQVPJJNP-UHFFFAOYSA-N"],
reactants: ["AFABGHUZZDYHJO-UHFFFAOYSA-N", "KIWAUQFHKHLABA-AATRIKPKSA-N", "XLYOFNOQVPJJNP-UHFFFAOYSA-N"],
products: ["AFABGHUZZDYHJO-UHFFFAOYSA-N", "KIWAUQFHKHLABA-AATRIKPKSA-N", "XLYOFNOQVPJJNP-UHFFFAOYSA-N"]
})
SVG::ReactionComposer.new(
{
materials_svg_paths: {
starting_materials: ["no_image_180.svg"],
reactants: ["no_image_180.svg"],
products: ["no_image_180.svg"],
}
},
{
solvents: [],
temperature: '',
is_report: false
}
)
}
describe 'composing the SVG' do
let(:svg) { composer.compose_reaction_svg }
let(:expected_svg) {
"<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:cml=\"http://www.xml-cml.org/schema\"\n width=\"1620px\" height=\"200px\" viewBox=\"0 0 810 100\">\n <title>Reaction 1</title><g transform='translate(0, 0) scale(1)'><svg width=\"100\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 263.923 214.641\" font-family=\"sans-serif\" stroke=\"rgb(0,0,0)\" stroke-width=\"2\" stroke-linecap=\"round\">\n<line x1=\"80.0\" y1=\"120.0\" x2=\"80.0\" y2=\"93.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"80.0\" y1=\"120.0\" x2=\"66.5\" y2=\"143.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"80.0\" y1=\"120.0\" x2=\"53.0\" y2=\"120.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"80.0\" y1=\"120.0\" x2=\"114.6\" y2=\"140.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"85.9\" y2=\"93.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"109.3\" y2=\"107.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"95.8\" y2=\"56.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"149.3\" y2=\"80.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"114.6\" y1=\"140.0\" x2=\"128.1\" y2=\"163.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"114.6\" y1=\"140.0\" x2=\"101.1\" y2=\"163.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"114.6\" y1=\"140.0\" x2=\"149.3\" y2=\"120.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"120.0\" x2=\"176.3\" y2=\"120.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"120.0\" x2=\"149.3\" y2=\"80.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"120.0\" x2=\"162.8\" y2=\"143.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"80.0\" x2=\"149.3\" y2=\"53.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"80.0\" x2=\"189.3\" y2=\"80.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"189.3\" y1=\"80.0\" x2=\"212.7\" y2=\"66.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"189.3\" y1=\"80.0\" x2=\"189.3\" y2=\"53.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"189.3\" y1=\"80.0\" x2=\"202.8\" y2=\"103.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<text x=\"74.000000\" y=\"88.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"54.000000\" y=\"162.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"34.000000\" y=\"128.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"68.641016\" y=\"108.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"103.282032\" y=\"128.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"83.282032\" y=\"53.358984\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"128.641016\" y=\"182.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"88.641016\" y=\"182.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"183.282032\" y=\"128.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"143.282032\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"217.923048\" y=\"68.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"183.282032\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"203.282032\" y=\"122.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"163.282032\" y=\"162.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n</svg></g><g transform='translate(100, 0) scale(1)'><svg width=\"100\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 173.637 336.084\" font-family=\"sans-serif\" stroke=\"rgb(0,0,0)\" stroke-width=\"2\" stroke-linecap=\"round\">\n<line x1=\"78.5\" y1=\"147.5\" x2=\"100.3\" y2=\"185.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"73.3\" y1=\"150.5\" x2=\"95.1\" y2=\"188.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"75.9\" y1=\"149.0\" x2=\"97.7\" y2=\"106.1\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"75.9\" y1=\"149.0\" x2=\"53.0\" y2=\"148.8\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"97.7\" y1=\"187.1\" x2=\"75.9\" y2=\"230.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"97.7\" y1=\"187.1\" x2=\"120.6\" y2=\"187.3\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"97.7\" y1=\"106.1\" x2=\"115.2\" y2=\"71.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"94.0\" y1=\"104.2\" x2=\"111.4\" y2=\"69.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"101.5\" y1=\"108.0\" x2=\"118.9\" y2=\"73.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"75.9\" y1=\"230.0\" x2=\"58.5\" y2=\"264.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"79.7\" y1=\"231.8\" x2=\"62.2\" y2=\"266.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"72.2\" y1=\"228.1\" x2=\"54.7\" y2=\"262.7\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"115.2\" y1=\"71.5\" x2=\"125.2\" y2=\"51.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"58.5\" y1=\"264.6\" x2=\"48.5\" y2=\"284.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<text x=\"34.000000\" y=\"156.615741\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"127.637227\" y=\"195.468538\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"125.022771\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"36.614456\" y=\"304.084280\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n</svg></g><g transform='translate(100, 0) scale(1)'> <svg font-family=\"sans-serif\" font-size=\"14\">\n <text x=\"0\" y=\"50\">+</text>\n </svg>\n</g><g transform='translate(200, 0) scale(1)'><svg width=\"100\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 149.282 100\" font-family=\"sans-serif\" stroke=\"rgb(0,0,0)\" stroke-width=\"2\" stroke-linecap=\"round\">\n<line x1=\"85.9\" y1=\"53.5\" x2=\"98.0\" y2=\"46.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"63.4\" y1=\"53.5\" x2=\"51.3\" y2=\"46.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<text x=\"68.641016\" y=\"68.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">O</text>\n<text x=\"103.282032\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"34.000000\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n</svg></g><g transform='translate(200, 0) scale(1)'> <svg font-family=\"sans-serif\" font-size=\"14\">\n <text x=\"0\" y=\"50\">+</text>\n </svg>\n</g><g transform='translate(330, 0) scale(0.5)'><svg width=\"100\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 263.923 214.641\" font-family=\"sans-serif\" stroke=\"rgb(0,0,0)\" stroke-width=\"2\" stroke-linecap=\"round\">\n<line x1=\"80.0\" y1=\"120.0\" x2=\"80.0\" y2=\"93.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"80.0\" y1=\"120.0\" x2=\"66.5\" y2=\"143.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"80.0\" y1=\"120.0\" x2=\"53.0\" y2=\"120.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"80.0\" y1=\"120.0\" x2=\"114.6\" y2=\"140.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"85.9\" y2=\"93.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"109.3\" y2=\"107.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"95.8\" y2=\"56.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"149.3\" y2=\"80.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"114.6\" y1=\"140.0\" x2=\"128.1\" y2=\"163.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"114.6\" y1=\"140.0\" x2=\"101.1\" y2=\"163.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"114.6\" y1=\"140.0\" x2=\"149.3\" y2=\"120.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"120.0\" x2=\"176.3\" y2=\"120.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"120.0\" x2=\"149.3\" y2=\"80.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"120.0\" x2=\"162.8\" y2=\"143.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"80.0\" x2=\"149.3\" y2=\"53.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"80.0\" x2=\"189.3\" y2=\"80.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"189.3\" y1=\"80.0\" x2=\"212.7\" y2=\"66.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"189.3\" y1=\"80.0\" x2=\"189.3\" y2=\"53.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"189.3\" y1=\"80.0\" x2=\"202.8\" y2=\"103.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<text x=\"74.000000\" y=\"88.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"54.000000\" y=\"162.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"34.000000\" y=\"128.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"68.641016\" y=\"108.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"103.282032\" y=\"128.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"83.282032\" y=\"53.358984\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"128.641016\" y=\"182.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"88.641016\" y=\"182.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"183.282032\" y=\"128.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"143.282032\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"217.923048\" y=\"68.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"183.282032\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"203.282032\" y=\"122.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"163.282032\" y=\"162.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n</svg></g><g transform='translate(380, 0) scale(0.5)'><svg width=\"100\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 173.637 336.084\" font-family=\"sans-serif\" stroke=\"rgb(0,0,0)\" stroke-width=\"2\" stroke-linecap=\"round\">\n<line x1=\"78.5\" y1=\"147.5\" x2=\"100.3\" y2=\"185.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"73.3\" y1=\"150.5\" x2=\"95.1\" y2=\"188.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"75.9\" y1=\"149.0\" x2=\"97.7\" y2=\"106.1\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"75.9\" y1=\"149.0\" x2=\"53.0\" y2=\"148.8\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"97.7\" y1=\"187.1\" x2=\"75.9\" y2=\"230.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"97.7\" y1=\"187.1\" x2=\"120.6\" y2=\"187.3\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"97.7\" y1=\"106.1\" x2=\"115.2\" y2=\"71.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"94.0\" y1=\"104.2\" x2=\"111.4\" y2=\"69.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"101.5\" y1=\"108.0\" x2=\"118.9\" y2=\"73.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"75.9\" y1=\"230.0\" x2=\"58.5\" y2=\"264.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"79.7\" y1=\"231.8\" x2=\"62.2\" y2=\"266.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"72.2\" y1=\"228.1\" x2=\"54.7\" y2=\"262.7\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"115.2\" y1=\"71.5\" x2=\"125.2\" y2=\"51.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"58.5\" y1=\"264.6\" x2=\"48.5\" y2=\"284.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<text x=\"34.000000\" y=\"156.615741\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"127.637227\" y=\"195.468538\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"125.022771\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"36.614456\" y=\"304.084280\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n</svg></g><g transform='translate(380, 0) scale(0.5)'> <svg font-family=\"sans-serif\" font-size=\"14\">\n <text x=\"0\" y=\"50\">+</text>\n </svg>\n</g><g transform='translate(430, 0) scale(0.5)'><svg width=\"100\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 149.282 100\" font-family=\"sans-serif\" stroke=\"rgb(0,0,0)\" stroke-width=\"2\" stroke-linecap=\"round\">\n<line x1=\"85.9\" y1=\"53.5\" x2=\"98.0\" y2=\"46.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"63.4\" y1=\"53.5\" x2=\"51.3\" y2=\"46.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<text x=\"68.641016\" y=\"68.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">O</text>\n<text x=\"103.282032\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"34.000000\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n</svg></g><g transform='translate(430, 0) scale(0.5)'> <svg font-family=\"sans-serif\" font-size=\"14\">\n <text x=\"0\" y=\"50\">+</text>\n </svg>\n</g><g transform='translate(300, 0)'> <svg stroke=\"black\" stroke-width=\"1\">\n <line x1=\"0\" y1=\"50\" x2=\"210\" y2=\"50\"/>\n <polygon points=\"202,50 200,47 210,50 200,53\"/>\n </svg>\n</g><g transform='translate(300, 0)'> <svg font-family=\"sans-serif\" font-size=\"8\">\n <text text-anchor=\"middle\" x=\"105\" y=\"65\"></text>\n </svg>\n</g><g transform='translate(510, 0) scale(1)'><svg width=\"100\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 263.923 214.641\" font-family=\"sans-serif\" stroke=\"rgb(0,0,0)\" stroke-width=\"2\" stroke-linecap=\"round\">\n<line x1=\"80.0\" y1=\"120.0\" x2=\"80.0\" y2=\"93.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"80.0\" y1=\"120.0\" x2=\"66.5\" y2=\"143.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"80.0\" y1=\"120.0\" x2=\"53.0\" y2=\"120.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"80.0\" y1=\"120.0\" x2=\"114.6\" y2=\"140.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"85.9\" y2=\"93.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"109.3\" y2=\"107.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"95.8\" y2=\"56.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"109.3\" y1=\"80.0\" x2=\"149.3\" y2=\"80.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"114.6\" y1=\"140.0\" x2=\"128.1\" y2=\"163.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"114.6\" y1=\"140.0\" x2=\"101.1\" y2=\"163.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"114.6\" y1=\"140.0\" x2=\"149.3\" y2=\"120.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"120.0\" x2=\"176.3\" y2=\"120.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"120.0\" x2=\"149.3\" y2=\"80.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"120.0\" x2=\"162.8\" y2=\"143.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"80.0\" x2=\"149.3\" y2=\"53.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"149.3\" y1=\"80.0\" x2=\"189.3\" y2=\"80.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"189.3\" y1=\"80.0\" x2=\"212.7\" y2=\"66.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"189.3\" y1=\"80.0\" x2=\"189.3\" y2=\"53.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"189.3\" y1=\"80.0\" x2=\"202.8\" y2=\"103.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<text x=\"74.000000\" y=\"88.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"54.000000\" y=\"162.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"34.000000\" y=\"128.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"68.641016\" y=\"108.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"103.282032\" y=\"128.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"83.282032\" y=\"53.358984\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"128.641016\" y=\"182.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"88.641016\" y=\"182.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"183.282032\" y=\"128.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"143.282032\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"217.923048\" y=\"68.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"183.282032\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"203.282032\" y=\"122.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"163.282032\" y=\"162.641016\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n</svg></g><g transform='translate(610, 0) scale(1)'><svg width=\"100\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 173.637 336.084\" font-family=\"sans-serif\" stroke=\"rgb(0,0,0)\" stroke-width=\"2\" stroke-linecap=\"round\">\n<line x1=\"78.5\" y1=\"147.5\" x2=\"100.3\" y2=\"185.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"73.3\" y1=\"150.5\" x2=\"95.1\" y2=\"188.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"75.9\" y1=\"149.0\" x2=\"97.7\" y2=\"106.1\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"75.9\" y1=\"149.0\" x2=\"53.0\" y2=\"148.8\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"97.7\" y1=\"187.1\" x2=\"75.9\" y2=\"230.0\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"97.7\" y1=\"187.1\" x2=\"120.6\" y2=\"187.3\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"97.7\" y1=\"106.1\" x2=\"115.2\" y2=\"71.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"94.0\" y1=\"104.2\" x2=\"111.4\" y2=\"69.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"101.5\" y1=\"108.0\" x2=\"118.9\" y2=\"73.4\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"75.9\" y1=\"230.0\" x2=\"58.5\" y2=\"264.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"79.7\" y1=\"231.8\" x2=\"62.2\" y2=\"266.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"72.2\" y1=\"228.1\" x2=\"54.7\" y2=\"262.7\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"115.2\" y1=\"71.5\" x2=\"125.2\" y2=\"51.6\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"58.5\" y1=\"264.6\" x2=\"48.5\" y2=\"284.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<text x=\"34.000000\" y=\"156.615741\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"127.637227\" y=\"195.468538\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"125.022771\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"36.614456\" y=\"304.084280\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n</svg></g><g transform='translate(610, 0) scale(1)'> <svg font-family=\"sans-serif\" font-size=\"14\">\n <text x=\"0\" y=\"50\">+</text>\n </svg>\n</g><g transform='translate(710, 0) scale(1)'><svg width=\"100\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 149.282 100\" font-family=\"sans-serif\" stroke=\"rgb(0,0,0)\" stroke-width=\"2\" stroke-linecap=\"round\">\n<line x1=\"85.9\" y1=\"53.5\" x2=\"98.0\" y2=\"46.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<line x1=\"63.4\" y1=\"53.5\" x2=\"51.3\" y2=\"46.5\" stroke=\"rgb(0,0,0)\" stroke-width=\"2.0\"/>\n<text x=\"68.641016\" y=\"68.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">O</text>\n<text x=\"103.282032\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n<text x=\"34.000000\" y=\"48.000000\" fill=\"rgb(0,0,0)\" stroke=\"rgb(0,0,0)\" stroke-width=\"1\" font-size=\"16\">H</text>\n</svg></g><g transform='translate(710, 0) scale(1)'> <svg font-family=\"sans-serif\" font-size=\"14\">\n <text x=\"0\" y=\"50\">+</text>\n </svg>\n</g></svg>"
}
"<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:cml=\"http://www.xml-cml.org/schema\"\n width=\"12in\" height=\"3.33in\" viewBox=\"0 0 60 110\">\n <title>Reaction 1</title><g transform='translate(0, 0)'> <svg stroke=\"black\" stroke-width=\"1\">\n <line x1=\"0\" y1=\"50\" x2=\"60\" y2=\"50\" stroke=\"black\"/>\n <polygon points=\"52,50 50,47 60,50 50,53\"/>\n </svg>\n</g><g transform='translate(0, 0)'></g><g transform='translate(0, 0)'> <svg font-family=\"sans-serif\">\n <text text-anchor=\"middle\" x=\"30\" y=\"65\" font-size=\"9\"></text>\n </svg>\n</g></svg>"
}
it 'should generate a svg' do
expect(svg).to eq(expected_svg)
......
......@@ -3,6 +3,8 @@ ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'devise'
# Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in
......@@ -26,8 +28,9 @@ RSpec.configure do |config|
config.infer_spec_type_from_file_location!
config.include Devise::TestHelpers, type: :controller
config.extend ControllerMacros, type: :controller
#config.include Devise::TestHelpers, type: :controller
#config.extend ControllerMacros, type: :controller
config.include ControllerHelpers, type: :controller
config.include LoginMacros
end
module ControllerHelpers
def sign__in(user = FactoryGirl.create(:person))
if user.nil?
allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user})
allow(controller).to receive(:current_user).and_return(nil)
else
allow(request.env['warden']).to receive(:authenticate!).and_return(user)
allow(controller).to receive(:current_user).and_return(user)
end
end
end
module ControllerMacros
def login_admin
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:admin]
sign_in FactoryGirl.create(:admin) # Using factory girl as an example
end
end
def login_user
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:user]
user = FactoryGirl.create(:user)
user.confirm! # or set a confirmed_at inside the factory. Only necessary if you are using the "confirmable" module
user = FactoryGirl.create(:person)
#user.confirm! # or set a confirmed_at inside the factory. Only necessary if you are using the "confirmable" module
sign_in user
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment