Questions tagged [rspec-expectations]

rspec-expectations is a module of the RSpec BDD suite that provides a readable API to express expected test outcomes, usable with other tools such as Cucumber as well as with RSpec.

rspec-expectations is a module of the RSpec BDD suite that provides a readable API to express expected test outcomes, usable with other tools such as Cucumber as well as with RSpec. It is implemented as a Ruby gem.

Instructions for how to use rspec-expectations with Cucumber can be found on Cucumber's Github wiki.

35 questions
1
vote
1 answer

Using rspec-expectations gem to validate arguments in an API

So, let's say I'm writing an API to make delicious frosted cakes. It's all nice and documented, but occasionally an error squeezes through, or maybe the user is exploring the library via IRB and has fat-fingered a variable while they're prototyping…
ALW
  • 1,007
  • 9
  • 13
1
vote
1 answer

How to test before_validation callback model concerns in rspec

I'm learning to write specs for my code and I'm still new to it. Trying to write specs / SharedExamples for my Model concerns, but I don't understand how to write it as I find this one very complicated. If someone could help me or show me how to…
meerkat
  • 361
  • 1
  • 3
  • 11
1
vote
2 answers

Is there an RSpec matcher to test the number of arguments with which a class is instantiated?

Are there any matchers in RSpec to check that a class is instantiated with an argument? Something like it { is_expected.to respond_to(:initialize).with(1).argument } Thanks!
Reiss Johnson
  • 1,419
  • 1
  • 13
  • 19
1
vote
1 answer

Check is option selected in drop down list?

I try to check is selected option realy selected in drop down list (select): expect(page.sltMembers_element.options).to eql('John Doe') But I get an error that expected: 'John Doe' and got: list of all options from drop down list.
1
vote
1 answer

Get the actual value of a boolean attribute

I have the span: Edit Member When I try to get the value of the disabled attribute: page.in_iframe(:id => 'MembersAreaFrame') do |frame| expect(page.span_element(:xpath => "//span[text()='Edit Member']", :frame =>…
Den Silver
  • 199
  • 16
1
vote
1 answer

In rspec what does a test that ends with 'to be' mean?

You can find an example at https://github.com/cloudfoundry/cloud_controller_ng/blob/c63d33c0b1c2298d49a0bad959222b9c3daba16a/spec/unit/controllers/services/service_instances_controller_spec.rb#L1748 : The second test in this block shows…
Eric
  • 2,115
  • 2
  • 20
  • 29
1
vote
1 answer

RSpec expectations check CSS attribute

Could you help me to create a correct RSpec expectation for check CSS attribute? for example I have: And MenuItem has an atribute "background-color: #c0c0c0". I need to check that background-color equals to #c0c0c0. My…
1
vote
1 answer

rspec-expectations-2.13.0/lib/rspec/matchers/method_missing.rb:9:in `method_missing'

I'm running RSpec tests and I got an error message saying: undefined local variable or method `applicant_signup_path'. This is strange because that applicant_signup_path is working elsewhere in the test) When I traced the error it looks like it's…
jyrkim
  • 2,849
  • 1
  • 24
  • 33
1
vote
1 answer

"no such file to load -- rspec/expectations (LoadError)"

My Gemfile currently specifies the following: gem "rspec-expectations", "2.7.0" When I try to run Cucumber, I get the following: no such file to load -- rspec/expectations…
Richie Thomas
  • 3,073
  • 4
  • 32
  • 55
0
votes
1 answer

My rspec test does not pass, I expect my method to receive message expectation n times, but it keeps getting n+1 times

I am writing test for my class, the following test does not pass. I expect my "create_board" method to create 64 squares. when I ran my test, I received the message: Expected: 64 times with any arguments Received: 65 times I tried to replace n…
0
votes
1 answer

RSpec .to be_empty raises ArgumentError "The expect syntax does not support operator matchers"

I'm using Ruby Cucumber to test an app. One of my step definitions does this: Then(/^all of my (\.\S+) should not have the below fields:$/) do |path,table| #path is my api, table is the fields list I'm sending through cucumber feature file and…
Aks..
  • 1,343
  • 1
  • 20
  • 42
0
votes
2 answers

RSpec expectation ignoring message argument

Does anybody understand why the expectation below is ignoring the argument message considering it's being passed as a string? spec.rb context 'flash' do context 'fail' do # Changes the admin_user so it has no permission to delete offence …
vinibol12
  • 468
  • 4
  • 21
0
votes
2 answers

Check elements from array are not visible

I have an array with elements' names: names=['tdColumn1','tdColumn2','tdColumn3'] And I wan't to check that they are not visible: expect(actual).to all(not_be_visible) But be_not_visible, not_visible, not_be_visible, .not_to all(be_visible) are…
Den Silver
  • 199
  • 16
0
votes
1 answer

Make sure that attribute "disabled" equals to "disabled"

I have a span with attribute "disabled" If I try to use next expectation: expect(page.spnApply_element).to have_attributes(:disabled => "disabled") I get an error: expected #
0
votes
2 answers

RSpec Expectations and ExpectationNotMetError

Hello I have been following a course to further my understanding of cucumber. The course is a little old so i have had to update some rspec syntax from should to expect but otherwise have been following it very carefully. I cannot get this recent…
Lilp
  • 961
  • 1
  • 11
  • 31