rspec

    0热度

    1回答

    我是Rails的新手,特别是写测试。当我运行测试时,我不断收到错误undefined method allow和undefined method allow_any_instance_of'。 我检查了Rspec> 3应该接受允许的语法,我的代码中有什么问题? describe "GET #show" do let(:sample_json_list) { "{\"file

    0热度

    1回答

    我希望我的哈希看起来像这两个中的一个: {metadata: {SOME_UNKNOWN_KEY: {transaction_id: 123456}}} {metadata: {transaction_id: 123456}} 如果我在寻找的关键:transaction_id,我明白,我可以使用hash_including期待嵌套关键应该是在一个特定的地方,但我希望能够做到这样的事情,以涵盖

    0热度

    2回答

    现在有一个奇怪的问题与轨道(5.0.5)。我知道渲染和返回正在运行,因为我可以使用binding.pry来介入。它应该返回一个状态码forbidden,但是当我运行我的测试时,它返回状态码204没有内容。 # we already know this user has permission for org_claim_codes#create but we need to check they a

    0热度

    2回答

    当我的it块之一失败时,我想要运行清理步骤。当所有的it块成功时,我不希望运行清理步骤。 RSpec.describe 'my describe' do it 'first it' do logic_that_might_fail end it 'second it' do logic_that_might_fail end

    0热度

    2回答

    如何在RSpec中定义当前范围的主题(改进主题)时访问父范围的主题? 示例代码: describe MyModule.method(:some_method) do context "when called with a String" do let(:string) { "Hey there!" } # I want to refine the subject

    1热度

    1回答

    我的模型有关于其相关模型之一的验证。由于此验证,我的rspec测试模型失败。 describe NewOfferRange do it { is_expected.to validate_presence_of(:new_offer) } it { is_expected.to validate_presence_of(:from) } it { is_expecte

    0热度

    2回答

    我使用Trix Editor在我的表单中使用WISIWIG。我想用RSpec和Capybara进行测试,但trix编辑器会隐藏该字段。 <div class="form-group"> <trix-editor class="formatted_content form-control" placeholder="Description" input="annonce_ad_body_t

    1热度

    3回答

    我在我的rspec测试中遇到了错误天数。后来我发现,问题是用符号代替串 user_response = JSON.parse(response.body, symbilize_names: true) expect(user_response[:email]).to eql(@user.email) 因为user_response[:email]回报nil因为某些原因 但是,当我将其更改为u

    1热度

    1回答

    在我的应用程序中,一个帐户可以有一个拥有者(用户)和多个用户。 在我的测试中我这样做: # account_factory_static.rb FactoryGirl.define do factory :account do name 'demoaccount' association :owner, :factory => :user end end

    1热度

    1回答

    使用像SimpleCov这样的宝石我可以看到我的测试覆盖率为所有我指定的文件的逐行基础。有没有办法在逐个方法的基础上查看测试覆盖率?例如,如果我的测试使用了某种方法,则该方法将被视为“覆盖”。