我有3个rspec选择器失败时,他们都应该成功.我跟随rails-tutorial.org书和他的节目一样正确.
PagesController GET 'home' should have the right title
Failure/Error: response.should have_selector("title", :content => "Ruby on Rails Sample App | Home")
expected following output to contain a <title>Ruby on Rails Sample App | Home</title> tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Ruby on Rails Tutorial Sample App | Home</title>
</head>
Run Code Online (Sandbox Code Playgroud)
与'内容'和'约'完全相同的错误
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<%= csrf_meta_tag %>
</head>
<body>
<%= yield %>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
home.html.erb
<h1>Sample App</h1>
<p>
This is the home page …Run Code Online (Sandbox Code Playgroud) 我对python相对较新,但我认为我有足够的理解,除了(显然)使用"import"语句的正确方法.我认为这是问题,但我不知道.
我有
from player import player
def initializeGame():
player1 = player()
player1.shuffleDeck()
player2 = player()
player2.shuffleDeck()
Run Code Online (Sandbox Code Playgroud)
和
from deck import deck
class player(object):
def __init__(self):
self.hand = []
self.deck = deck()
def drawCard(self):
c = self.deck.cards
cardDrawn = c.pop(0)
self.hand.append(cardDrawn)
def shuffleDeck(self):
from random import shuffle
shuffle(self.deck.cards)
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试初始化游戏时,它说"播放器1尚未被定义",我不确定为什么.在同一个文件中,如果我只使用"player1 = player()"那么它完全没问题,但它拒绝在函数内部工作.有帮助吗?
编辑:添加之前未包含的内容
class deck(object):
def __init__(self):
self.cards = []
def viewLibrary(self):
for x in self.cards:
print(x.name)
def viewNumberOfCards(self, cardsToView):
for x in self.cards[:cardsToView]:
print(x.name)
from deck import deck
class player(object):
def …Run Code Online (Sandbox Code Playgroud)