logo
down
shadow

When to switch from cucumber to rspec in the BDD cycle for a login procedure


When to switch from cucumber to rspec in the BDD cycle for a login procedure

Content Index :

When to switch from cucumber to rspec in the BDD cycle for a login procedure
Tag : ruby-on-rails , By : dormsbee
Date : November 26 2020, 01:01 AM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How do I fake OpenID login in RSpec user story/Cucumber when using open_id_authentication plugin


Tag : ruby-on-rails , By : Hans-Inge
Date : March 29 2020, 07:55 AM
Hope that helps I've figured out a way, if you place this in your features/support/env.rb:
ActionController::Base.class_eval do
  private

  def begin_open_id_authentication(identity_url, options = {})
    yield OpenIdAuthentication::Result.new(:successful), identity_url, nil
  end 
end
Given /^I am logged in as "(.*)"$/ do |name|
  user = User.find_by_name(user)
  post '/session', :openid_url => user.identity_url
  # Some assertions just to make sure our hack in env.rb is still working
  response.should redirect_to('/')
  flash[:notice].should eql('Logged in successfully')
end

RSpec vs Cucumber (RSpec stories)


Tag : unit-testing , By : suresh
Date : March 29 2020, 07:55 AM
To fix this issue If you haven't already, you might want to check out Dan North's excellent article, What's in a Story? as a starting point.
We have two main uses for Cucumber stories. First, because the story form is very specific it helps focus the product owner's articulation of the features he wants built. This is the "token for a conversation" use of stories, and would be valuable whether or not we implemented the stories in code. Second, when the process is working well enough that we have complete stories before we begin writing the feature (more of an ideal that we strive for than a daily reality), you have your acceptance criteria spelled out clearly and you know exactly what and how much to build.

Is there an equivalent in RSpec to Cucumber's "Scenarios" or am I using RSpec the wrong way?


Tag : ruby-on-rails , By : Moe Skeeto
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I'm impressed at the brevity and usefulness of Cucumber's Scenarios, they're a great way to test a load of different cases. , Try the following approach. I like the way it turned out.
describe StateDateMethods do
  before :each do
    @product = OpenStruct.new
    @product.extend StateDateMethods
  end

  def parse_date(unparsed_date_value)
    unless unparsed_date_value.nil?
      DateTime.strptime(unparsed_date_value, '%m/%d/%Y')
    end
  end

  context '#pre_order?' do
    examples = [
      # [visible_on, pre_order_on, for_sale_on] => method_result
      { :inputs => [nil, nil, nil], :expected => false },
      { :inputs => ['1/1/2001', nil, nil], :expected => false },
      { :inputs => ['1/1/2001', '1/1/2001', nil], :expected => true },
      { :inputs => ['1/1/2001', '1/2/2001', nil], :expected => true },
      { :inputs => ['1/1/2001', '1/1/2001', '1/2/2001'], :expected => false },
      { :inputs => ['1/1/2001', '1/1/2001', '1/1/3001'], :expected => true },
      { :inputs => ['1/1/2001', '1/1/3001', '1/2/3001'], :expected => false },
      { :inputs => ['1/1/3001', '1/1/3001', '1/2/3001'], :expected => false },
      { :inputs => ['1/1/2001', nil, '1/1/2001'], :expected => false },
      { :inputs => ['1/1/2001', nil, '1/1/3001'], :expected => false }
    ]
    examples.each do |example|
      inputs = example[:inputs]

      it "should return #{example[:expected].inspect} when visible_on == #{inputs[0].inspect}, pre_order_on == #{inputs[1].inspect}, for_sale_on == #{inputs[2].inspect}" do
        @product.visible_on = parse_date(inputs[0])
        @product.pre_order_on = parse_date(inputs[1])
        @product.for_sale_on = parse_date(inputs[2])

        @product.pre_order?.should == example[:expected]
      end
    end
  end
end
....F.....

Failures:

  1) StateDateMethods#pre_order? should return false when visible_on == "1/1/2001", pre_order_on == "1/1/2001", for_sale_on == "1/2/2001"
     Failure/Error: @product.pre_order?.should == example[:expected]
       expected: false
            got: true (using ==)
     # ./spec_no_rails/state_date_methods_spec.rb:40:in `block (4 levels) in <top (required)>'

Finished in 0.38933 seconds
10 examples, 1 failure

Failed examples:

rspec ./spec_no_rails/state_date_methods_spec.rb:35 # StateDateMethods#pre_order? should return false when visible_on == "1/1/2001", pre_order_on == "1/1/2001", for_sale_on == "1/2/2001"
..........

Finished in 0.3889 seconds
10 examples, 0 failures

no such file to load -- rspec/matchers - rspec-rails, shoulda, cucumber, factory girl, Rails2.3.10


Tag : ruby-on-rails , By : mansoor
Date : March 29 2020, 07:55 AM
should help you out I ran into this same problem. After hunting down all binary rspec commands (several locations), I belatedly realized that the 1.3.2 branch of RSPEC titles its binary "spec" and not "rspec".
So the correct commands was always "bundle exec spec spec/models/..." Putting "rspec" meant that bundler failed to find it in my current rvm/gemset and went searching through my entire path, eventually coming up with an /opt/local/bin copy that belonged to an rspec2.x install.

Why does guard start spork both for rspec and cucumber even if I wanted to start it only for rspec using groups?


Tag : development , By : artifex
Date : March 29 2020, 07:55 AM
around this issue You must disable Cucumber in Spork in the RSpec group and the other way around:
specs :specs    
  guard :spork, :cucumber => false do
    # ...
  end
end

specs :features    
  guard 'spork', :rspec => false do
    # ...
  end
end
Related Posts Related QUESTIONS :
  • random ActionController::InvalidAuthenticityToken in my rails app
  • How to determine which controller has been called from ApplicationController?
  • Parameterize an ActiveRecord #joins method
  • Why the redis returning more values instead of count?
  • Is this ruby(rails) code readable simply?
  • Can I see what SQL an ActiveRecord .save call would generate, without doing the save?
  • Time.current.tap{|t| t.change hour: 10 } is not working in Rails 4.2
  • Write active decorator DRY
  • Creating 2 Models in Controller Action With Transaction - Rails 4
  • How do I display the text with all of the tabs and new lines (\t and \n) in Ruby on Rails?
  • Why my Module is not being loaded in Rails?
  • how to retrieve data from the database using the has_many association
  • Out of ranger error, Type::Integer during rspec test
  • Generate a video from many images using RMagick in RoR
  • Calling an overriden scope from an included concern in the overriding scope
  • ActionController::UnknownFormat on Bugsnag
  • How do I pass a person object into a related Post model object
  • rubocop cannot load such file -- rubocop-rails
  • Malicious Bots waking up heroku free app and using up all dyno hours
  • How to do RSpec of validators?
  • Is there a way to wrap the response of all controller methods in a json object in application_controller.rb?
  • Need to implement #cache! if you want to use Cloudinary::CarrierWave::Storage as a cache storage
  • How to integrate custom bootstrap theme in activeadmin
  • How can I load an STI record using just the base STI class?
  • Getting the .each loop result with the lowest number from json
  • When and where to aggregate or perform calculations on data in RESTful Rails API
  • How do you write a conditional ternary operator inline in Ruby on Rails?
  • Why put require statement at the end of a ruby file?
  • In Rails, is it possible to display an alert without calling redirect_to or render?
  • Convert hash of hash in array of hash
  • Rails 5 tries to save the empty string as nil
  • websocket-driver was not found on deploy
  • Dangerous query method deprecation warning on Rails 5.2.3
  • Using ERB in Markdown with Redcarpet
  • How to create list of unique array items from thousands of records in Rails?
  • Undefined method 'suspend_paypal' for User
  • Any good methods to find Ruby on Rails memory leak?
  • Why does if __FILE__ == $0 not work on Heroku with Rails 5.2?
  • Rails: How to implement login and authentication where i have five different user models in rails?
  • What is the impact of changing rails secret_key_base on production?
  • how to keep heroku dyno worker alive if web dyno goes to sleep?
  • syntax error, unexpected end-of-input, expecting keyword_end. when running rspec of feature file
  • How does form_with know which method to call inside a model?
  • When using activestorage in Rails 6, how do I retain a file when redisplaying a form?
  • How to override table column value with column value from second table if it exist?
  • Comparison of !! operator vs present?
  • Error parsing Gemfile when pushing to Heroku
  • Rails 5: How to save uniq element in Array of Hash get from API's response
  • Devise: Unable to redirect to current user edit profile after sign_up
  • How to fix "fatal :unable to look up https (port 9418) (No such host is known)
  • How do I create a self-referential association table rails migration
  • How to send a variable from an action without using the URL in Rails?
  • How to use Ruby on Rails functions within plain (non ROR) Ruby file
  • Rails 6 and Google Maps for Rails
  • Ruby .map hash values to key value pair in array
  • Rails Frontend, Backend, and API
  • How to make value attribute in the select option tag to have url's in rails
  • Can I apply methods to a model.where condition to get all object created in specific month?
  • With Capybara, how do you get assertions on transient elements to work?
  • Best way to combine results of two select statements without returning an array?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com