0

<p>次のコンテンツを含むこのタグがあります。

<p id="post_example"> <%= t (".for_example_type") %> <strong><%= post.title %></strong></p>

私の統合テストでは:

it "should have example post" do
  should have_selector "#post_example", :text => "For example, type #{post.title}"
end

1) Index page should have example post
     Failure/Error: should have_selector "#post_example", :text => "For example, type #{post.title}"
       expected #has_selector?("#post_example", {:text=>"For example, type Post number 10"}) to return true, got false
     # ./spec/requests/posts_spec.rb:26:in `block (3 levels) in <top (required)>'

Finished in 3.8 seconds
6 examples, 1 failure

Failed examples:

rspec ./spec/requests/posts_spec.rb:25 # Index page should have example post


Randomized with seed 5480

:textRubyコードとテキスト/文字列を組み合わせてカピバラに渡すことは可能ですか?

4

2 に答える 2

1

すでにそうです。スタック トレースを確認します。

expected #has_selector?("#post_example", {:text=>"For example, type Post number 10"})

テキストが解釈されました::text=>"For example, type Post number 10"

于 2013-04-30T11:34:15.210 に答える