rspec

RSpec: Cant Verify there are more than 5 Btns on Search Result Page

人盡茶涼 提交于 2020-01-16 18:04:49
问题 I try to do an Selenium-Acceptancetest 'Search Result List' with RSpec spec And my Issue is It should verify the count of a Button "Detail" I would be happy to get help for start thinking as a coder; i am a manual tester stil. My Problem now is: Method Error Failure/Error: expect(@driver.find_element(:xpath, "//a[contains(text(),'Details')]").to be > 4) NoMethodError: undefined method `to' for #<Selenium::WebDriver::Element:0x00000003fd4938> Sources: On my way to resolve the issue I tried to

Mock TCPSocket in Rspec

余生长醉 提交于 2020-01-16 06:10:31
问题 I have a simple method which connects to a TCP server and puts single line of string and closes the connection. After the connection is closed the method redirects to a particular page. I am in interested in testing the redirection of that method and do not care about the TCP connection values. Thus, my best option to get around is to mock the connection. Here is the method, def print server = TCPSocket.new('a.b.c.d', 56423) server.puts "Hello Everyone" server.close redirect_to root_url end

Mock TCPSocket in Rspec

你说的曾经没有我的故事 提交于 2020-01-16 06:09:26
问题 I have a simple method which connects to a TCP server and puts single line of string and closes the connection. After the connection is closed the method redirects to a particular page. I am in interested in testing the redirection of that method and do not care about the TCP connection values. Thus, my best option to get around is to mock the connection. Here is the method, def print server = TCPSocket.new('a.b.c.d', 56423) server.puts "Hello Everyone" server.close redirect_to root_url end

Rspec have_field raises an error while have_selector return success

血红的双手。 提交于 2020-01-15 23:35:24
问题 In the example below 3 have_field specs fail, while 2 have_selector pass. describe "without js support", js: false do subject { page } it { should have_selector "form label[for='user_password']", text: "Password" } it { should have_selector "form input#user_password[name='user[password]'][type='password'][required]" } it { should have_field "user_password" } # check by field id it { should have_field "user[password]" } # check by field name it { should have_field "Password" } # check by field

cabybara-webkit + rspec: Records are not available

微笑、不失礼 提交于 2020-01-15 11:19:09
问题 I'm new to the integration testing, although I've done a lot of unit tests for my models and controllers. But now I want to test the whole stack. (I don't want to use Cucumber, since there is no customer and I can read code) Here my (simplified) spec describe ArticlesController, "#show" do before do @article = Factory :article, :title => "Lorem ipsum" end it "should show the article page" do visit article_path(:id => @article) page.should have_content("Lorem ipsum") end end The spec passes,

Capybara::ElementNotFound on all specs only on Travis

浪尽此生 提交于 2020-01-15 08:15:35
问题 I'm using selenium, capybara with rspec for testing, i noticed all tests pass locally, but on travis all tests fail with this error on each spec. Capybara::ElementNotFound: I'm not sure what is wrong here, here is the specs runner on .travis.yml script: - xvfb-run bundle exec rspec spec/features/*.rb for spec_helper.rb here is my config: RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.use_transactional_fixtures = false config.infer_base_class

How can I determine the subject of an rspec controller test?

房东的猫 提交于 2020-01-15 04:51:11
问题 So I don't have a great reason for needing to know this other than curiosity - the BEST reason - but I'm not sure what's going on here. Background: I'm working through the RSpec book and updating the examples. On Chapter 24 - Rails Controllers there's a test for a messages controller. ## spec/controllers/messages_controller_spec.rb ## require 'spec_helper' describe MessagesController do describe "POST create" do let(:message) { mock_model(Message).as_null_object } before do Message.stub(:new)

Rspec/mocks raises uninitialized constant BasicObject::RSpec

橙三吉。 提交于 2020-01-15 03:28:09
问题 I just installed rspec and rspec-mocks but I am not able to run the simplest setup irb(main):001:0> require 'rspec' => true irb(main):004:0> require 'rspec/mocks' => false irb(main):006:0> RSpec::Mocks::setup(Object.new) NameError: uninitialized constant BasicObject::RSpec from /usr/local/Cellar/ruby/1.9.1-p376/lib/ruby/gems/1.9.1/gems/rspec-mocks-2.13.0/lib/rspec/mocks.rb:60:in `block in add_extensions' from /usr/local/Cellar/ruby/1.9.1-p376/lib/ruby/gems/1.9.1/gems/rspec-mocks-2.13.0/lib

RSpec - Uninitialized variable outside of tests

旧巷老猫 提交于 2020-01-15 02:45:30
问题 Sorry, I don't know how to word the title better, but here is a general idea of my test: describe Model do let(:model) { FactoryGirl.create(:model) } subject { model } it { should be_valid } model.array_attribute.each do |attribute| context "description" do specify { attribute.should == 1 } end end end The problem is that at the line model.array_attribute.each do |attribute| , I get an error of undefined local variable or method model . I know that the let(:model) is working because the

RSpec - Uninitialized variable outside of tests

我的未来我决定 提交于 2020-01-15 02:45:07
问题 Sorry, I don't know how to word the title better, but here is a general idea of my test: describe Model do let(:model) { FactoryGirl.create(:model) } subject { model } it { should be_valid } model.array_attribute.each do |attribute| context "description" do specify { attribute.should == 1 } end end end The problem is that at the line model.array_attribute.each do |attribute| , I get an error of undefined local variable or method model . I know that the let(:model) is working because the