Posts

Showing posts with the label Testing

cucumber usage in rails project

Add below gems to your gem file $ gem'database_cleaner' $gem'cucumber-rails' $gem'cucumber' $gem'rspec-rails' Then run bundle install from your root directory. run rake db:migrate next run the below command in your project rails g cucumber:install --capybara $ above command will generate all necessary files run the below command to write cucumber stories to your application. $ touch features/support/your_test_file_name.rb go to the above file and write your application stories run below command to implement test cases for stories $ rake cucumber:wip now we can add the step defination for story in step_defination folder #features/step_definitions/yourcontroller_steps.rb Given /^a regexpress that is "(.*)"$/ do |color| Strawberry.make!(:color => color) end

Rspec Documentation

RSPEC RSpec is a great tool in the behavior driven design process of writing human readable specifications that direct and validate the development of your application. I've found the following practices helpful in writing elegant and maintainable specifications. First #describe What You Are Doing Begin by using #describe for each of the methods you plan on defining, passing the method’s name as the argument. For class method specs prefix a "." to the name, and for instance level specs prefix a "#". This follows standard Ruby documentation practices and will read well when output by the spec runner. describe User do describe '.authenticate' do end describe '.admins' do end describe '#admin?' do end describe '#name' do end end Then Establish The #context Next use #context to explain the different scenarios in which the method could be exe...