Rspec Elements basic definitions

Rspec:-
describe:- describe the behaviour of a class
it:- tests are written using the it block
before and after has two arguments
all:- the setup will be done once before all of the tests in the block.
each:- the setup wil be done before each individual test.
before:-only before tests are started.
after:-only after tests are completed
RSpec Idioms:-
We usually use the describe keyword to describe methods. Using a “.” will signify that you’re testing a class method, and using “#” will signify that it’s an instance method.
describe MyClass do
describe “.class_method_1” do
end
describe “#instance_method_1” do
end
end

Advertisements

cannot load such file — mysql/mysql_api (LoadError)

When running rspec ruby file ( require “mysql” ), sometimes you will get error due mysql missing file like ‘:cannot load such file — mysql/mysql_api (LoadError)
Error like:-
c:\Ruby193\bin>rspec –format html –out test.html E:\Selva-Backup\doc\SAMPLE\test.rb
c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’:cannot load such file — mysql/mysql_api (LoadError)
from c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.9.1-x86-mingw32/lib/mysql.rb:6:in `rescue in <top (required)>’

Solution:-
1. Download the mysql-connector
cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip
2.unzip the zipped file
copy the file C:\Users\admin\Downloads\mysql-connector-c-noinstall-6.0.2-win32\mysql-connector-c-noinstall-6.0.2-win32\lib\libmysql.dll in to C:\Ruby193\bin\ paste inside the bin folder.
3. Now it will work fine.