Skip to content

Instantly share code, notes, and snippets.

@danielmoralesp
Last active July 5, 2021 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielmoralesp/e804fe2c391420282ee5f14f2c49e393 to your computer and use it in GitHub Desktop.
Save danielmoralesp/e804fe2c391420282ee5f14f2c49e393 to your computer and use it in GitHub Desktop.
RSpec & Cucumber
## instalation
$ rvm use 2.7.1
$ gem install rspec --version 3.10.0
$ rspec --help
$ gem install cucumber --version 6.0.0
$ cucumber --help
## Hello RSpec
/greeter_scpec.rb
class RSpecGreeter
def greet
"Hello Rspec!"
end
end
describe "Rspec Greeter" do
it "should say 'Hello Rspec!' when it receives the greet() message" do
greeter = RSpecGreeter.new # Given
greeting = greeter.greet # When
greeting.should == "Hello Rspec!" #Then
end
end
$ rspec greeter_spec.rb
Finished in 0.00393 seconds (files took 0.08857 seconds to load)
1 example, 0 failures
######################################### RSpec and Cucumber with Rails 6
rails --version
## rails 6.0
## Gemfile
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
## RSpec
## Testing libraries
gem 'rspec-rails', '~> 5.0.0'
gem 'cucumber-rails', require: false
gem 'database_cleaner'
gem 'webrat', '~> 0.7.3'
end
$ bundle install
$ rails g rspec:install
$ rails g cucumber:install
## To make sure everything is wired up correctly, run these commands:
$ rails db:migrate
$ rails db:test:prepare
$ rails spec
$ rails cucumber
## running first escenarios
$ touch features/step_definitions/name_descriptions.feature
Feature:
So that I can find jobs that fit my skills
As a job seeker
I want to see accurate and conscince job offers
@wip
Scenario: Show job offers for all candidates
Given a job
When I see a good opportunity for me
Then the click redirects me to a page to join the job
$ rails cucumber:wip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment