我遇到了类似于这个问题的问题: Rails资产管道不包括application.js中的必需文件然而,这个问题已经关闭,所以我重新询问它,但是我的具体情况.)
Ruby 2.0.0,Rails 3.2.8,OSX 10.7.5,Chrome 28.0.1500.95
置于"/ app/assets/javascripts"中的文件似乎没有编译或出现在"/ public/assets"中
如果我在app/assets/javascripts中放置一个这样的test.js文件:
alert("Hello!");
Run Code Online (Sandbox Code Playgroud)
然后在我的应用程序中重新加载页面,此警报应该出现.(我正在复制Ryan Bates在资产管道上的Railscast中在~6:30进行视频时所做的事情)但是,没有出现警报.
我做了一些测试来尝试调试这个.
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试设置autoprefixer npm包.我想插入一些css,看看它是否根据需要添加了供应商前缀.但是,我不确定我会添加什么css会触发特定于供应商的自动插入.
我怎么能弄清楚用什么css来确认包是否有效?
例如,如果我使用OSX Chrome v49.x,我会使用什么?
我目前正在采用更多的TDD方法,并希望在测试React组件方面做得更好.测试我正在努力解决的React组件的一个方面是测试子组件对父组件的回调.
测试内部React组件通信的有效方法是什么,例如回调父组件?
对这个问题的回答似乎提供了一个可能的解决方案,虽然我不太了解它(例如,我并不完全熟悉如何在Jasmine测试中使用函数链.)
提前感谢任何提示和建议!
例
(以下示例使用Meteor,但我不一定要寻找特定于Meteor的解决方案.)
假设我有一个接受文本输入的组件,并通过提交上的props传递它:
SingleFieldSubmit = React.createClass({
propTypes: {
handleInput: React.PropTypes.func.isRequired
},
getDefaultProps() {
return {
inputValue: ""
};
},
getInitialState() {
return {
inputValue: this.props.inputValue
};
},
updateInputValue(e){
this.setState({inputValue: e.target.value});
},
handleSubmit(e) {
e.preventDefault();
this.handleInput();
},
handleInput(){
this.props.handleInput(this.state.inputValue.trim());
},
render() {
return (
<form className="single-field-submit" onSubmit={this.handleSubmit}>
<input
type="text"
value={this.state.inputValue}
onChange={this.updateInputValue}
/>
</form>
)
}
});
Run Code Online (Sandbox Code Playgroud)
在这里,我想测试组件是否在提交时传递用户输入.我目前有点笨重的解决方案是创建一个模拟父组件,我要测试的组件包含在子项中:
MockParentComponent = React.createClass({
getInitialState: function() {
return {
callbackValue: null
};
},
handleCallback: function(value) {
this.setState({callbackValue: …Run Code Online (Sandbox Code Playgroud)